babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381
  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, isLocal: boolean) => 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, isLocal: boolean) => 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. private _framebufferDimensionsObject;
  32110. /**
  32111. * sets the object from which width and height will be taken from when getting render width and height
  32112. * Will fallback to the gl object
  32113. * @param dimensions the framebuffer width and height that will be used.
  32114. */
  32115. set framebufferDimensionsObject(dimensions: Nullable<{
  32116. framebufferWidth: number;
  32117. framebufferHeight: number;
  32118. }>);
  32119. /**
  32120. * Gets the list of texture formats supported
  32121. */
  32122. get texturesSupported(): Array<string>;
  32123. /**
  32124. * Gets the list of texture formats in use
  32125. */
  32126. get textureFormatInUse(): Nullable<string>;
  32127. /**
  32128. * Gets the current viewport
  32129. */
  32130. get currentViewport(): Nullable<IViewportLike>;
  32131. /**
  32132. * Gets the default empty texture
  32133. */
  32134. get emptyTexture(): InternalTexture;
  32135. /**
  32136. * Gets the default empty 3D texture
  32137. */
  32138. get emptyTexture3D(): InternalTexture;
  32139. /**
  32140. * Gets the default empty 2D array texture
  32141. */
  32142. get emptyTexture2DArray(): InternalTexture;
  32143. /**
  32144. * Gets the default empty cube texture
  32145. */
  32146. get emptyCubeTexture(): InternalTexture;
  32147. /**
  32148. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32149. */
  32150. readonly premultipliedAlpha: boolean;
  32151. /**
  32152. * Observable event triggered before each texture is initialized
  32153. */
  32154. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32155. /**
  32156. * Creates a new engine
  32157. * @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
  32158. * @param antialias defines enable antialiasing (default: false)
  32159. * @param options defines further options to be sent to the getContext() function
  32160. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32161. */
  32162. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32163. private _rebuildInternalTextures;
  32164. private _rebuildEffects;
  32165. /**
  32166. * Gets a boolean indicating if all created effects are ready
  32167. * @returns true if all effects are ready
  32168. */
  32169. areAllEffectsReady(): boolean;
  32170. protected _rebuildBuffers(): void;
  32171. private _initGLContext;
  32172. /**
  32173. * Gets version of the current webGL context
  32174. */
  32175. get webGLVersion(): number;
  32176. /**
  32177. * Gets a string idenfifying the name of the class
  32178. * @returns "Engine" string
  32179. */
  32180. getClassName(): string;
  32181. /**
  32182. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32183. */
  32184. get isStencilEnable(): boolean;
  32185. /** @hidden */
  32186. _prepareWorkingCanvas(): void;
  32187. /**
  32188. * Reset the texture cache to empty state
  32189. */
  32190. resetTextureCache(): void;
  32191. /**
  32192. * Gets an object containing information about the current webGL context
  32193. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32194. */
  32195. getGlInfo(): {
  32196. vendor: string;
  32197. renderer: string;
  32198. version: string;
  32199. };
  32200. /**
  32201. * Defines the hardware scaling level.
  32202. * By default the hardware scaling level is computed from the window device ratio.
  32203. * 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.
  32204. * @param level defines the level to use
  32205. */
  32206. setHardwareScalingLevel(level: number): void;
  32207. /**
  32208. * Gets the current hardware scaling level.
  32209. * By default the hardware scaling level is computed from the window device ratio.
  32210. * 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.
  32211. * @returns a number indicating the current hardware scaling level
  32212. */
  32213. getHardwareScalingLevel(): number;
  32214. /**
  32215. * Gets the list of loaded textures
  32216. * @returns an array containing all loaded textures
  32217. */
  32218. getLoadedTexturesCache(): InternalTexture[];
  32219. /**
  32220. * Gets the object containing all engine capabilities
  32221. * @returns the EngineCapabilities object
  32222. */
  32223. getCaps(): EngineCapabilities;
  32224. /**
  32225. * stop executing a render loop function and remove it from the execution array
  32226. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32227. */
  32228. stopRenderLoop(renderFunction?: () => void): void;
  32229. /** @hidden */
  32230. _renderLoop(): void;
  32231. /**
  32232. * Gets the HTML canvas attached with the current webGL context
  32233. * @returns a HTML canvas
  32234. */
  32235. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32236. /**
  32237. * Gets host window
  32238. * @returns the host window object
  32239. */
  32240. getHostWindow(): Nullable<Window>;
  32241. /**
  32242. * Gets the current render width
  32243. * @param useScreen defines if screen size must be used (or the current render target if any)
  32244. * @returns a number defining the current render width
  32245. */
  32246. getRenderWidth(useScreen?: boolean): number;
  32247. /**
  32248. * Gets the current render height
  32249. * @param useScreen defines if screen size must be used (or the current render target if any)
  32250. * @returns a number defining the current render height
  32251. */
  32252. getRenderHeight(useScreen?: boolean): number;
  32253. /**
  32254. * Can be used to override the current requestAnimationFrame requester.
  32255. * @hidden
  32256. */
  32257. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32258. /**
  32259. * Register and execute a render loop. The engine can have more than one render function
  32260. * @param renderFunction defines the function to continuously execute
  32261. */
  32262. runRenderLoop(renderFunction: () => void): void;
  32263. /**
  32264. * Clear the current render buffer or the current render target (if any is set up)
  32265. * @param color defines the color to use
  32266. * @param backBuffer defines if the back buffer must be cleared
  32267. * @param depth defines if the depth buffer must be cleared
  32268. * @param stencil defines if the stencil buffer must be cleared
  32269. */
  32270. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32271. private _viewportCached;
  32272. /** @hidden */
  32273. _viewport(x: number, y: number, width: number, height: number): void;
  32274. /**
  32275. * Set the WebGL's viewport
  32276. * @param viewport defines the viewport element to be used
  32277. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32278. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32279. */
  32280. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32281. /**
  32282. * Begin a new frame
  32283. */
  32284. beginFrame(): void;
  32285. /**
  32286. * Enf the current frame
  32287. */
  32288. endFrame(): void;
  32289. /**
  32290. * Resize the view according to the canvas' size
  32291. */
  32292. resize(): void;
  32293. /**
  32294. * Force a specific size of the canvas
  32295. * @param width defines the new canvas' width
  32296. * @param height defines the new canvas' height
  32297. */
  32298. setSize(width: number, height: number): void;
  32299. /**
  32300. * Binds the frame buffer to the specified texture.
  32301. * @param texture The texture to render to or null for the default canvas
  32302. * @param faceIndex The face of the texture to render to in case of cube texture
  32303. * @param requiredWidth The width of the target to render to
  32304. * @param requiredHeight The height of the target to render to
  32305. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32306. * @param lodLevel defines the lod level to bind to the frame buffer
  32307. * @param layer defines the 2d array index to bind to frame buffer to
  32308. */
  32309. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32310. /** @hidden */
  32311. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32312. /**
  32313. * Unbind the current render target texture from the webGL context
  32314. * @param texture defines the render target texture to unbind
  32315. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32316. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32317. */
  32318. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32319. /**
  32320. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32321. */
  32322. flushFramebuffer(): void;
  32323. /**
  32324. * Unbind the current render target and bind the default framebuffer
  32325. */
  32326. restoreDefaultFramebuffer(): void;
  32327. /** @hidden */
  32328. protected _resetVertexBufferBinding(): void;
  32329. /**
  32330. * Creates a vertex buffer
  32331. * @param data the data for the vertex buffer
  32332. * @returns the new WebGL static buffer
  32333. */
  32334. createVertexBuffer(data: DataArray): DataBuffer;
  32335. private _createVertexBuffer;
  32336. /**
  32337. * Creates a dynamic vertex buffer
  32338. * @param data the data for the dynamic vertex buffer
  32339. * @returns the new WebGL dynamic buffer
  32340. */
  32341. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32342. protected _resetIndexBufferBinding(): void;
  32343. /**
  32344. * Creates a new index buffer
  32345. * @param indices defines the content of the index buffer
  32346. * @param updatable defines if the index buffer must be updatable
  32347. * @returns a new webGL buffer
  32348. */
  32349. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32350. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32351. /**
  32352. * Bind a webGL buffer to the webGL context
  32353. * @param buffer defines the buffer to bind
  32354. */
  32355. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32356. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32357. private bindBuffer;
  32358. /**
  32359. * update the bound buffer with the given data
  32360. * @param data defines the data to update
  32361. */
  32362. updateArrayBuffer(data: Float32Array): void;
  32363. private _vertexAttribPointer;
  32364. /** @hidden */
  32365. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32366. private _bindVertexBuffersAttributes;
  32367. /**
  32368. * Records a vertex array object
  32369. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32370. * @param vertexBuffers defines the list of vertex buffers to store
  32371. * @param indexBuffer defines the index buffer to store
  32372. * @param effect defines the effect to store
  32373. * @returns the new vertex array object
  32374. */
  32375. recordVertexArrayObject(vertexBuffers: {
  32376. [key: string]: VertexBuffer;
  32377. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32378. /**
  32379. * Bind a specific vertex array object
  32380. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32381. * @param vertexArrayObject defines the vertex array object to bind
  32382. * @param indexBuffer defines the index buffer to bind
  32383. */
  32384. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32385. /**
  32386. * Bind webGl buffers directly to the webGL context
  32387. * @param vertexBuffer defines the vertex buffer to bind
  32388. * @param indexBuffer defines the index buffer to bind
  32389. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32390. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32391. * @param effect defines the effect associated with the vertex buffer
  32392. */
  32393. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32394. private _unbindVertexArrayObject;
  32395. /**
  32396. * Bind a list of vertex buffers to the webGL context
  32397. * @param vertexBuffers defines the list of vertex buffers to bind
  32398. * @param indexBuffer defines the index buffer to bind
  32399. * @param effect defines the effect associated with the vertex buffers
  32400. */
  32401. bindBuffers(vertexBuffers: {
  32402. [key: string]: Nullable<VertexBuffer>;
  32403. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32404. /**
  32405. * Unbind all instance attributes
  32406. */
  32407. unbindInstanceAttributes(): void;
  32408. /**
  32409. * Release and free the memory of a vertex array object
  32410. * @param vao defines the vertex array object to delete
  32411. */
  32412. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32413. /** @hidden */
  32414. _releaseBuffer(buffer: DataBuffer): boolean;
  32415. protected _deleteBuffer(buffer: DataBuffer): void;
  32416. /**
  32417. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32418. * @param instancesBuffer defines the webGL buffer to update and bind
  32419. * @param data defines the data to store in the buffer
  32420. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32421. */
  32422. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32423. /**
  32424. * Bind the content of a webGL buffer used with instantiation
  32425. * @param instancesBuffer defines the webGL buffer to bind
  32426. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32427. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32428. */
  32429. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32430. /**
  32431. * Disable the instance attribute corresponding to the name in parameter
  32432. * @param name defines the name of the attribute to disable
  32433. */
  32434. disableInstanceAttributeByName(name: string): void;
  32435. /**
  32436. * Disable the instance attribute corresponding to the location in parameter
  32437. * @param attributeLocation defines the attribute location of the attribute to disable
  32438. */
  32439. disableInstanceAttribute(attributeLocation: number): void;
  32440. /**
  32441. * Disable the attribute corresponding to the location in parameter
  32442. * @param attributeLocation defines the attribute location of the attribute to disable
  32443. */
  32444. disableAttributeByIndex(attributeLocation: number): void;
  32445. /**
  32446. * Send a draw order
  32447. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32448. * @param indexStart defines the starting index
  32449. * @param indexCount defines the number of index to draw
  32450. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32451. */
  32452. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32453. /**
  32454. * Draw a list of points
  32455. * @param verticesStart defines the index of first vertex to draw
  32456. * @param verticesCount defines the count of vertices to draw
  32457. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32458. */
  32459. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32460. /**
  32461. * Draw a list of unindexed primitives
  32462. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32463. * @param verticesStart defines the index of first vertex to draw
  32464. * @param verticesCount defines the count of vertices to draw
  32465. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32466. */
  32467. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32468. /**
  32469. * Draw a list of indexed primitives
  32470. * @param fillMode defines the primitive to use
  32471. * @param indexStart defines the starting index
  32472. * @param indexCount defines the number of index to draw
  32473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32474. */
  32475. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32476. /**
  32477. * Draw a list of unindexed primitives
  32478. * @param fillMode defines the primitive to use
  32479. * @param verticesStart defines the index of first vertex to draw
  32480. * @param verticesCount defines the count of vertices to draw
  32481. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32482. */
  32483. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32484. private _drawMode;
  32485. /** @hidden */
  32486. protected _reportDrawCall(): void;
  32487. /** @hidden */
  32488. _releaseEffect(effect: Effect): void;
  32489. /** @hidden */
  32490. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32491. /**
  32492. * Create a new effect (used to store vertex/fragment shaders)
  32493. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32494. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32495. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32496. * @param samplers defines an array of string used to represent textures
  32497. * @param defines defines the string containing the defines to use to compile the shaders
  32498. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32499. * @param onCompiled defines a function to call when the effect creation is successful
  32500. * @param onError defines a function to call when the effect creation has failed
  32501. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32502. * @returns the new Effect
  32503. */
  32504. 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;
  32505. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32506. private _compileShader;
  32507. private _compileRawShader;
  32508. /**
  32509. * Directly 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 context defines the webGL context to use (if not set, the current one will be used)
  32514. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32515. * @returns the new webGL program
  32516. */
  32517. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32518. /**
  32519. * Creates a webGL program
  32520. * @param pipelineContext defines the pipeline context to attach to
  32521. * @param vertexCode defines the vertex shader code to use
  32522. * @param fragmentCode defines the fragment shader code to use
  32523. * @param defines defines the string containing the defines to use to compile the shaders
  32524. * @param context defines the webGL context to use (if not set, the current one will be used)
  32525. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32526. * @returns the new webGL program
  32527. */
  32528. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32529. /**
  32530. * Creates a new pipeline context
  32531. * @returns the new pipeline
  32532. */
  32533. createPipelineContext(): IPipelineContext;
  32534. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32535. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32536. /** @hidden */
  32537. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32538. /** @hidden */
  32539. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32540. /** @hidden */
  32541. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32542. /**
  32543. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32544. * @param pipelineContext defines the pipeline context to use
  32545. * @param uniformsNames defines the list of uniform names
  32546. * @returns an array of webGL uniform locations
  32547. */
  32548. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32549. /**
  32550. * Gets the lsit of active attributes for a given webGL program
  32551. * @param pipelineContext defines the pipeline context to use
  32552. * @param attributesNames defines the list of attribute names to get
  32553. * @returns an array of indices indicating the offset of each attribute
  32554. */
  32555. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32556. /**
  32557. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32558. * @param effect defines the effect to activate
  32559. */
  32560. enableEffect(effect: Nullable<Effect>): void;
  32561. /**
  32562. * Set the value of an uniform to a number (int)
  32563. * @param uniform defines the webGL uniform location where to store the value
  32564. * @param value defines the int number to store
  32565. */
  32566. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32567. /**
  32568. * Set the value of an uniform to an array of int32
  32569. * @param uniform defines the webGL uniform location where to store the value
  32570. * @param array defines the array of int32 to store
  32571. */
  32572. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32573. /**
  32574. * Set the value of an uniform to an array of int32 (stored as vec2)
  32575. * @param uniform defines the webGL uniform location where to store the value
  32576. * @param array defines the array of int32 to store
  32577. */
  32578. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32579. /**
  32580. * Set the value of an uniform to an array of int32 (stored as vec3)
  32581. * @param uniform defines the webGL uniform location where to store the value
  32582. * @param array defines the array of int32 to store
  32583. */
  32584. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32585. /**
  32586. * Set the value of an uniform to an array of int32 (stored as vec4)
  32587. * @param uniform defines the webGL uniform location where to store the value
  32588. * @param array defines the array of int32 to store
  32589. */
  32590. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32591. /**
  32592. * Set the value of an uniform to an array of number
  32593. * @param uniform defines the webGL uniform location where to store the value
  32594. * @param array defines the array of number to store
  32595. */
  32596. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32597. /**
  32598. * Set the value of an uniform to an array of number (stored as vec2)
  32599. * @param uniform defines the webGL uniform location where to store the value
  32600. * @param array defines the array of number to store
  32601. */
  32602. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32603. /**
  32604. * Set the value of an uniform to an array of number (stored as vec3)
  32605. * @param uniform defines the webGL uniform location where to store the value
  32606. * @param array defines the array of number to store
  32607. */
  32608. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32609. /**
  32610. * Set the value of an uniform to an array of number (stored as vec4)
  32611. * @param uniform defines the webGL uniform location where to store the value
  32612. * @param array defines the array of number to store
  32613. */
  32614. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32615. /**
  32616. * Set the value of an uniform to an array of float32 (stored as matrices)
  32617. * @param uniform defines the webGL uniform location where to store the value
  32618. * @param matrices defines the array of float32 to store
  32619. */
  32620. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32621. /**
  32622. * Set the value of an uniform to a matrix (3x3)
  32623. * @param uniform defines the webGL uniform location where to store the value
  32624. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32625. */
  32626. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32627. /**
  32628. * Set the value of an uniform to a matrix (2x2)
  32629. * @param uniform defines the webGL uniform location where to store the value
  32630. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32631. */
  32632. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32633. /**
  32634. * Set the value of an uniform to a number (float)
  32635. * @param uniform defines the webGL uniform location where to store the value
  32636. * @param value defines the float number to store
  32637. */
  32638. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32639. /**
  32640. * Set the value of an uniform to a vec2
  32641. * @param uniform defines the webGL uniform location where to store the value
  32642. * @param x defines the 1st component of the value
  32643. * @param y defines the 2nd component of the value
  32644. */
  32645. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32646. /**
  32647. * Set the value of an uniform to a vec3
  32648. * @param uniform defines the webGL uniform location where to store the value
  32649. * @param x defines the 1st component of the value
  32650. * @param y defines the 2nd component of the value
  32651. * @param z defines the 3rd component of the value
  32652. */
  32653. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32654. /**
  32655. * Set the value of an uniform to a vec4
  32656. * @param uniform defines the webGL uniform location where to store the value
  32657. * @param x defines the 1st component of the value
  32658. * @param y defines the 2nd component of the value
  32659. * @param z defines the 3rd component of the value
  32660. * @param w defines the 4th component of the value
  32661. */
  32662. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32663. /**
  32664. * Apply all cached states (depth, culling, stencil and alpha)
  32665. */
  32666. applyStates(): void;
  32667. /**
  32668. * Enable or disable color writing
  32669. * @param enable defines the state to set
  32670. */
  32671. setColorWrite(enable: boolean): void;
  32672. /**
  32673. * Gets a boolean indicating if color writing is enabled
  32674. * @returns the current color writing state
  32675. */
  32676. getColorWrite(): boolean;
  32677. /**
  32678. * Gets the depth culling state manager
  32679. */
  32680. get depthCullingState(): DepthCullingState;
  32681. /**
  32682. * Gets the alpha state manager
  32683. */
  32684. get alphaState(): AlphaState;
  32685. /**
  32686. * Gets the stencil state manager
  32687. */
  32688. get stencilState(): StencilState;
  32689. /**
  32690. * Clears the list of texture accessible through engine.
  32691. * This can help preventing texture load conflict due to name collision.
  32692. */
  32693. clearInternalTexturesCache(): void;
  32694. /**
  32695. * Force the entire cache to be cleared
  32696. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32697. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32698. */
  32699. wipeCaches(bruteForce?: boolean): void;
  32700. /** @hidden */
  32701. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32702. min: number;
  32703. mag: number;
  32704. };
  32705. /** @hidden */
  32706. _createTexture(): WebGLTexture;
  32707. /**
  32708. * Usually called from Texture.ts.
  32709. * Passed information to create a WebGLTexture
  32710. * @param urlArg defines a value which contains one of the following:
  32711. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32712. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32713. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32714. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32715. * @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)
  32716. * @param scene needed for loading to the correct scene
  32717. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32718. * @param onLoad optional callback to be called upon successful completion
  32719. * @param onError optional callback to be called upon failure
  32720. * @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
  32721. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32722. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32723. * @param forcedExtension defines the extension to use to pick the right loader
  32724. * @param mimeType defines an optional mime type
  32725. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32726. */
  32727. 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;
  32728. /**
  32729. * Loads an image as an HTMLImageElement.
  32730. * @param input url string, ArrayBuffer, or Blob to load
  32731. * @param onLoad callback called when the image successfully loads
  32732. * @param onError callback called when the image fails to load
  32733. * @param offlineProvider offline provider for caching
  32734. * @param mimeType optional mime type
  32735. * @returns the HTMLImageElement of the loaded image
  32736. * @hidden
  32737. */
  32738. 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>;
  32739. /**
  32740. * @hidden
  32741. */
  32742. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32743. /**
  32744. * Creates a raw texture
  32745. * @param data defines the data to store in the texture
  32746. * @param width defines the width of the texture
  32747. * @param height defines the height of the texture
  32748. * @param format defines the format of the data
  32749. * @param generateMipMaps defines if the engine should generate the mip levels
  32750. * @param invertY defines if data must be stored with Y axis inverted
  32751. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32752. * @param compression defines the compression used (null by default)
  32753. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32754. * @returns the raw texture inside an InternalTexture
  32755. */
  32756. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32757. /**
  32758. * Creates a new raw cube texture
  32759. * @param data defines the array of data to use to create each face
  32760. * @param size defines the size of the textures
  32761. * @param format defines the format of the data
  32762. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32763. * @param generateMipMaps defines if the engine should generate the mip levels
  32764. * @param invertY defines if data must be stored with Y axis inverted
  32765. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32766. * @param compression defines the compression used (null by default)
  32767. * @returns the cube texture as an InternalTexture
  32768. */
  32769. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32770. /**
  32771. * Creates a new raw 3D texture
  32772. * @param data defines the data used to create the texture
  32773. * @param width defines the width of the texture
  32774. * @param height defines the height of the texture
  32775. * @param depth defines the depth of the texture
  32776. * @param format defines the format of the texture
  32777. * @param generateMipMaps defines if the engine must generate mip levels
  32778. * @param invertY defines if data must be stored with Y axis inverted
  32779. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32780. * @param compression defines the compressed used (can be null)
  32781. * @param textureType defines the compressed used (can be null)
  32782. * @returns a new raw 3D texture (stored in an InternalTexture)
  32783. */
  32784. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32785. /**
  32786. * Creates a new raw 2D array texture
  32787. * @param data defines the data used to create the texture
  32788. * @param width defines the width of the texture
  32789. * @param height defines the height of the texture
  32790. * @param depth defines the number of layers of the texture
  32791. * @param format defines the format of the texture
  32792. * @param generateMipMaps defines if the engine must generate mip levels
  32793. * @param invertY defines if data must be stored with Y axis inverted
  32794. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32795. * @param compression defines the compressed used (can be null)
  32796. * @param textureType defines the compressed used (can be null)
  32797. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32798. */
  32799. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32800. private _unpackFlipYCached;
  32801. /**
  32802. * In case you are sharing the context with other applications, it might
  32803. * be interested to not cache the unpack flip y state to ensure a consistent
  32804. * value would be set.
  32805. */
  32806. enableUnpackFlipYCached: boolean;
  32807. /** @hidden */
  32808. _unpackFlipY(value: boolean): void;
  32809. /** @hidden */
  32810. _getUnpackAlignement(): number;
  32811. private _getTextureTarget;
  32812. /**
  32813. * Update the sampling mode of a given texture
  32814. * @param samplingMode defines the required sampling mode
  32815. * @param texture defines the texture to update
  32816. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32817. */
  32818. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32819. /**
  32820. * Update the sampling mode of a given texture
  32821. * @param texture defines the texture to update
  32822. * @param wrapU defines the texture wrap mode of the u coordinates
  32823. * @param wrapV defines the texture wrap mode of the v coordinates
  32824. * @param wrapR defines the texture wrap mode of the r coordinates
  32825. */
  32826. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32827. /** @hidden */
  32828. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32829. width: number;
  32830. height: number;
  32831. layers?: number;
  32832. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32833. /** @hidden */
  32834. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32835. /** @hidden */
  32836. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32837. /**
  32838. * Update a portion of an internal texture
  32839. * @param texture defines the texture to update
  32840. * @param imageData defines the data to store into the texture
  32841. * @param xOffset defines the x coordinates of the update rectangle
  32842. * @param yOffset defines the y coordinates of the update rectangle
  32843. * @param width defines the width of the update rectangle
  32844. * @param height defines the height of the update rectangle
  32845. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32846. * @param lod defines the lod level to update (0 by default)
  32847. */
  32848. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32849. /** @hidden */
  32850. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32851. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32852. private _prepareWebGLTexture;
  32853. /** @hidden */
  32854. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32855. private _getDepthStencilBuffer;
  32856. /** @hidden */
  32857. _releaseFramebufferObjects(texture: InternalTexture): void;
  32858. /** @hidden */
  32859. _releaseTexture(texture: InternalTexture): void;
  32860. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32861. protected _setProgram(program: WebGLProgram): void;
  32862. protected _boundUniforms: {
  32863. [key: number]: WebGLUniformLocation;
  32864. };
  32865. /**
  32866. * Binds an effect to the webGL context
  32867. * @param effect defines the effect to bind
  32868. */
  32869. bindSamplers(effect: Effect): void;
  32870. private _activateCurrentTexture;
  32871. /** @hidden */
  32872. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32873. /** @hidden */
  32874. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32875. /**
  32876. * Unbind all textures from the webGL context
  32877. */
  32878. unbindAllTextures(): void;
  32879. /**
  32880. * Sets a texture to the according uniform.
  32881. * @param channel The texture channel
  32882. * @param uniform The uniform to set
  32883. * @param texture The texture to apply
  32884. */
  32885. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32886. private _bindSamplerUniformToChannel;
  32887. private _getTextureWrapMode;
  32888. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32889. /**
  32890. * Sets an array of texture to the webGL context
  32891. * @param channel defines the channel where the texture array must be set
  32892. * @param uniform defines the associated uniform location
  32893. * @param textures defines the array of textures to bind
  32894. */
  32895. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32896. /** @hidden */
  32897. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32898. private _setTextureParameterFloat;
  32899. private _setTextureParameterInteger;
  32900. /**
  32901. * Unbind all vertex attributes from the webGL context
  32902. */
  32903. unbindAllAttributes(): void;
  32904. /**
  32905. * 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
  32906. */
  32907. releaseEffects(): void;
  32908. /**
  32909. * Dispose and release all associated resources
  32910. */
  32911. dispose(): void;
  32912. /**
  32913. * Attach a new callback raised when context lost event is fired
  32914. * @param callback defines the callback to call
  32915. */
  32916. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32917. /**
  32918. * Attach a new callback raised when context restored event is fired
  32919. * @param callback defines the callback to call
  32920. */
  32921. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32922. /**
  32923. * Get the current error code of the webGL context
  32924. * @returns the error code
  32925. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32926. */
  32927. getError(): number;
  32928. private _canRenderToFloatFramebuffer;
  32929. private _canRenderToHalfFloatFramebuffer;
  32930. private _canRenderToFramebuffer;
  32931. /** @hidden */
  32932. _getWebGLTextureType(type: number): number;
  32933. /** @hidden */
  32934. _getInternalFormat(format: number): number;
  32935. /** @hidden */
  32936. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32937. /** @hidden */
  32938. _getRGBAMultiSampleBufferFormat(type: number): number;
  32939. /** @hidden */
  32940. _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;
  32941. /**
  32942. * Loads a file from a url
  32943. * @param url url to load
  32944. * @param onSuccess callback called when the file successfully loads
  32945. * @param onProgress callback called while file is loading (if the server supports this mode)
  32946. * @param offlineProvider defines the offline provider for caching
  32947. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32948. * @param onError callback called when the file fails to load
  32949. * @returns a file request object
  32950. * @hidden
  32951. */
  32952. 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;
  32953. /**
  32954. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32955. * @param x defines the x coordinate of the rectangle where pixels must be read
  32956. * @param y defines the y coordinate of the rectangle where pixels must be read
  32957. * @param width defines the width of the rectangle where pixels must be read
  32958. * @param height defines the height of the rectangle where pixels must be read
  32959. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32960. * @returns a Uint8Array containing RGBA colors
  32961. */
  32962. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32963. private static _isSupported;
  32964. /**
  32965. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32966. * @returns true if the engine can be created
  32967. * @ignorenaming
  32968. */
  32969. static isSupported(): boolean;
  32970. /**
  32971. * Find the next highest power of two.
  32972. * @param x Number to start search from.
  32973. * @return Next highest power of two.
  32974. */
  32975. static CeilingPOT(x: number): number;
  32976. /**
  32977. * Find the next lowest power of two.
  32978. * @param x Number to start search from.
  32979. * @return Next lowest power of two.
  32980. */
  32981. static FloorPOT(x: number): number;
  32982. /**
  32983. * Find the nearest power of two.
  32984. * @param x Number to start search from.
  32985. * @return Next nearest power of two.
  32986. */
  32987. static NearestPOT(x: number): number;
  32988. /**
  32989. * Get the closest exponent of two
  32990. * @param value defines the value to approximate
  32991. * @param max defines the maximum value to return
  32992. * @param mode defines how to define the closest value
  32993. * @returns closest exponent of two of the given value
  32994. */
  32995. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32996. /**
  32997. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32998. * @param func - the function to be called
  32999. * @param requester - the object that will request the next frame. Falls back to window.
  33000. * @returns frame number
  33001. */
  33002. static QueueNewFrame(func: () => void, requester?: any): number;
  33003. /**
  33004. * Gets host document
  33005. * @returns the host document object
  33006. */
  33007. getHostDocument(): Nullable<Document>;
  33008. }
  33009. }
  33010. declare module "babylonjs/Maths/sphericalPolynomial" {
  33011. import { Vector3 } from "babylonjs/Maths/math.vector";
  33012. import { Color3 } from "babylonjs/Maths/math.color";
  33013. /**
  33014. * Class representing spherical harmonics coefficients to the 3rd degree
  33015. */
  33016. export class SphericalHarmonics {
  33017. /**
  33018. * Defines whether or not the harmonics have been prescaled for rendering.
  33019. */
  33020. preScaled: boolean;
  33021. /**
  33022. * The l0,0 coefficients of the spherical harmonics
  33023. */
  33024. l00: Vector3;
  33025. /**
  33026. * The l1,-1 coefficients of the spherical harmonics
  33027. */
  33028. l1_1: Vector3;
  33029. /**
  33030. * The l1,0 coefficients of the spherical harmonics
  33031. */
  33032. l10: Vector3;
  33033. /**
  33034. * The l1,1 coefficients of the spherical harmonics
  33035. */
  33036. l11: Vector3;
  33037. /**
  33038. * The l2,-2 coefficients of the spherical harmonics
  33039. */
  33040. l2_2: Vector3;
  33041. /**
  33042. * The l2,-1 coefficients of the spherical harmonics
  33043. */
  33044. l2_1: Vector3;
  33045. /**
  33046. * The l2,0 coefficients of the spherical harmonics
  33047. */
  33048. l20: Vector3;
  33049. /**
  33050. * The l2,1 coefficients of the spherical harmonics
  33051. */
  33052. l21: Vector3;
  33053. /**
  33054. * The l2,2 coefficients of the spherical harmonics
  33055. */
  33056. l22: Vector3;
  33057. /**
  33058. * Adds a light to the spherical harmonics
  33059. * @param direction the direction of the light
  33060. * @param color the color of the light
  33061. * @param deltaSolidAngle the delta solid angle of the light
  33062. */
  33063. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33064. /**
  33065. * Scales the spherical harmonics by the given amount
  33066. * @param scale the amount to scale
  33067. */
  33068. scaleInPlace(scale: number): void;
  33069. /**
  33070. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33071. *
  33072. * ```
  33073. * E_lm = A_l * L_lm
  33074. * ```
  33075. *
  33076. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33077. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33078. * the scaling factors are given in equation 9.
  33079. */
  33080. convertIncidentRadianceToIrradiance(): void;
  33081. /**
  33082. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33083. *
  33084. * ```
  33085. * L = (1/pi) * E * rho
  33086. * ```
  33087. *
  33088. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33089. */
  33090. convertIrradianceToLambertianRadiance(): void;
  33091. /**
  33092. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33093. * required operations at run time.
  33094. *
  33095. * This is simply done by scaling back the SH with Ylm constants parameter.
  33096. * The trigonometric part being applied by the shader at run time.
  33097. */
  33098. preScaleForRendering(): void;
  33099. /**
  33100. * Constructs a spherical harmonics from an array.
  33101. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33102. * @returns the spherical harmonics
  33103. */
  33104. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33105. /**
  33106. * Gets the spherical harmonics from polynomial
  33107. * @param polynomial the spherical polynomial
  33108. * @returns the spherical harmonics
  33109. */
  33110. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33111. }
  33112. /**
  33113. * Class representing spherical polynomial coefficients to the 3rd degree
  33114. */
  33115. export class SphericalPolynomial {
  33116. private _harmonics;
  33117. /**
  33118. * The spherical harmonics used to create the polynomials.
  33119. */
  33120. get preScaledHarmonics(): SphericalHarmonics;
  33121. /**
  33122. * The x coefficients of the spherical polynomial
  33123. */
  33124. x: Vector3;
  33125. /**
  33126. * The y coefficients of the spherical polynomial
  33127. */
  33128. y: Vector3;
  33129. /**
  33130. * The z coefficients of the spherical polynomial
  33131. */
  33132. z: Vector3;
  33133. /**
  33134. * The xx coefficients of the spherical polynomial
  33135. */
  33136. xx: Vector3;
  33137. /**
  33138. * The yy coefficients of the spherical polynomial
  33139. */
  33140. yy: Vector3;
  33141. /**
  33142. * The zz coefficients of the spherical polynomial
  33143. */
  33144. zz: Vector3;
  33145. /**
  33146. * The xy coefficients of the spherical polynomial
  33147. */
  33148. xy: Vector3;
  33149. /**
  33150. * The yz coefficients of the spherical polynomial
  33151. */
  33152. yz: Vector3;
  33153. /**
  33154. * The zx coefficients of the spherical polynomial
  33155. */
  33156. zx: Vector3;
  33157. /**
  33158. * Adds an ambient color to the spherical polynomial
  33159. * @param color the color to add
  33160. */
  33161. addAmbient(color: Color3): void;
  33162. /**
  33163. * Scales the spherical polynomial by the given amount
  33164. * @param scale the amount to scale
  33165. */
  33166. scaleInPlace(scale: number): void;
  33167. /**
  33168. * Gets the spherical polynomial from harmonics
  33169. * @param harmonics the spherical harmonics
  33170. * @returns the spherical polynomial
  33171. */
  33172. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33173. /**
  33174. * Constructs a spherical polynomial from an array.
  33175. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33176. * @returns the spherical polynomial
  33177. */
  33178. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33179. }
  33180. }
  33181. declare module "babylonjs/Materials/Textures/internalTexture" {
  33182. import { Observable } from "babylonjs/Misc/observable";
  33183. import { Nullable, int } from "babylonjs/types";
  33184. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33185. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33186. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33187. /**
  33188. * Defines the source of the internal texture
  33189. */
  33190. export enum InternalTextureSource {
  33191. /**
  33192. * The source of the texture data is unknown
  33193. */
  33194. Unknown = 0,
  33195. /**
  33196. * Texture data comes from an URL
  33197. */
  33198. Url = 1,
  33199. /**
  33200. * Texture data is only used for temporary storage
  33201. */
  33202. Temp = 2,
  33203. /**
  33204. * Texture data comes from raw data (ArrayBuffer)
  33205. */
  33206. Raw = 3,
  33207. /**
  33208. * Texture content is dynamic (video or dynamic texture)
  33209. */
  33210. Dynamic = 4,
  33211. /**
  33212. * Texture content is generated by rendering to it
  33213. */
  33214. RenderTarget = 5,
  33215. /**
  33216. * Texture content is part of a multi render target process
  33217. */
  33218. MultiRenderTarget = 6,
  33219. /**
  33220. * Texture data comes from a cube data file
  33221. */
  33222. Cube = 7,
  33223. /**
  33224. * Texture data comes from a raw cube data
  33225. */
  33226. CubeRaw = 8,
  33227. /**
  33228. * Texture data come from a prefiltered cube data file
  33229. */
  33230. CubePrefiltered = 9,
  33231. /**
  33232. * Texture content is raw 3D data
  33233. */
  33234. Raw3D = 10,
  33235. /**
  33236. * Texture content is raw 2D array data
  33237. */
  33238. Raw2DArray = 11,
  33239. /**
  33240. * Texture content is a depth texture
  33241. */
  33242. Depth = 12,
  33243. /**
  33244. * Texture data comes from a raw cube data encoded with RGBD
  33245. */
  33246. CubeRawRGBD = 13
  33247. }
  33248. /**
  33249. * Class used to store data associated with WebGL texture data for the engine
  33250. * This class should not be used directly
  33251. */
  33252. export class InternalTexture {
  33253. /** @hidden */
  33254. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33255. /**
  33256. * Defines if the texture is ready
  33257. */
  33258. isReady: boolean;
  33259. /**
  33260. * Defines if the texture is a cube texture
  33261. */
  33262. isCube: boolean;
  33263. /**
  33264. * Defines if the texture contains 3D data
  33265. */
  33266. is3D: boolean;
  33267. /**
  33268. * Defines if the texture contains 2D array data
  33269. */
  33270. is2DArray: boolean;
  33271. /**
  33272. * Defines if the texture contains multiview data
  33273. */
  33274. isMultiview: boolean;
  33275. /**
  33276. * Gets the URL used to load this texture
  33277. */
  33278. url: string;
  33279. /**
  33280. * Gets the sampling mode of the texture
  33281. */
  33282. samplingMode: number;
  33283. /**
  33284. * Gets a boolean indicating if the texture needs mipmaps generation
  33285. */
  33286. generateMipMaps: boolean;
  33287. /**
  33288. * Gets the number of samples used by the texture (WebGL2+ only)
  33289. */
  33290. samples: number;
  33291. /**
  33292. * Gets the type of the texture (int, float...)
  33293. */
  33294. type: number;
  33295. /**
  33296. * Gets the format of the texture (RGB, RGBA...)
  33297. */
  33298. format: number;
  33299. /**
  33300. * Observable called when the texture is loaded
  33301. */
  33302. onLoadedObservable: Observable<InternalTexture>;
  33303. /**
  33304. * Gets the width of the texture
  33305. */
  33306. width: number;
  33307. /**
  33308. * Gets the height of the texture
  33309. */
  33310. height: number;
  33311. /**
  33312. * Gets the depth of the texture
  33313. */
  33314. depth: number;
  33315. /**
  33316. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33317. */
  33318. baseWidth: number;
  33319. /**
  33320. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33321. */
  33322. baseHeight: number;
  33323. /**
  33324. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33325. */
  33326. baseDepth: number;
  33327. /**
  33328. * Gets a boolean indicating if the texture is inverted on Y axis
  33329. */
  33330. invertY: boolean;
  33331. /** @hidden */
  33332. _invertVScale: boolean;
  33333. /** @hidden */
  33334. _associatedChannel: number;
  33335. /** @hidden */
  33336. _source: InternalTextureSource;
  33337. /** @hidden */
  33338. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33339. /** @hidden */
  33340. _bufferView: Nullable<ArrayBufferView>;
  33341. /** @hidden */
  33342. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33343. /** @hidden */
  33344. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33345. /** @hidden */
  33346. _size: number;
  33347. /** @hidden */
  33348. _extension: string;
  33349. /** @hidden */
  33350. _files: Nullable<string[]>;
  33351. /** @hidden */
  33352. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33353. /** @hidden */
  33354. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33355. /** @hidden */
  33356. _framebuffer: Nullable<WebGLFramebuffer>;
  33357. /** @hidden */
  33358. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33359. /** @hidden */
  33360. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33361. /** @hidden */
  33362. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33363. /** @hidden */
  33364. _attachments: Nullable<number[]>;
  33365. /** @hidden */
  33366. _cachedCoordinatesMode: Nullable<number>;
  33367. /** @hidden */
  33368. _cachedWrapU: Nullable<number>;
  33369. /** @hidden */
  33370. _cachedWrapV: Nullable<number>;
  33371. /** @hidden */
  33372. _cachedWrapR: Nullable<number>;
  33373. /** @hidden */
  33374. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33375. /** @hidden */
  33376. _isDisabled: boolean;
  33377. /** @hidden */
  33378. _compression: Nullable<string>;
  33379. /** @hidden */
  33380. _generateStencilBuffer: boolean;
  33381. /** @hidden */
  33382. _generateDepthBuffer: boolean;
  33383. /** @hidden */
  33384. _comparisonFunction: number;
  33385. /** @hidden */
  33386. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33387. /** @hidden */
  33388. _lodGenerationScale: number;
  33389. /** @hidden */
  33390. _lodGenerationOffset: number;
  33391. /** @hidden */
  33392. _depthStencilTexture: Nullable<InternalTexture>;
  33393. /** @hidden */
  33394. _colorTextureArray: Nullable<WebGLTexture>;
  33395. /** @hidden */
  33396. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33397. /** @hidden */
  33398. _lodTextureHigh: Nullable<BaseTexture>;
  33399. /** @hidden */
  33400. _lodTextureMid: Nullable<BaseTexture>;
  33401. /** @hidden */
  33402. _lodTextureLow: Nullable<BaseTexture>;
  33403. /** @hidden */
  33404. _isRGBD: boolean;
  33405. /** @hidden */
  33406. _linearSpecularLOD: boolean;
  33407. /** @hidden */
  33408. _irradianceTexture: Nullable<BaseTexture>;
  33409. /** @hidden */
  33410. _webGLTexture: Nullable<WebGLTexture>;
  33411. /** @hidden */
  33412. _references: number;
  33413. private _engine;
  33414. /**
  33415. * Gets the Engine the texture belongs to.
  33416. * @returns The babylon engine
  33417. */
  33418. getEngine(): ThinEngine;
  33419. /**
  33420. * Gets the data source type of the texture
  33421. */
  33422. get source(): InternalTextureSource;
  33423. /**
  33424. * Creates a new InternalTexture
  33425. * @param engine defines the engine to use
  33426. * @param source defines the type of data that will be used
  33427. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33428. */
  33429. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33430. /**
  33431. * Increments the number of references (ie. the number of Texture that point to it)
  33432. */
  33433. incrementReferences(): void;
  33434. /**
  33435. * Change the size of the texture (not the size of the content)
  33436. * @param width defines the new width
  33437. * @param height defines the new height
  33438. * @param depth defines the new depth (1 by default)
  33439. */
  33440. updateSize(width: int, height: int, depth?: int): void;
  33441. /** @hidden */
  33442. _rebuild(): void;
  33443. /** @hidden */
  33444. _swapAndDie(target: InternalTexture): void;
  33445. /**
  33446. * Dispose the current allocated resources
  33447. */
  33448. dispose(): void;
  33449. }
  33450. }
  33451. declare module "babylonjs/Audio/analyser" {
  33452. import { Scene } from "babylonjs/scene";
  33453. /**
  33454. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33456. */
  33457. export class Analyser {
  33458. /**
  33459. * Gets or sets the smoothing
  33460. * @ignorenaming
  33461. */
  33462. SMOOTHING: number;
  33463. /**
  33464. * Gets or sets the FFT table size
  33465. * @ignorenaming
  33466. */
  33467. FFT_SIZE: number;
  33468. /**
  33469. * Gets or sets the bar graph amplitude
  33470. * @ignorenaming
  33471. */
  33472. BARGRAPHAMPLITUDE: number;
  33473. /**
  33474. * Gets or sets the position of the debug canvas
  33475. * @ignorenaming
  33476. */
  33477. DEBUGCANVASPOS: {
  33478. x: number;
  33479. y: number;
  33480. };
  33481. /**
  33482. * Gets or sets the debug canvas size
  33483. * @ignorenaming
  33484. */
  33485. DEBUGCANVASSIZE: {
  33486. width: number;
  33487. height: number;
  33488. };
  33489. private _byteFreqs;
  33490. private _byteTime;
  33491. private _floatFreqs;
  33492. private _webAudioAnalyser;
  33493. private _debugCanvas;
  33494. private _debugCanvasContext;
  33495. private _scene;
  33496. private _registerFunc;
  33497. private _audioEngine;
  33498. /**
  33499. * Creates a new analyser
  33500. * @param scene defines hosting scene
  33501. */
  33502. constructor(scene: Scene);
  33503. /**
  33504. * Get the number of data values you will have to play with for the visualization
  33505. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33506. * @returns a number
  33507. */
  33508. getFrequencyBinCount(): number;
  33509. /**
  33510. * Gets the current frequency data as a byte array
  33511. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33512. * @returns a Uint8Array
  33513. */
  33514. getByteFrequencyData(): Uint8Array;
  33515. /**
  33516. * Gets the current waveform as a byte array
  33517. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33518. * @returns a Uint8Array
  33519. */
  33520. getByteTimeDomainData(): Uint8Array;
  33521. /**
  33522. * Gets the current frequency data as a float array
  33523. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33524. * @returns a Float32Array
  33525. */
  33526. getFloatFrequencyData(): Float32Array;
  33527. /**
  33528. * Renders the debug canvas
  33529. */
  33530. drawDebugCanvas(): void;
  33531. /**
  33532. * Stops rendering the debug canvas and removes it
  33533. */
  33534. stopDebugCanvas(): void;
  33535. /**
  33536. * Connects two audio nodes
  33537. * @param inputAudioNode defines first node to connect
  33538. * @param outputAudioNode defines second node to connect
  33539. */
  33540. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33541. /**
  33542. * Releases all associated resources
  33543. */
  33544. dispose(): void;
  33545. }
  33546. }
  33547. declare module "babylonjs/Audio/audioEngine" {
  33548. import { IDisposable } from "babylonjs/scene";
  33549. import { Analyser } from "babylonjs/Audio/analyser";
  33550. import { Nullable } from "babylonjs/types";
  33551. import { Observable } from "babylonjs/Misc/observable";
  33552. /**
  33553. * This represents an audio engine and it is responsible
  33554. * to play, synchronize and analyse sounds throughout the application.
  33555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33556. */
  33557. export interface IAudioEngine extends IDisposable {
  33558. /**
  33559. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33560. */
  33561. readonly canUseWebAudio: boolean;
  33562. /**
  33563. * Gets the current AudioContext if available.
  33564. */
  33565. readonly audioContext: Nullable<AudioContext>;
  33566. /**
  33567. * The master gain node defines the global audio volume of your audio engine.
  33568. */
  33569. readonly masterGain: GainNode;
  33570. /**
  33571. * Gets whether or not mp3 are supported by your browser.
  33572. */
  33573. readonly isMP3supported: boolean;
  33574. /**
  33575. * Gets whether or not ogg are supported by your browser.
  33576. */
  33577. readonly isOGGsupported: boolean;
  33578. /**
  33579. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33580. * @ignoreNaming
  33581. */
  33582. WarnedWebAudioUnsupported: boolean;
  33583. /**
  33584. * Defines if the audio engine relies on a custom unlocked button.
  33585. * In this case, the embedded button will not be displayed.
  33586. */
  33587. useCustomUnlockedButton: boolean;
  33588. /**
  33589. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33590. */
  33591. readonly unlocked: boolean;
  33592. /**
  33593. * Event raised when audio has been unlocked on the browser.
  33594. */
  33595. onAudioUnlockedObservable: Observable<AudioEngine>;
  33596. /**
  33597. * Event raised when audio has been locked on the browser.
  33598. */
  33599. onAudioLockedObservable: Observable<AudioEngine>;
  33600. /**
  33601. * Flags the audio engine in Locked state.
  33602. * This happens due to new browser policies preventing audio to autoplay.
  33603. */
  33604. lock(): void;
  33605. /**
  33606. * Unlocks the audio engine once a user action has been done on the dom.
  33607. * This is helpful to resume play once browser policies have been satisfied.
  33608. */
  33609. unlock(): void;
  33610. }
  33611. /**
  33612. * This represents the default audio engine used in babylon.
  33613. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33615. */
  33616. export class AudioEngine implements IAudioEngine {
  33617. private _audioContext;
  33618. private _audioContextInitialized;
  33619. private _muteButton;
  33620. private _hostElement;
  33621. /**
  33622. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33623. */
  33624. canUseWebAudio: boolean;
  33625. /**
  33626. * The master gain node defines the global audio volume of your audio engine.
  33627. */
  33628. masterGain: GainNode;
  33629. /**
  33630. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33631. * @ignoreNaming
  33632. */
  33633. WarnedWebAudioUnsupported: boolean;
  33634. /**
  33635. * Gets whether or not mp3 are supported by your browser.
  33636. */
  33637. isMP3supported: boolean;
  33638. /**
  33639. * Gets whether or not ogg are supported by your browser.
  33640. */
  33641. isOGGsupported: boolean;
  33642. /**
  33643. * Gets whether audio has been unlocked on the device.
  33644. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33645. * a user interaction has happened.
  33646. */
  33647. unlocked: boolean;
  33648. /**
  33649. * Defines if the audio engine relies on a custom unlocked button.
  33650. * In this case, the embedded button will not be displayed.
  33651. */
  33652. useCustomUnlockedButton: boolean;
  33653. /**
  33654. * Event raised when audio has been unlocked on the browser.
  33655. */
  33656. onAudioUnlockedObservable: Observable<AudioEngine>;
  33657. /**
  33658. * Event raised when audio has been locked on the browser.
  33659. */
  33660. onAudioLockedObservable: Observable<AudioEngine>;
  33661. /**
  33662. * Gets the current AudioContext if available.
  33663. */
  33664. get audioContext(): Nullable<AudioContext>;
  33665. private _connectedAnalyser;
  33666. /**
  33667. * Instantiates a new audio engine.
  33668. *
  33669. * There should be only one per page as some browsers restrict the number
  33670. * of audio contexts you can create.
  33671. * @param hostElement defines the host element where to display the mute icon if necessary
  33672. */
  33673. constructor(hostElement?: Nullable<HTMLElement>);
  33674. /**
  33675. * Flags the audio engine in Locked state.
  33676. * This happens due to new browser policies preventing audio to autoplay.
  33677. */
  33678. lock(): void;
  33679. /**
  33680. * Unlocks the audio engine once a user action has been done on the dom.
  33681. * This is helpful to resume play once browser policies have been satisfied.
  33682. */
  33683. unlock(): void;
  33684. private _resumeAudioContext;
  33685. private _initializeAudioContext;
  33686. private _tryToRun;
  33687. private _triggerRunningState;
  33688. private _triggerSuspendedState;
  33689. private _displayMuteButton;
  33690. private _moveButtonToTopLeft;
  33691. private _onResize;
  33692. private _hideMuteButton;
  33693. /**
  33694. * Destroy and release the resources associated with the audio ccontext.
  33695. */
  33696. dispose(): void;
  33697. /**
  33698. * Gets the global volume sets on the master gain.
  33699. * @returns the global volume if set or -1 otherwise
  33700. */
  33701. getGlobalVolume(): number;
  33702. /**
  33703. * Sets the global volume of your experience (sets on the master gain).
  33704. * @param newVolume Defines the new global volume of the application
  33705. */
  33706. setGlobalVolume(newVolume: number): void;
  33707. /**
  33708. * Connect the audio engine to an audio analyser allowing some amazing
  33709. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33711. * @param analyser The analyser to connect to the engine
  33712. */
  33713. connectToAnalyser(analyser: Analyser): void;
  33714. }
  33715. }
  33716. declare module "babylonjs/Loading/loadingScreen" {
  33717. /**
  33718. * Interface used to present a loading screen while loading a scene
  33719. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33720. */
  33721. export interface ILoadingScreen {
  33722. /**
  33723. * Function called to display the loading screen
  33724. */
  33725. displayLoadingUI: () => void;
  33726. /**
  33727. * Function called to hide the loading screen
  33728. */
  33729. hideLoadingUI: () => void;
  33730. /**
  33731. * Gets or sets the color to use for the background
  33732. */
  33733. loadingUIBackgroundColor: string;
  33734. /**
  33735. * Gets or sets the text to display while loading
  33736. */
  33737. loadingUIText: string;
  33738. }
  33739. /**
  33740. * Class used for the default loading screen
  33741. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33742. */
  33743. export class DefaultLoadingScreen implements ILoadingScreen {
  33744. private _renderingCanvas;
  33745. private _loadingText;
  33746. private _loadingDivBackgroundColor;
  33747. private _loadingDiv;
  33748. private _loadingTextDiv;
  33749. /** Gets or sets the logo url to use for the default loading screen */
  33750. static DefaultLogoUrl: string;
  33751. /** Gets or sets the spinner url to use for the default loading screen */
  33752. static DefaultSpinnerUrl: string;
  33753. /**
  33754. * Creates a new default loading screen
  33755. * @param _renderingCanvas defines the canvas used to render the scene
  33756. * @param _loadingText defines the default text to display
  33757. * @param _loadingDivBackgroundColor defines the default background color
  33758. */
  33759. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33760. /**
  33761. * Function called to display the loading screen
  33762. */
  33763. displayLoadingUI(): void;
  33764. /**
  33765. * Function called to hide the loading screen
  33766. */
  33767. hideLoadingUI(): void;
  33768. /**
  33769. * Gets or sets the text to display while loading
  33770. */
  33771. set loadingUIText(text: string);
  33772. get loadingUIText(): string;
  33773. /**
  33774. * Gets or sets the color to use for the background
  33775. */
  33776. get loadingUIBackgroundColor(): string;
  33777. set loadingUIBackgroundColor(color: string);
  33778. private _resizeLoadingUI;
  33779. }
  33780. }
  33781. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33782. /**
  33783. * Interface for any object that can request an animation frame
  33784. */
  33785. export interface ICustomAnimationFrameRequester {
  33786. /**
  33787. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33788. */
  33789. renderFunction?: Function;
  33790. /**
  33791. * Called to request the next frame to render to
  33792. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33793. */
  33794. requestAnimationFrame: Function;
  33795. /**
  33796. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33797. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33798. */
  33799. requestID?: number;
  33800. }
  33801. }
  33802. declare module "babylonjs/Misc/performanceMonitor" {
  33803. /**
  33804. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33805. */
  33806. export class PerformanceMonitor {
  33807. private _enabled;
  33808. private _rollingFrameTime;
  33809. private _lastFrameTimeMs;
  33810. /**
  33811. * constructor
  33812. * @param frameSampleSize The number of samples required to saturate the sliding window
  33813. */
  33814. constructor(frameSampleSize?: number);
  33815. /**
  33816. * Samples current frame
  33817. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33818. */
  33819. sampleFrame(timeMs?: number): void;
  33820. /**
  33821. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33822. */
  33823. get averageFrameTime(): number;
  33824. /**
  33825. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33826. */
  33827. get averageFrameTimeVariance(): number;
  33828. /**
  33829. * Returns the frame time of the most recent frame
  33830. */
  33831. get instantaneousFrameTime(): number;
  33832. /**
  33833. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33834. */
  33835. get averageFPS(): number;
  33836. /**
  33837. * Returns the average framerate in frames per second using the most recent frame time
  33838. */
  33839. get instantaneousFPS(): number;
  33840. /**
  33841. * Returns true if enough samples have been taken to completely fill the sliding window
  33842. */
  33843. get isSaturated(): boolean;
  33844. /**
  33845. * Enables contributions to the sliding window sample set
  33846. */
  33847. enable(): void;
  33848. /**
  33849. * Disables contributions to the sliding window sample set
  33850. * Samples will not be interpolated over the disabled period
  33851. */
  33852. disable(): void;
  33853. /**
  33854. * Returns true if sampling is enabled
  33855. */
  33856. get isEnabled(): boolean;
  33857. /**
  33858. * Resets performance monitor
  33859. */
  33860. reset(): void;
  33861. }
  33862. /**
  33863. * RollingAverage
  33864. *
  33865. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33866. */
  33867. export class RollingAverage {
  33868. /**
  33869. * Current average
  33870. */
  33871. average: number;
  33872. /**
  33873. * Current variance
  33874. */
  33875. variance: number;
  33876. protected _samples: Array<number>;
  33877. protected _sampleCount: number;
  33878. protected _pos: number;
  33879. protected _m2: number;
  33880. /**
  33881. * constructor
  33882. * @param length The number of samples required to saturate the sliding window
  33883. */
  33884. constructor(length: number);
  33885. /**
  33886. * Adds a sample to the sample set
  33887. * @param v The sample value
  33888. */
  33889. add(v: number): void;
  33890. /**
  33891. * Returns previously added values or null if outside of history or outside the sliding window domain
  33892. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33893. * @return Value previously recorded with add() or null if outside of range
  33894. */
  33895. history(i: number): number;
  33896. /**
  33897. * Returns true if enough samples have been taken to completely fill the sliding window
  33898. * @return true if sample-set saturated
  33899. */
  33900. isSaturated(): boolean;
  33901. /**
  33902. * Resets the rolling average (equivalent to 0 samples taken so far)
  33903. */
  33904. reset(): void;
  33905. /**
  33906. * Wraps a value around the sample range boundaries
  33907. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33908. * @return Wrapped position in sample range
  33909. */
  33910. protected _wrapPosition(i: number): number;
  33911. }
  33912. }
  33913. declare module "babylonjs/Misc/perfCounter" {
  33914. /**
  33915. * This class is used to track a performance counter which is number based.
  33916. * The user has access to many properties which give statistics of different nature.
  33917. *
  33918. * The implementer can track two kinds of Performance Counter: time and count.
  33919. * 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.
  33920. * 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.
  33921. */
  33922. export class PerfCounter {
  33923. /**
  33924. * Gets or sets a global boolean to turn on and off all the counters
  33925. */
  33926. static Enabled: boolean;
  33927. /**
  33928. * Returns the smallest value ever
  33929. */
  33930. get min(): number;
  33931. /**
  33932. * Returns the biggest value ever
  33933. */
  33934. get max(): number;
  33935. /**
  33936. * Returns the average value since the performance counter is running
  33937. */
  33938. get average(): number;
  33939. /**
  33940. * Returns the average value of the last second the counter was monitored
  33941. */
  33942. get lastSecAverage(): number;
  33943. /**
  33944. * Returns the current value
  33945. */
  33946. get current(): number;
  33947. /**
  33948. * Gets the accumulated total
  33949. */
  33950. get total(): number;
  33951. /**
  33952. * Gets the total value count
  33953. */
  33954. get count(): number;
  33955. /**
  33956. * Creates a new counter
  33957. */
  33958. constructor();
  33959. /**
  33960. * Call this method to start monitoring a new frame.
  33961. * 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.
  33962. */
  33963. fetchNewFrame(): void;
  33964. /**
  33965. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33966. * @param newCount the count value to add to the monitored count
  33967. * @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.
  33968. */
  33969. addCount(newCount: number, fetchResult: boolean): void;
  33970. /**
  33971. * Start monitoring this performance counter
  33972. */
  33973. beginMonitoring(): void;
  33974. /**
  33975. * Compute the time lapsed since the previous beginMonitoring() call.
  33976. * @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
  33977. */
  33978. endMonitoring(newFrame?: boolean): void;
  33979. private _fetchResult;
  33980. private _startMonitoringTime;
  33981. private _min;
  33982. private _max;
  33983. private _average;
  33984. private _current;
  33985. private _totalValueCount;
  33986. private _totalAccumulated;
  33987. private _lastSecAverage;
  33988. private _lastSecAccumulated;
  33989. private _lastSecTime;
  33990. private _lastSecValueCount;
  33991. }
  33992. }
  33993. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33994. module "babylonjs/Engines/thinEngine" {
  33995. interface ThinEngine {
  33996. /**
  33997. * Sets alpha constants used by some alpha blending modes
  33998. * @param r defines the red component
  33999. * @param g defines the green component
  34000. * @param b defines the blue component
  34001. * @param a defines the alpha component
  34002. */
  34003. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34004. /**
  34005. * Sets the current alpha mode
  34006. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34007. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34008. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34009. */
  34010. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34011. /**
  34012. * Gets the current alpha mode
  34013. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34014. * @returns the current alpha mode
  34015. */
  34016. getAlphaMode(): number;
  34017. /**
  34018. * Sets the current alpha equation
  34019. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34020. */
  34021. setAlphaEquation(equation: number): void;
  34022. /**
  34023. * Gets the current alpha equation.
  34024. * @returns the current alpha equation
  34025. */
  34026. getAlphaEquation(): number;
  34027. }
  34028. }
  34029. }
  34030. declare module "babylonjs/Engines/engine" {
  34031. import { Observable } from "babylonjs/Misc/observable";
  34032. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34033. import { Scene } from "babylonjs/scene";
  34034. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34035. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34036. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34037. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34038. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34039. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34040. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34041. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34042. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34043. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34044. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34045. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34046. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34047. import "babylonjs/Engines/Extensions/engine.alpha";
  34048. import { Material } from "babylonjs/Materials/material";
  34049. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34050. /**
  34051. * Defines the interface used by display changed events
  34052. */
  34053. export interface IDisplayChangedEventArgs {
  34054. /** Gets the vrDisplay object (if any) */
  34055. vrDisplay: Nullable<any>;
  34056. /** Gets a boolean indicating if webVR is supported */
  34057. vrSupported: boolean;
  34058. }
  34059. /**
  34060. * Defines the interface used by objects containing a viewport (like a camera)
  34061. */
  34062. interface IViewportOwnerLike {
  34063. /**
  34064. * Gets or sets the viewport
  34065. */
  34066. viewport: IViewportLike;
  34067. }
  34068. /**
  34069. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34070. */
  34071. export class Engine extends ThinEngine {
  34072. /** Defines that alpha blending is disabled */
  34073. static readonly ALPHA_DISABLE: number;
  34074. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34075. static readonly ALPHA_ADD: number;
  34076. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34077. static readonly ALPHA_COMBINE: number;
  34078. /** Defines that alpha blending to DEST - SRC * DEST */
  34079. static readonly ALPHA_SUBTRACT: number;
  34080. /** Defines that alpha blending to SRC * DEST */
  34081. static readonly ALPHA_MULTIPLY: number;
  34082. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34083. static readonly ALPHA_MAXIMIZED: number;
  34084. /** Defines that alpha blending to SRC + DEST */
  34085. static readonly ALPHA_ONEONE: number;
  34086. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34087. static readonly ALPHA_PREMULTIPLIED: number;
  34088. /**
  34089. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34090. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34091. */
  34092. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34093. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34094. static readonly ALPHA_INTERPOLATE: number;
  34095. /**
  34096. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34097. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34098. */
  34099. static readonly ALPHA_SCREENMODE: number;
  34100. /** Defines that the ressource is not delayed*/
  34101. static readonly DELAYLOADSTATE_NONE: number;
  34102. /** Defines that the ressource was successfully delay loaded */
  34103. static readonly DELAYLOADSTATE_LOADED: number;
  34104. /** Defines that the ressource is currently delay loading */
  34105. static readonly DELAYLOADSTATE_LOADING: number;
  34106. /** Defines that the ressource is delayed and has not started loading */
  34107. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34108. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34109. static readonly NEVER: number;
  34110. /** 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 */
  34111. static readonly ALWAYS: number;
  34112. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34113. static readonly LESS: number;
  34114. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34115. static readonly EQUAL: number;
  34116. /** 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 */
  34117. static readonly LEQUAL: number;
  34118. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34119. static readonly GREATER: number;
  34120. /** 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 */
  34121. static readonly GEQUAL: number;
  34122. /** 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 */
  34123. static readonly NOTEQUAL: number;
  34124. /** Passed to stencilOperation to specify that stencil value must be kept */
  34125. static readonly KEEP: number;
  34126. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34127. static readonly REPLACE: number;
  34128. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34129. static readonly INCR: number;
  34130. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34131. static readonly DECR: number;
  34132. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34133. static readonly INVERT: number;
  34134. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34135. static readonly INCR_WRAP: number;
  34136. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34137. static readonly DECR_WRAP: number;
  34138. /** Texture is not repeating outside of 0..1 UVs */
  34139. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34140. /** Texture is repeating outside of 0..1 UVs */
  34141. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34142. /** Texture is repeating and mirrored */
  34143. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34144. /** ALPHA */
  34145. static readonly TEXTUREFORMAT_ALPHA: number;
  34146. /** LUMINANCE */
  34147. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34148. /** LUMINANCE_ALPHA */
  34149. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34150. /** RGB */
  34151. static readonly TEXTUREFORMAT_RGB: number;
  34152. /** RGBA */
  34153. static readonly TEXTUREFORMAT_RGBA: number;
  34154. /** RED */
  34155. static readonly TEXTUREFORMAT_RED: number;
  34156. /** RED (2nd reference) */
  34157. static readonly TEXTUREFORMAT_R: number;
  34158. /** RG */
  34159. static readonly TEXTUREFORMAT_RG: number;
  34160. /** RED_INTEGER */
  34161. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34162. /** RED_INTEGER (2nd reference) */
  34163. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34164. /** RG_INTEGER */
  34165. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34166. /** RGB_INTEGER */
  34167. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34168. /** RGBA_INTEGER */
  34169. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34170. /** UNSIGNED_BYTE */
  34171. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34172. /** UNSIGNED_BYTE (2nd reference) */
  34173. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34174. /** FLOAT */
  34175. static readonly TEXTURETYPE_FLOAT: number;
  34176. /** HALF_FLOAT */
  34177. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34178. /** BYTE */
  34179. static readonly TEXTURETYPE_BYTE: number;
  34180. /** SHORT */
  34181. static readonly TEXTURETYPE_SHORT: number;
  34182. /** UNSIGNED_SHORT */
  34183. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34184. /** INT */
  34185. static readonly TEXTURETYPE_INT: number;
  34186. /** UNSIGNED_INT */
  34187. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34188. /** UNSIGNED_SHORT_4_4_4_4 */
  34189. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34190. /** UNSIGNED_SHORT_5_5_5_1 */
  34191. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34192. /** UNSIGNED_SHORT_5_6_5 */
  34193. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34194. /** UNSIGNED_INT_2_10_10_10_REV */
  34195. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34196. /** UNSIGNED_INT_24_8 */
  34197. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34198. /** UNSIGNED_INT_10F_11F_11F_REV */
  34199. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34200. /** UNSIGNED_INT_5_9_9_9_REV */
  34201. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34202. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34203. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34204. /** nearest is mag = nearest and min = nearest and mip = linear */
  34205. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34206. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34207. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34208. /** Trilinear is mag = linear and min = linear and mip = linear */
  34209. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34210. /** nearest is mag = nearest and min = nearest and mip = linear */
  34211. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34212. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34213. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34214. /** Trilinear is mag = linear and min = linear and mip = linear */
  34215. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34216. /** mag = nearest and min = nearest and mip = nearest */
  34217. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34218. /** mag = nearest and min = linear and mip = nearest */
  34219. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34220. /** mag = nearest and min = linear and mip = linear */
  34221. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34222. /** mag = nearest and min = linear and mip = none */
  34223. static readonly TEXTURE_NEAREST_LINEAR: number;
  34224. /** mag = nearest and min = nearest and mip = none */
  34225. static readonly TEXTURE_NEAREST_NEAREST: number;
  34226. /** mag = linear and min = nearest and mip = nearest */
  34227. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34228. /** mag = linear and min = nearest and mip = linear */
  34229. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34230. /** mag = linear and min = linear and mip = none */
  34231. static readonly TEXTURE_LINEAR_LINEAR: number;
  34232. /** mag = linear and min = nearest and mip = none */
  34233. static readonly TEXTURE_LINEAR_NEAREST: number;
  34234. /** Explicit coordinates mode */
  34235. static readonly TEXTURE_EXPLICIT_MODE: number;
  34236. /** Spherical coordinates mode */
  34237. static readonly TEXTURE_SPHERICAL_MODE: number;
  34238. /** Planar coordinates mode */
  34239. static readonly TEXTURE_PLANAR_MODE: number;
  34240. /** Cubic coordinates mode */
  34241. static readonly TEXTURE_CUBIC_MODE: number;
  34242. /** Projection coordinates mode */
  34243. static readonly TEXTURE_PROJECTION_MODE: number;
  34244. /** Skybox coordinates mode */
  34245. static readonly TEXTURE_SKYBOX_MODE: number;
  34246. /** Inverse Cubic coordinates mode */
  34247. static readonly TEXTURE_INVCUBIC_MODE: number;
  34248. /** Equirectangular coordinates mode */
  34249. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34250. /** Equirectangular Fixed coordinates mode */
  34251. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34252. /** Equirectangular Fixed Mirrored coordinates mode */
  34253. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34254. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34255. static readonly SCALEMODE_FLOOR: number;
  34256. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34257. static readonly SCALEMODE_NEAREST: number;
  34258. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34259. static readonly SCALEMODE_CEILING: number;
  34260. /**
  34261. * Returns the current npm package of the sdk
  34262. */
  34263. static get NpmPackage(): string;
  34264. /**
  34265. * Returns the current version of the framework
  34266. */
  34267. static get Version(): string;
  34268. /** Gets the list of created engines */
  34269. static get Instances(): Engine[];
  34270. /**
  34271. * Gets the latest created engine
  34272. */
  34273. static get LastCreatedEngine(): Nullable<Engine>;
  34274. /**
  34275. * Gets the latest created scene
  34276. */
  34277. static get LastCreatedScene(): Nullable<Scene>;
  34278. /**
  34279. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34280. * @param flag defines which part of the materials must be marked as dirty
  34281. * @param predicate defines a predicate used to filter which materials should be affected
  34282. */
  34283. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34284. /**
  34285. * Method called to create the default loading screen.
  34286. * This can be overriden in your own app.
  34287. * @param canvas The rendering canvas element
  34288. * @returns The loading screen
  34289. */
  34290. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34291. /**
  34292. * Method called to create the default rescale post process on each engine.
  34293. */
  34294. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34295. /**
  34296. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34297. **/
  34298. enableOfflineSupport: boolean;
  34299. /**
  34300. * 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)
  34301. **/
  34302. disableManifestCheck: boolean;
  34303. /**
  34304. * Gets the list of created scenes
  34305. */
  34306. scenes: Scene[];
  34307. /**
  34308. * Event raised when a new scene is created
  34309. */
  34310. onNewSceneAddedObservable: Observable<Scene>;
  34311. /**
  34312. * Gets the list of created postprocesses
  34313. */
  34314. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34315. /**
  34316. * Gets a boolean indicating if the pointer is currently locked
  34317. */
  34318. isPointerLock: boolean;
  34319. /**
  34320. * Observable event triggered each time the rendering canvas is resized
  34321. */
  34322. onResizeObservable: Observable<Engine>;
  34323. /**
  34324. * Observable event triggered each time the canvas loses focus
  34325. */
  34326. onCanvasBlurObservable: Observable<Engine>;
  34327. /**
  34328. * Observable event triggered each time the canvas gains focus
  34329. */
  34330. onCanvasFocusObservable: Observable<Engine>;
  34331. /**
  34332. * Observable event triggered each time the canvas receives pointerout event
  34333. */
  34334. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34335. /**
  34336. * Observable raised when the engine begins a new frame
  34337. */
  34338. onBeginFrameObservable: Observable<Engine>;
  34339. /**
  34340. * If set, will be used to request the next animation frame for the render loop
  34341. */
  34342. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34343. /**
  34344. * Observable raised when the engine ends the current frame
  34345. */
  34346. onEndFrameObservable: Observable<Engine>;
  34347. /**
  34348. * Observable raised when the engine is about to compile a shader
  34349. */
  34350. onBeforeShaderCompilationObservable: Observable<Engine>;
  34351. /**
  34352. * Observable raised when the engine has jsut compiled a shader
  34353. */
  34354. onAfterShaderCompilationObservable: Observable<Engine>;
  34355. /**
  34356. * Gets the audio engine
  34357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34358. * @ignorenaming
  34359. */
  34360. static audioEngine: IAudioEngine;
  34361. /**
  34362. * Default AudioEngine factory responsible of creating the Audio Engine.
  34363. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34364. */
  34365. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34366. /**
  34367. * Default offline support factory responsible of creating a tool used to store data locally.
  34368. * By default, this will create a Database object if the workload has been embedded.
  34369. */
  34370. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34371. private _loadingScreen;
  34372. private _pointerLockRequested;
  34373. private _dummyFramebuffer;
  34374. private _rescalePostProcess;
  34375. private _deterministicLockstep;
  34376. private _lockstepMaxSteps;
  34377. private _timeStep;
  34378. protected get _supportsHardwareTextureRescaling(): boolean;
  34379. private _fps;
  34380. private _deltaTime;
  34381. /** @hidden */
  34382. _drawCalls: PerfCounter;
  34383. /** 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 */
  34384. canvasTabIndex: number;
  34385. /**
  34386. * Turn this value on if you want to pause FPS computation when in background
  34387. */
  34388. disablePerformanceMonitorInBackground: boolean;
  34389. private _performanceMonitor;
  34390. /**
  34391. * Gets the performance monitor attached to this engine
  34392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34393. */
  34394. get performanceMonitor(): PerformanceMonitor;
  34395. private _onFocus;
  34396. private _onBlur;
  34397. private _onCanvasPointerOut;
  34398. private _onCanvasBlur;
  34399. private _onCanvasFocus;
  34400. private _onFullscreenChange;
  34401. private _onPointerLockChange;
  34402. /**
  34403. * Gets the HTML element used to attach event listeners
  34404. * @returns a HTML element
  34405. */
  34406. getInputElement(): Nullable<HTMLElement>;
  34407. /**
  34408. * Creates a new engine
  34409. * @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
  34410. * @param antialias defines enable antialiasing (default: false)
  34411. * @param options defines further options to be sent to the getContext() function
  34412. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34413. */
  34414. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34415. /**
  34416. * Gets current aspect ratio
  34417. * @param viewportOwner defines the camera to use to get the aspect ratio
  34418. * @param useScreen defines if screen size must be used (or the current render target if any)
  34419. * @returns a number defining the aspect ratio
  34420. */
  34421. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34422. /**
  34423. * Gets current screen aspect ratio
  34424. * @returns a number defining the aspect ratio
  34425. */
  34426. getScreenAspectRatio(): number;
  34427. /**
  34428. * Gets the client rect of the HTML canvas attached with the current webGL context
  34429. * @returns a client rectanglee
  34430. */
  34431. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34432. /**
  34433. * Gets the client rect of the HTML element used for events
  34434. * @returns a client rectanglee
  34435. */
  34436. getInputElementClientRect(): Nullable<ClientRect>;
  34437. /**
  34438. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34439. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34440. * @returns true if engine is in deterministic lock step mode
  34441. */
  34442. isDeterministicLockStep(): boolean;
  34443. /**
  34444. * Gets the max steps when engine is running in deterministic lock step
  34445. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34446. * @returns the max steps
  34447. */
  34448. getLockstepMaxSteps(): number;
  34449. /**
  34450. * Returns the time in ms between steps when using deterministic lock step.
  34451. * @returns time step in (ms)
  34452. */
  34453. getTimeStep(): number;
  34454. /**
  34455. * Force the mipmap generation for the given render target texture
  34456. * @param texture defines the render target texture to use
  34457. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34458. */
  34459. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34460. /** States */
  34461. /**
  34462. * Set various states to the webGL context
  34463. * @param culling defines backface culling state
  34464. * @param zOffset defines the value to apply to zOffset (0 by default)
  34465. * @param force defines if states must be applied even if cache is up to date
  34466. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34467. */
  34468. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34469. /**
  34470. * Set the z offset to apply to current rendering
  34471. * @param value defines the offset to apply
  34472. */
  34473. setZOffset(value: number): void;
  34474. /**
  34475. * Gets the current value of the zOffset
  34476. * @returns the current zOffset state
  34477. */
  34478. getZOffset(): number;
  34479. /**
  34480. * Enable or disable depth buffering
  34481. * @param enable defines the state to set
  34482. */
  34483. setDepthBuffer(enable: boolean): void;
  34484. /**
  34485. * Gets a boolean indicating if depth writing is enabled
  34486. * @returns the current depth writing state
  34487. */
  34488. getDepthWrite(): boolean;
  34489. /**
  34490. * Enable or disable depth writing
  34491. * @param enable defines the state to set
  34492. */
  34493. setDepthWrite(enable: boolean): void;
  34494. /**
  34495. * Gets a boolean indicating if stencil buffer is enabled
  34496. * @returns the current stencil buffer state
  34497. */
  34498. getStencilBuffer(): boolean;
  34499. /**
  34500. * Enable or disable the stencil buffer
  34501. * @param enable defines if the stencil buffer must be enabled or disabled
  34502. */
  34503. setStencilBuffer(enable: boolean): void;
  34504. /**
  34505. * Gets the current stencil mask
  34506. * @returns a number defining the new stencil mask to use
  34507. */
  34508. getStencilMask(): number;
  34509. /**
  34510. * Sets the current stencil mask
  34511. * @param mask defines the new stencil mask to use
  34512. */
  34513. setStencilMask(mask: number): void;
  34514. /**
  34515. * Gets the current stencil function
  34516. * @returns a number defining the stencil function to use
  34517. */
  34518. getStencilFunction(): number;
  34519. /**
  34520. * Gets the current stencil reference value
  34521. * @returns a number defining the stencil reference value to use
  34522. */
  34523. getStencilFunctionReference(): number;
  34524. /**
  34525. * Gets the current stencil mask
  34526. * @returns a number defining the stencil mask to use
  34527. */
  34528. getStencilFunctionMask(): number;
  34529. /**
  34530. * Sets the current stencil function
  34531. * @param stencilFunc defines the new stencil function to use
  34532. */
  34533. setStencilFunction(stencilFunc: number): void;
  34534. /**
  34535. * Sets the current stencil reference
  34536. * @param reference defines the new stencil reference to use
  34537. */
  34538. setStencilFunctionReference(reference: number): void;
  34539. /**
  34540. * Sets the current stencil mask
  34541. * @param mask defines the new stencil mask to use
  34542. */
  34543. setStencilFunctionMask(mask: number): void;
  34544. /**
  34545. * Gets the current stencil operation when stencil fails
  34546. * @returns a number defining stencil operation to use when stencil fails
  34547. */
  34548. getStencilOperationFail(): number;
  34549. /**
  34550. * Gets the current stencil operation when depth fails
  34551. * @returns a number defining stencil operation to use when depth fails
  34552. */
  34553. getStencilOperationDepthFail(): number;
  34554. /**
  34555. * Gets the current stencil operation when stencil passes
  34556. * @returns a number defining stencil operation to use when stencil passes
  34557. */
  34558. getStencilOperationPass(): number;
  34559. /**
  34560. * Sets the stencil operation to use when stencil fails
  34561. * @param operation defines the stencil operation to use when stencil fails
  34562. */
  34563. setStencilOperationFail(operation: number): void;
  34564. /**
  34565. * Sets the stencil operation to use when depth fails
  34566. * @param operation defines the stencil operation to use when depth fails
  34567. */
  34568. setStencilOperationDepthFail(operation: number): void;
  34569. /**
  34570. * Sets the stencil operation to use when stencil passes
  34571. * @param operation defines the stencil operation to use when stencil passes
  34572. */
  34573. setStencilOperationPass(operation: number): void;
  34574. /**
  34575. * Sets a boolean indicating if the dithering state is enabled or disabled
  34576. * @param value defines the dithering state
  34577. */
  34578. setDitheringState(value: boolean): void;
  34579. /**
  34580. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34581. * @param value defines the rasterizer state
  34582. */
  34583. setRasterizerState(value: boolean): void;
  34584. /**
  34585. * Gets the current depth function
  34586. * @returns a number defining the depth function
  34587. */
  34588. getDepthFunction(): Nullable<number>;
  34589. /**
  34590. * Sets the current depth function
  34591. * @param depthFunc defines the function to use
  34592. */
  34593. setDepthFunction(depthFunc: number): void;
  34594. /**
  34595. * Sets the current depth function to GREATER
  34596. */
  34597. setDepthFunctionToGreater(): void;
  34598. /**
  34599. * Sets the current depth function to GEQUAL
  34600. */
  34601. setDepthFunctionToGreaterOrEqual(): void;
  34602. /**
  34603. * Sets the current depth function to LESS
  34604. */
  34605. setDepthFunctionToLess(): void;
  34606. /**
  34607. * Sets the current depth function to LEQUAL
  34608. */
  34609. setDepthFunctionToLessOrEqual(): void;
  34610. private _cachedStencilBuffer;
  34611. private _cachedStencilFunction;
  34612. private _cachedStencilMask;
  34613. private _cachedStencilOperationPass;
  34614. private _cachedStencilOperationFail;
  34615. private _cachedStencilOperationDepthFail;
  34616. private _cachedStencilReference;
  34617. /**
  34618. * Caches the the state of the stencil buffer
  34619. */
  34620. cacheStencilState(): void;
  34621. /**
  34622. * Restores the state of the stencil buffer
  34623. */
  34624. restoreStencilState(): void;
  34625. /**
  34626. * Directly set the WebGL Viewport
  34627. * @param x defines the x coordinate of the viewport (in screen space)
  34628. * @param y defines the y coordinate of the viewport (in screen space)
  34629. * @param width defines the width of the viewport (in screen space)
  34630. * @param height defines the height of the viewport (in screen space)
  34631. * @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
  34632. */
  34633. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34634. /**
  34635. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34636. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34637. * @param y defines the y-coordinate of the corner of the clear rectangle
  34638. * @param width defines the width of the clear rectangle
  34639. * @param height defines the height of the clear rectangle
  34640. * @param clearColor defines the clear color
  34641. */
  34642. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34643. /**
  34644. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34645. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34646. * @param y defines the y-coordinate of the corner of the clear rectangle
  34647. * @param width defines the width of the clear rectangle
  34648. * @param height defines the height of the clear rectangle
  34649. */
  34650. enableScissor(x: number, y: number, width: number, height: number): void;
  34651. /**
  34652. * Disable previously set scissor test rectangle
  34653. */
  34654. disableScissor(): void;
  34655. protected _reportDrawCall(): void;
  34656. /**
  34657. * Initializes a webVR display and starts listening to display change events
  34658. * The onVRDisplayChangedObservable will be notified upon these changes
  34659. * @returns The onVRDisplayChangedObservable
  34660. */
  34661. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34662. /** @hidden */
  34663. _prepareVRComponent(): void;
  34664. /** @hidden */
  34665. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34666. /** @hidden */
  34667. _submitVRFrame(): void;
  34668. /**
  34669. * Call this function to leave webVR mode
  34670. * Will do nothing if webVR is not supported or if there is no webVR device
  34671. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34672. */
  34673. disableVR(): void;
  34674. /**
  34675. * Gets a boolean indicating that the system is in VR mode and is presenting
  34676. * @returns true if VR mode is engaged
  34677. */
  34678. isVRPresenting(): boolean;
  34679. /** @hidden */
  34680. _requestVRFrame(): void;
  34681. /** @hidden */
  34682. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34683. /**
  34684. * Gets the source code of the vertex shader associated with a specific webGL program
  34685. * @param program defines the program to use
  34686. * @returns a string containing the source code of the vertex shader associated with the program
  34687. */
  34688. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34689. /**
  34690. * Gets the source code of the fragment shader associated with a specific webGL program
  34691. * @param program defines the program to use
  34692. * @returns a string containing the source code of the fragment shader associated with the program
  34693. */
  34694. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34695. /**
  34696. * Sets a depth stencil texture from a render target to the according uniform.
  34697. * @param channel The texture channel
  34698. * @param uniform The uniform to set
  34699. * @param texture The render target texture containing the depth stencil texture to apply
  34700. */
  34701. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34702. /**
  34703. * Sets a texture to the webGL context from a postprocess
  34704. * @param channel defines the channel to use
  34705. * @param postProcess defines the source postprocess
  34706. */
  34707. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34708. /**
  34709. * Binds the output of the passed in post process to the texture channel specified
  34710. * @param channel The channel the texture should be bound to
  34711. * @param postProcess The post process which's output should be bound
  34712. */
  34713. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34714. /** @hidden */
  34715. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34716. protected _rebuildBuffers(): void;
  34717. /** @hidden */
  34718. _renderFrame(): void;
  34719. _renderLoop(): void;
  34720. /** @hidden */
  34721. _renderViews(): boolean;
  34722. /**
  34723. * Toggle full screen mode
  34724. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34725. */
  34726. switchFullscreen(requestPointerLock: boolean): void;
  34727. /**
  34728. * Enters full screen mode
  34729. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34730. */
  34731. enterFullscreen(requestPointerLock: boolean): void;
  34732. /**
  34733. * Exits full screen mode
  34734. */
  34735. exitFullscreen(): void;
  34736. /**
  34737. * Enters Pointerlock mode
  34738. */
  34739. enterPointerlock(): void;
  34740. /**
  34741. * Exits Pointerlock mode
  34742. */
  34743. exitPointerlock(): void;
  34744. /**
  34745. * Begin a new frame
  34746. */
  34747. beginFrame(): void;
  34748. /**
  34749. * Enf the current frame
  34750. */
  34751. endFrame(): void;
  34752. resize(): void;
  34753. /**
  34754. * Force a specific size of the canvas
  34755. * @param width defines the new canvas' width
  34756. * @param height defines the new canvas' height
  34757. */
  34758. setSize(width: number, height: number): void;
  34759. /**
  34760. * Updates a dynamic vertex buffer.
  34761. * @param vertexBuffer the vertex buffer to update
  34762. * @param data the data used to update the vertex buffer
  34763. * @param byteOffset the byte offset of the data
  34764. * @param byteLength the byte length of the data
  34765. */
  34766. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34767. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34768. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34769. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34770. _releaseTexture(texture: InternalTexture): void;
  34771. /**
  34772. * @hidden
  34773. * Rescales a texture
  34774. * @param source input texutre
  34775. * @param destination destination texture
  34776. * @param scene scene to use to render the resize
  34777. * @param internalFormat format to use when resizing
  34778. * @param onComplete callback to be called when resize has completed
  34779. */
  34780. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34781. /**
  34782. * Gets the current framerate
  34783. * @returns a number representing the framerate
  34784. */
  34785. getFps(): number;
  34786. /**
  34787. * Gets the time spent between current and previous frame
  34788. * @returns a number representing the delta time in ms
  34789. */
  34790. getDeltaTime(): number;
  34791. private _measureFps;
  34792. /** @hidden */
  34793. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34794. /**
  34795. * Update a dynamic index buffer
  34796. * @param indexBuffer defines the target index buffer
  34797. * @param indices defines the data to update
  34798. * @param offset defines the offset in the target index buffer where update should start
  34799. */
  34800. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34801. /**
  34802. * Updates the sample count of a render target texture
  34803. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34804. * @param texture defines the texture to update
  34805. * @param samples defines the sample count to set
  34806. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34807. */
  34808. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34809. /**
  34810. * Updates a depth texture Comparison Mode and Function.
  34811. * If the comparison Function is equal to 0, the mode will be set to none.
  34812. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34813. * @param texture The texture to set the comparison function for
  34814. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34815. */
  34816. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34817. /**
  34818. * Creates a webGL buffer to use with instanciation
  34819. * @param capacity defines the size of the buffer
  34820. * @returns the webGL buffer
  34821. */
  34822. createInstancesBuffer(capacity: number): DataBuffer;
  34823. /**
  34824. * Delete a webGL buffer used with instanciation
  34825. * @param buffer defines the webGL buffer to delete
  34826. */
  34827. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34828. private _clientWaitAsync;
  34829. /** @hidden */
  34830. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34831. /** @hidden */
  34832. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34833. dispose(): void;
  34834. private _disableTouchAction;
  34835. /**
  34836. * Display the loading screen
  34837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34838. */
  34839. displayLoadingUI(): void;
  34840. /**
  34841. * Hide the loading screen
  34842. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34843. */
  34844. hideLoadingUI(): void;
  34845. /**
  34846. * Gets the current loading screen object
  34847. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34848. */
  34849. get loadingScreen(): ILoadingScreen;
  34850. /**
  34851. * Sets the current loading screen object
  34852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34853. */
  34854. set loadingScreen(loadingScreen: ILoadingScreen);
  34855. /**
  34856. * Sets the current loading screen text
  34857. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34858. */
  34859. set loadingUIText(text: string);
  34860. /**
  34861. * Sets the current loading screen background color
  34862. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34863. */
  34864. set loadingUIBackgroundColor(color: string);
  34865. /** Pointerlock and fullscreen */
  34866. /**
  34867. * Ask the browser to promote the current element to pointerlock mode
  34868. * @param element defines the DOM element to promote
  34869. */
  34870. static _RequestPointerlock(element: HTMLElement): void;
  34871. /**
  34872. * Asks the browser to exit pointerlock mode
  34873. */
  34874. static _ExitPointerlock(): void;
  34875. /**
  34876. * Ask the browser to promote the current element to fullscreen rendering mode
  34877. * @param element defines the DOM element to promote
  34878. */
  34879. static _RequestFullscreen(element: HTMLElement): void;
  34880. /**
  34881. * Asks the browser to exit fullscreen mode
  34882. */
  34883. static _ExitFullscreen(): void;
  34884. }
  34885. }
  34886. declare module "babylonjs/Engines/engineStore" {
  34887. import { Nullable } from "babylonjs/types";
  34888. import { Engine } from "babylonjs/Engines/engine";
  34889. import { Scene } from "babylonjs/scene";
  34890. /**
  34891. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34892. * during the life time of the application.
  34893. */
  34894. export class EngineStore {
  34895. /** Gets the list of created engines */
  34896. static Instances: import("babylonjs/Engines/engine").Engine[];
  34897. /** @hidden */
  34898. static _LastCreatedScene: Nullable<Scene>;
  34899. /**
  34900. * Gets the latest created engine
  34901. */
  34902. static get LastCreatedEngine(): Nullable<Engine>;
  34903. /**
  34904. * Gets the latest created scene
  34905. */
  34906. static get LastCreatedScene(): Nullable<Scene>;
  34907. /**
  34908. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34909. * @ignorenaming
  34910. */
  34911. static UseFallbackTexture: boolean;
  34912. /**
  34913. * Texture content used if a texture cannot loaded
  34914. * @ignorenaming
  34915. */
  34916. static FallbackTexture: string;
  34917. }
  34918. }
  34919. declare module "babylonjs/Misc/promise" {
  34920. /**
  34921. * Helper class that provides a small promise polyfill
  34922. */
  34923. export class PromisePolyfill {
  34924. /**
  34925. * Static function used to check if the polyfill is required
  34926. * If this is the case then the function will inject the polyfill to window.Promise
  34927. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34928. */
  34929. static Apply(force?: boolean): void;
  34930. }
  34931. }
  34932. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34933. /**
  34934. * Interface for screenshot methods with describe argument called `size` as object with options
  34935. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34936. */
  34937. export interface IScreenshotSize {
  34938. /**
  34939. * number in pixels for canvas height
  34940. */
  34941. height?: number;
  34942. /**
  34943. * multiplier allowing render at a higher or lower resolution
  34944. * If value is defined then height and width will be ignored and taken from camera
  34945. */
  34946. precision?: number;
  34947. /**
  34948. * number in pixels for canvas width
  34949. */
  34950. width?: number;
  34951. }
  34952. }
  34953. declare module "babylonjs/Misc/tools" {
  34954. import { Nullable, float } from "babylonjs/types";
  34955. import { DomManagement } from "babylonjs/Misc/domManagement";
  34956. import { WebRequest } from "babylonjs/Misc/webRequest";
  34957. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34958. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34959. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34960. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34961. import { Camera } from "babylonjs/Cameras/camera";
  34962. import { Engine } from "babylonjs/Engines/engine";
  34963. interface IColor4Like {
  34964. r: float;
  34965. g: float;
  34966. b: float;
  34967. a: float;
  34968. }
  34969. /**
  34970. * Class containing a set of static utilities functions
  34971. */
  34972. export class Tools {
  34973. /**
  34974. * Gets or sets the base URL to use to load assets
  34975. */
  34976. static get BaseUrl(): string;
  34977. static set BaseUrl(value: string);
  34978. /**
  34979. * Enable/Disable Custom HTTP Request Headers globally.
  34980. * default = false
  34981. * @see CustomRequestHeaders
  34982. */
  34983. static UseCustomRequestHeaders: boolean;
  34984. /**
  34985. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34986. * i.e. when loading files, where the server/service expects an Authorization header
  34987. */
  34988. static CustomRequestHeaders: {
  34989. [key: string]: string;
  34990. };
  34991. /**
  34992. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34993. */
  34994. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34995. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34996. /**
  34997. * Default behaviour for cors in the application.
  34998. * It can be a string if the expected behavior is identical in the entire app.
  34999. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35000. */
  35001. static CorsBehavior: string | ((url: string | string[]) => string);
  35002. /**
  35003. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35004. * @ignorenaming
  35005. */
  35006. static get UseFallbackTexture(): boolean;
  35007. static set UseFallbackTexture(value: boolean);
  35008. /**
  35009. * Use this object to register external classes like custom textures or material
  35010. * to allow the laoders to instantiate them
  35011. */
  35012. static get RegisteredExternalClasses(): {
  35013. [key: string]: Object;
  35014. };
  35015. static set RegisteredExternalClasses(classes: {
  35016. [key: string]: Object;
  35017. });
  35018. /**
  35019. * Texture content used if a texture cannot loaded
  35020. * @ignorenaming
  35021. */
  35022. static get fallbackTexture(): string;
  35023. static set fallbackTexture(value: string);
  35024. /**
  35025. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35026. * @param u defines the coordinate on X axis
  35027. * @param v defines the coordinate on Y axis
  35028. * @param width defines the width of the source data
  35029. * @param height defines the height of the source data
  35030. * @param pixels defines the source byte array
  35031. * @param color defines the output color
  35032. */
  35033. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35034. /**
  35035. * Interpolates between a and b via alpha
  35036. * @param a The lower value (returned when alpha = 0)
  35037. * @param b The upper value (returned when alpha = 1)
  35038. * @param alpha The interpolation-factor
  35039. * @return The mixed value
  35040. */
  35041. static Mix(a: number, b: number, alpha: number): number;
  35042. /**
  35043. * Tries to instantiate a new object from a given class name
  35044. * @param className defines the class name to instantiate
  35045. * @returns the new object or null if the system was not able to do the instantiation
  35046. */
  35047. static Instantiate(className: string): any;
  35048. /**
  35049. * Provides a slice function that will work even on IE
  35050. * @param data defines the array to slice
  35051. * @param start defines the start of the data (optional)
  35052. * @param end defines the end of the data (optional)
  35053. * @returns the new sliced array
  35054. */
  35055. static Slice<T>(data: T, start?: number, end?: number): T;
  35056. /**
  35057. * Polyfill for setImmediate
  35058. * @param action defines the action to execute after the current execution block
  35059. */
  35060. static SetImmediate(action: () => void): void;
  35061. /**
  35062. * Function indicating if a number is an exponent of 2
  35063. * @param value defines the value to test
  35064. * @returns true if the value is an exponent of 2
  35065. */
  35066. static IsExponentOfTwo(value: number): boolean;
  35067. private static _tmpFloatArray;
  35068. /**
  35069. * Returns the nearest 32-bit single precision float representation of a Number
  35070. * @param value A Number. If the parameter is of a different type, it will get converted
  35071. * to a number or to NaN if it cannot be converted
  35072. * @returns number
  35073. */
  35074. static FloatRound(value: number): number;
  35075. /**
  35076. * Extracts the filename from a path
  35077. * @param path defines the path to use
  35078. * @returns the filename
  35079. */
  35080. static GetFilename(path: string): string;
  35081. /**
  35082. * Extracts the "folder" part of a path (everything before the filename).
  35083. * @param uri The URI to extract the info from
  35084. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35085. * @returns The "folder" part of the path
  35086. */
  35087. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35088. /**
  35089. * Extracts text content from a DOM element hierarchy
  35090. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35091. */
  35092. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35093. /**
  35094. * Convert an angle in radians to degrees
  35095. * @param angle defines the angle to convert
  35096. * @returns the angle in degrees
  35097. */
  35098. static ToDegrees(angle: number): number;
  35099. /**
  35100. * Convert an angle in degrees to radians
  35101. * @param angle defines the angle to convert
  35102. * @returns the angle in radians
  35103. */
  35104. static ToRadians(angle: number): number;
  35105. /**
  35106. * Returns an array if obj is not an array
  35107. * @param obj defines the object to evaluate as an array
  35108. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35109. * @returns either obj directly if obj is an array or a new array containing obj
  35110. */
  35111. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35112. /**
  35113. * Gets the pointer prefix to use
  35114. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35115. */
  35116. static GetPointerPrefix(): string;
  35117. /**
  35118. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35119. * @param url define the url we are trying
  35120. * @param element define the dom element where to configure the cors policy
  35121. */
  35122. static SetCorsBehavior(url: string | string[], element: {
  35123. crossOrigin: string | null;
  35124. }): void;
  35125. /**
  35126. * Removes unwanted characters from an url
  35127. * @param url defines the url to clean
  35128. * @returns the cleaned url
  35129. */
  35130. static CleanUrl(url: string): string;
  35131. /**
  35132. * Gets or sets a function used to pre-process url before using them to load assets
  35133. */
  35134. static get PreprocessUrl(): (url: string) => string;
  35135. static set PreprocessUrl(processor: (url: string) => string);
  35136. /**
  35137. * Loads an image as an HTMLImageElement.
  35138. * @param input url string, ArrayBuffer, or Blob to load
  35139. * @param onLoad callback called when the image successfully loads
  35140. * @param onError callback called when the image fails to load
  35141. * @param offlineProvider offline provider for caching
  35142. * @param mimeType optional mime type
  35143. * @returns the HTMLImageElement of the loaded image
  35144. */
  35145. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35146. /**
  35147. * Loads a file from a url
  35148. * @param url url string, ArrayBuffer, or Blob to load
  35149. * @param onSuccess callback called when the file successfully loads
  35150. * @param onProgress callback called while file is loading (if the server supports this mode)
  35151. * @param offlineProvider defines the offline provider for caching
  35152. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35153. * @param onError callback called when the file fails to load
  35154. * @returns a file request object
  35155. */
  35156. 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;
  35157. /**
  35158. * Loads a file from a url
  35159. * @param url the file url to load
  35160. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35161. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35162. */
  35163. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35164. /**
  35165. * Load a script (identified by an url). When the url returns, the
  35166. * content of this file is added into a new script element, attached to the DOM (body element)
  35167. * @param scriptUrl defines the url of the script to laod
  35168. * @param onSuccess defines the callback called when the script is loaded
  35169. * @param onError defines the callback to call if an error occurs
  35170. * @param scriptId defines the id of the script element
  35171. */
  35172. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35173. /**
  35174. * Load an asynchronous script (identified by an url). When the url returns, the
  35175. * content of this file is added into a new script element, attached to the DOM (body element)
  35176. * @param scriptUrl defines the url of the script to laod
  35177. * @param scriptId defines the id of the script element
  35178. * @returns a promise request object
  35179. */
  35180. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35181. /**
  35182. * Loads a file from a blob
  35183. * @param fileToLoad defines the blob to use
  35184. * @param callback defines the callback to call when data is loaded
  35185. * @param progressCallback defines the callback to call during loading process
  35186. * @returns a file request object
  35187. */
  35188. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35189. /**
  35190. * Reads a file from a File object
  35191. * @param file defines the file to load
  35192. * @param onSuccess defines the callback to call when data is loaded
  35193. * @param onProgress defines the callback to call during loading process
  35194. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35195. * @param onError defines the callback to call when an error occurs
  35196. * @returns a file request object
  35197. */
  35198. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35199. /**
  35200. * Creates a data url from a given string content
  35201. * @param content defines the content to convert
  35202. * @returns the new data url link
  35203. */
  35204. static FileAsURL(content: string): string;
  35205. /**
  35206. * Format the given number to a specific decimal format
  35207. * @param value defines the number to format
  35208. * @param decimals defines the number of decimals to use
  35209. * @returns the formatted string
  35210. */
  35211. static Format(value: number, decimals?: number): string;
  35212. /**
  35213. * Tries to copy an object by duplicating every property
  35214. * @param source defines the source object
  35215. * @param destination defines the target object
  35216. * @param doNotCopyList defines a list of properties to avoid
  35217. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35218. */
  35219. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35220. /**
  35221. * Gets a boolean indicating if the given object has no own property
  35222. * @param obj defines the object to test
  35223. * @returns true if object has no own property
  35224. */
  35225. static IsEmpty(obj: any): boolean;
  35226. /**
  35227. * Function used to register events at window level
  35228. * @param windowElement defines the Window object to use
  35229. * @param events defines the events to register
  35230. */
  35231. static RegisterTopRootEvents(windowElement: Window, events: {
  35232. name: string;
  35233. handler: Nullable<(e: FocusEvent) => any>;
  35234. }[]): void;
  35235. /**
  35236. * Function used to unregister events from window level
  35237. * @param windowElement defines the Window object to use
  35238. * @param events defines the events to unregister
  35239. */
  35240. static UnregisterTopRootEvents(windowElement: Window, events: {
  35241. name: string;
  35242. handler: Nullable<(e: FocusEvent) => any>;
  35243. }[]): void;
  35244. /**
  35245. * @ignore
  35246. */
  35247. static _ScreenshotCanvas: HTMLCanvasElement;
  35248. /**
  35249. * Dumps the current bound framebuffer
  35250. * @param width defines the rendering width
  35251. * @param height defines the rendering height
  35252. * @param engine defines the hosting engine
  35253. * @param successCallback defines the callback triggered once the data are available
  35254. * @param mimeType defines the mime type of the result
  35255. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35256. */
  35257. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35258. /**
  35259. * Converts the canvas data to blob.
  35260. * This acts as a polyfill for browsers not supporting the to blob function.
  35261. * @param canvas Defines the canvas to extract the data from
  35262. * @param successCallback Defines the callback triggered once the data are available
  35263. * @param mimeType Defines the mime type of the result
  35264. */
  35265. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35266. /**
  35267. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35268. * @param successCallback defines the callback triggered once the data are available
  35269. * @param mimeType defines the mime type of the result
  35270. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35271. */
  35272. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35273. /**
  35274. * Downloads a blob in the browser
  35275. * @param blob defines the blob to download
  35276. * @param fileName defines the name of the downloaded file
  35277. */
  35278. static Download(blob: Blob, fileName: string): void;
  35279. /**
  35280. * Captures a screenshot of the current rendering
  35281. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35282. * @param engine defines the rendering engine
  35283. * @param camera defines the source camera
  35284. * @param size This parameter can be set to a single number or to an object with the
  35285. * following (optional) properties: precision, width, height. If a single number is passed,
  35286. * it will be used for both width and height. If an object is passed, the screenshot size
  35287. * will be derived from the parameters. The precision property is a multiplier allowing
  35288. * rendering at a higher or lower resolution
  35289. * @param successCallback defines the callback receives a single parameter which contains the
  35290. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35291. * src parameter of an <img> to display it
  35292. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35293. * Check your browser for supported MIME types
  35294. */
  35295. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35296. /**
  35297. * Captures a screenshot of the current rendering
  35298. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35299. * @param engine defines the rendering engine
  35300. * @param camera defines the source camera
  35301. * @param size This parameter can be set to a single number or to an object with the
  35302. * following (optional) properties: precision, width, height. If a single number is passed,
  35303. * it will be used for both width and height. If an object is passed, the screenshot size
  35304. * will be derived from the parameters. The precision property is a multiplier allowing
  35305. * rendering at a higher or lower resolution
  35306. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35307. * Check your browser for supported MIME types
  35308. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35309. * to the src parameter of an <img> to display it
  35310. */
  35311. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35312. /**
  35313. * Generates an image screenshot from the specified camera.
  35314. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35315. * @param engine The engine to use for rendering
  35316. * @param camera The camera to use for rendering
  35317. * @param size This parameter can be set to a single number or to an object with the
  35318. * following (optional) properties: precision, width, height. If a single number is passed,
  35319. * it will be used for both width and height. If an object is passed, the screenshot size
  35320. * will be derived from the parameters. The precision property is a multiplier allowing
  35321. * rendering at a higher or lower resolution
  35322. * @param successCallback The callback receives a single parameter which contains the
  35323. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35324. * src parameter of an <img> to display it
  35325. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35326. * Check your browser for supported MIME types
  35327. * @param samples Texture samples (default: 1)
  35328. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35329. * @param fileName A name for for the downloaded file.
  35330. */
  35331. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35332. /**
  35333. * Generates an image screenshot from the specified camera.
  35334. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35335. * @param engine The engine to use for rendering
  35336. * @param camera The camera to use for rendering
  35337. * @param size This parameter can be set to a single number or to an object with the
  35338. * following (optional) properties: precision, width, height. If a single number is passed,
  35339. * it will be used for both width and height. If an object is passed, the screenshot size
  35340. * will be derived from the parameters. The precision property is a multiplier allowing
  35341. * rendering at a higher or lower resolution
  35342. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35343. * Check your browser for supported MIME types
  35344. * @param samples Texture samples (default: 1)
  35345. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35346. * @param fileName A name for for the downloaded file.
  35347. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35348. * to the src parameter of an <img> to display it
  35349. */
  35350. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35351. /**
  35352. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35353. * Be aware Math.random() could cause collisions, but:
  35354. * "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"
  35355. * @returns a pseudo random id
  35356. */
  35357. static RandomId(): string;
  35358. /**
  35359. * Test if the given uri is a base64 string
  35360. * @param uri The uri to test
  35361. * @return True if the uri is a base64 string or false otherwise
  35362. */
  35363. static IsBase64(uri: string): boolean;
  35364. /**
  35365. * Decode the given base64 uri.
  35366. * @param uri The uri to decode
  35367. * @return The decoded base64 data.
  35368. */
  35369. static DecodeBase64(uri: string): ArrayBuffer;
  35370. /**
  35371. * Gets the absolute url.
  35372. * @param url the input url
  35373. * @return the absolute url
  35374. */
  35375. static GetAbsoluteUrl(url: string): string;
  35376. /**
  35377. * No log
  35378. */
  35379. static readonly NoneLogLevel: number;
  35380. /**
  35381. * Only message logs
  35382. */
  35383. static readonly MessageLogLevel: number;
  35384. /**
  35385. * Only warning logs
  35386. */
  35387. static readonly WarningLogLevel: number;
  35388. /**
  35389. * Only error logs
  35390. */
  35391. static readonly ErrorLogLevel: number;
  35392. /**
  35393. * All logs
  35394. */
  35395. static readonly AllLogLevel: number;
  35396. /**
  35397. * Gets a value indicating the number of loading errors
  35398. * @ignorenaming
  35399. */
  35400. static get errorsCount(): number;
  35401. /**
  35402. * Callback called when a new log is added
  35403. */
  35404. static OnNewCacheEntry: (entry: string) => void;
  35405. /**
  35406. * Log a message to the console
  35407. * @param message defines the message to log
  35408. */
  35409. static Log(message: string): void;
  35410. /**
  35411. * Write a warning message to the console
  35412. * @param message defines the message to log
  35413. */
  35414. static Warn(message: string): void;
  35415. /**
  35416. * Write an error message to the console
  35417. * @param message defines the message to log
  35418. */
  35419. static Error(message: string): void;
  35420. /**
  35421. * Gets current log cache (list of logs)
  35422. */
  35423. static get LogCache(): string;
  35424. /**
  35425. * Clears the log cache
  35426. */
  35427. static ClearLogCache(): void;
  35428. /**
  35429. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35430. */
  35431. static set LogLevels(level: number);
  35432. /**
  35433. * Checks if the window object exists
  35434. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35435. */
  35436. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35437. /**
  35438. * No performance log
  35439. */
  35440. static readonly PerformanceNoneLogLevel: number;
  35441. /**
  35442. * Use user marks to log performance
  35443. */
  35444. static readonly PerformanceUserMarkLogLevel: number;
  35445. /**
  35446. * Log performance to the console
  35447. */
  35448. static readonly PerformanceConsoleLogLevel: number;
  35449. private static _performance;
  35450. /**
  35451. * Sets the current performance log level
  35452. */
  35453. static set PerformanceLogLevel(level: number);
  35454. private static _StartPerformanceCounterDisabled;
  35455. private static _EndPerformanceCounterDisabled;
  35456. private static _StartUserMark;
  35457. private static _EndUserMark;
  35458. private static _StartPerformanceConsole;
  35459. private static _EndPerformanceConsole;
  35460. /**
  35461. * Starts a performance counter
  35462. */
  35463. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35464. /**
  35465. * Ends a specific performance coutner
  35466. */
  35467. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35468. /**
  35469. * Gets either window.performance.now() if supported or Date.now() else
  35470. */
  35471. static get Now(): number;
  35472. /**
  35473. * This method will return the name of the class used to create the instance of the given object.
  35474. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35475. * @param object the object to get the class name from
  35476. * @param isType defines if the object is actually a type
  35477. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35478. */
  35479. static GetClassName(object: any, isType?: boolean): string;
  35480. /**
  35481. * Gets the first element of an array satisfying a given predicate
  35482. * @param array defines the array to browse
  35483. * @param predicate defines the predicate to use
  35484. * @returns null if not found or the element
  35485. */
  35486. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35487. /**
  35488. * This method will return the name of the full name of the class, including its owning module (if any).
  35489. * 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).
  35490. * @param object the object to get the class name from
  35491. * @param isType defines if the object is actually a type
  35492. * @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.
  35493. * @ignorenaming
  35494. */
  35495. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35496. /**
  35497. * Returns a promise that resolves after the given amount of time.
  35498. * @param delay Number of milliseconds to delay
  35499. * @returns Promise that resolves after the given amount of time
  35500. */
  35501. static DelayAsync(delay: number): Promise<void>;
  35502. /**
  35503. * Utility function to detect if the current user agent is Safari
  35504. * @returns whether or not the current user agent is safari
  35505. */
  35506. static IsSafari(): boolean;
  35507. }
  35508. /**
  35509. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35510. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35511. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35512. * @param name The name of the class, case should be preserved
  35513. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35514. */
  35515. export function className(name: string, module?: string): (target: Object) => void;
  35516. /**
  35517. * An implementation of a loop for asynchronous functions.
  35518. */
  35519. export class AsyncLoop {
  35520. /**
  35521. * Defines the number of iterations for the loop
  35522. */
  35523. iterations: number;
  35524. /**
  35525. * Defines the current index of the loop.
  35526. */
  35527. index: number;
  35528. private _done;
  35529. private _fn;
  35530. private _successCallback;
  35531. /**
  35532. * Constructor.
  35533. * @param iterations the number of iterations.
  35534. * @param func the function to run each iteration
  35535. * @param successCallback the callback that will be called upon succesful execution
  35536. * @param offset starting offset.
  35537. */
  35538. constructor(
  35539. /**
  35540. * Defines the number of iterations for the loop
  35541. */
  35542. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35543. /**
  35544. * Execute the next iteration. Must be called after the last iteration was finished.
  35545. */
  35546. executeNext(): void;
  35547. /**
  35548. * Break the loop and run the success callback.
  35549. */
  35550. breakLoop(): void;
  35551. /**
  35552. * Create and run an async loop.
  35553. * @param iterations the number of iterations.
  35554. * @param fn the function to run each iteration
  35555. * @param successCallback the callback that will be called upon succesful execution
  35556. * @param offset starting offset.
  35557. * @returns the created async loop object
  35558. */
  35559. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35560. /**
  35561. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35562. * @param iterations total number of iterations
  35563. * @param syncedIterations number of synchronous iterations in each async iteration.
  35564. * @param fn the function to call each iteration.
  35565. * @param callback a success call back that will be called when iterating stops.
  35566. * @param breakFunction a break condition (optional)
  35567. * @param timeout timeout settings for the setTimeout function. default - 0.
  35568. * @returns the created async loop object
  35569. */
  35570. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35571. }
  35572. }
  35573. declare module "babylonjs/Misc/stringDictionary" {
  35574. import { Nullable } from "babylonjs/types";
  35575. /**
  35576. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35577. * The underlying implementation relies on an associative array to ensure the best performances.
  35578. * The value can be anything including 'null' but except 'undefined'
  35579. */
  35580. export class StringDictionary<T> {
  35581. /**
  35582. * This will clear this dictionary and copy the content from the 'source' one.
  35583. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35584. * @param source the dictionary to take the content from and copy to this dictionary
  35585. */
  35586. copyFrom(source: StringDictionary<T>): void;
  35587. /**
  35588. * Get a value based from its key
  35589. * @param key the given key to get the matching value from
  35590. * @return the value if found, otherwise undefined is returned
  35591. */
  35592. get(key: string): T | undefined;
  35593. /**
  35594. * Get a value from its key or add it if it doesn't exist.
  35595. * This method will ensure you that a given key/data will be present in the dictionary.
  35596. * @param key the given key to get the matching value from
  35597. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35598. * The factory will only be invoked if there's no data for the given key.
  35599. * @return the value corresponding to the key.
  35600. */
  35601. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35602. /**
  35603. * Get a value from its key if present in the dictionary otherwise add it
  35604. * @param key the key to get the value from
  35605. * @param val if there's no such key/value pair in the dictionary add it with this value
  35606. * @return the value corresponding to the key
  35607. */
  35608. getOrAdd(key: string, val: T): T;
  35609. /**
  35610. * Check if there's a given key in the dictionary
  35611. * @param key the key to check for
  35612. * @return true if the key is present, false otherwise
  35613. */
  35614. contains(key: string): boolean;
  35615. /**
  35616. * Add a new key and its corresponding value
  35617. * @param key the key to add
  35618. * @param value the value corresponding to the key
  35619. * @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
  35620. */
  35621. add(key: string, value: T): boolean;
  35622. /**
  35623. * Update a specific value associated to a key
  35624. * @param key defines the key to use
  35625. * @param value defines the value to store
  35626. * @returns true if the value was updated (or false if the key was not found)
  35627. */
  35628. set(key: string, value: T): boolean;
  35629. /**
  35630. * Get the element of the given key and remove it from the dictionary
  35631. * @param key defines the key to search
  35632. * @returns the value associated with the key or null if not found
  35633. */
  35634. getAndRemove(key: string): Nullable<T>;
  35635. /**
  35636. * Remove a key/value from the dictionary.
  35637. * @param key the key to remove
  35638. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35639. */
  35640. remove(key: string): boolean;
  35641. /**
  35642. * Clear the whole content of the dictionary
  35643. */
  35644. clear(): void;
  35645. /**
  35646. * Gets the current count
  35647. */
  35648. get count(): number;
  35649. /**
  35650. * Execute a callback on each key/val of the dictionary.
  35651. * Note that you can remove any element in this dictionary in the callback implementation
  35652. * @param callback the callback to execute on a given key/value pair
  35653. */
  35654. forEach(callback: (key: string, val: T) => void): void;
  35655. /**
  35656. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35657. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35658. * Note that you can remove any element in this dictionary in the callback implementation
  35659. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35660. * @returns the first item
  35661. */
  35662. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35663. private _count;
  35664. private _data;
  35665. }
  35666. }
  35667. declare module "babylonjs/Collisions/collisionCoordinator" {
  35668. import { Nullable } from "babylonjs/types";
  35669. import { Scene } from "babylonjs/scene";
  35670. import { Vector3 } from "babylonjs/Maths/math.vector";
  35671. import { Collider } from "babylonjs/Collisions/collider";
  35672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35673. /** @hidden */
  35674. export interface ICollisionCoordinator {
  35675. createCollider(): Collider;
  35676. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35677. init(scene: Scene): void;
  35678. }
  35679. /** @hidden */
  35680. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35681. private _scene;
  35682. private _scaledPosition;
  35683. private _scaledVelocity;
  35684. private _finalPosition;
  35685. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35686. createCollider(): Collider;
  35687. init(scene: Scene): void;
  35688. private _collideWithWorld;
  35689. }
  35690. }
  35691. declare module "babylonjs/Inputs/scene.inputManager" {
  35692. import { Nullable } from "babylonjs/types";
  35693. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35694. import { Vector2 } from "babylonjs/Maths/math.vector";
  35695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35696. import { Scene } from "babylonjs/scene";
  35697. /**
  35698. * Class used to manage all inputs for the scene.
  35699. */
  35700. export class InputManager {
  35701. /** The distance in pixel that you have to move to prevent some events */
  35702. static DragMovementThreshold: number;
  35703. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35704. static LongPressDelay: number;
  35705. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35706. static DoubleClickDelay: number;
  35707. /** If you need to check double click without raising a single click at first click, enable this flag */
  35708. static ExclusiveDoubleClickMode: boolean;
  35709. private _wheelEventName;
  35710. private _onPointerMove;
  35711. private _onPointerDown;
  35712. private _onPointerUp;
  35713. private _initClickEvent;
  35714. private _initActionManager;
  35715. private _delayedSimpleClick;
  35716. private _delayedSimpleClickTimeout;
  35717. private _previousDelayedSimpleClickTimeout;
  35718. private _meshPickProceed;
  35719. private _previousButtonPressed;
  35720. private _currentPickResult;
  35721. private _previousPickResult;
  35722. private _totalPointersPressed;
  35723. private _doubleClickOccured;
  35724. private _pointerOverMesh;
  35725. private _pickedDownMesh;
  35726. private _pickedUpMesh;
  35727. private _pointerX;
  35728. private _pointerY;
  35729. private _unTranslatedPointerX;
  35730. private _unTranslatedPointerY;
  35731. private _startingPointerPosition;
  35732. private _previousStartingPointerPosition;
  35733. private _startingPointerTime;
  35734. private _previousStartingPointerTime;
  35735. private _pointerCaptures;
  35736. private _onKeyDown;
  35737. private _onKeyUp;
  35738. private _onCanvasFocusObserver;
  35739. private _onCanvasBlurObserver;
  35740. private _scene;
  35741. /**
  35742. * Creates a new InputManager
  35743. * @param scene defines the hosting scene
  35744. */
  35745. constructor(scene: Scene);
  35746. /**
  35747. * Gets the mesh that is currently under the pointer
  35748. */
  35749. get meshUnderPointer(): Nullable<AbstractMesh>;
  35750. /**
  35751. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35752. */
  35753. get unTranslatedPointer(): Vector2;
  35754. /**
  35755. * Gets or sets the current on-screen X position of the pointer
  35756. */
  35757. get pointerX(): number;
  35758. set pointerX(value: number);
  35759. /**
  35760. * Gets or sets the current on-screen Y position of the pointer
  35761. */
  35762. get pointerY(): number;
  35763. set pointerY(value: number);
  35764. private _updatePointerPosition;
  35765. private _processPointerMove;
  35766. private _setRayOnPointerInfo;
  35767. private _checkPrePointerObservable;
  35768. /**
  35769. * Use this method to simulate a pointer move on a mesh
  35770. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35771. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35772. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35773. */
  35774. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35775. /**
  35776. * Use this method to simulate a pointer down 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. */
  35781. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35782. private _processPointerDown;
  35783. /** @hidden */
  35784. _isPointerSwiping(): boolean;
  35785. /**
  35786. * Use this method to simulate a pointer up on a mesh
  35787. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35788. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35789. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35790. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35791. */
  35792. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35793. private _processPointerUp;
  35794. /**
  35795. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35796. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35797. * @returns true if the pointer was captured
  35798. */
  35799. isPointerCaptured(pointerId?: number): boolean;
  35800. /**
  35801. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35802. * @param attachUp defines if you want to attach events to pointerup
  35803. * @param attachDown defines if you want to attach events to pointerdown
  35804. * @param attachMove defines if you want to attach events to pointermove
  35805. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35806. */
  35807. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35808. /**
  35809. * Detaches all event handlers
  35810. */
  35811. detachControl(): void;
  35812. /**
  35813. * Force the value of meshUnderPointer
  35814. * @param mesh defines the mesh to use
  35815. */
  35816. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35817. /**
  35818. * Gets the mesh under the pointer
  35819. * @returns a Mesh or null if no mesh is under the pointer
  35820. */
  35821. getPointerOverMesh(): Nullable<AbstractMesh>;
  35822. }
  35823. }
  35824. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35825. /**
  35826. * Helper class used to generate session unique ID
  35827. */
  35828. export class UniqueIdGenerator {
  35829. private static _UniqueIdCounter;
  35830. /**
  35831. * Gets an unique (relatively to the current scene) Id
  35832. */
  35833. static get UniqueId(): number;
  35834. }
  35835. }
  35836. declare module "babylonjs/Animations/animationGroup" {
  35837. import { Animatable } from "babylonjs/Animations/animatable";
  35838. import { Animation } from "babylonjs/Animations/animation";
  35839. import { Scene, IDisposable } from "babylonjs/scene";
  35840. import { Observable } from "babylonjs/Misc/observable";
  35841. import { Nullable } from "babylonjs/types";
  35842. import "babylonjs/Animations/animatable";
  35843. /**
  35844. * This class defines the direct association between an animation and a target
  35845. */
  35846. export class TargetedAnimation {
  35847. /**
  35848. * Animation to perform
  35849. */
  35850. animation: Animation;
  35851. /**
  35852. * Target to animate
  35853. */
  35854. target: any;
  35855. /**
  35856. * Serialize the object
  35857. * @returns the JSON object representing the current entity
  35858. */
  35859. serialize(): any;
  35860. }
  35861. /**
  35862. * Use this class to create coordinated animations on multiple targets
  35863. */
  35864. export class AnimationGroup implements IDisposable {
  35865. /** The name of the animation group */
  35866. name: string;
  35867. private _scene;
  35868. private _targetedAnimations;
  35869. private _animatables;
  35870. private _from;
  35871. private _to;
  35872. private _isStarted;
  35873. private _isPaused;
  35874. private _speedRatio;
  35875. private _loopAnimation;
  35876. /**
  35877. * Gets or sets the unique id of the node
  35878. */
  35879. uniqueId: number;
  35880. /**
  35881. * This observable will notify when one animation have ended
  35882. */
  35883. onAnimationEndObservable: Observable<TargetedAnimation>;
  35884. /**
  35885. * Observer raised when one animation loops
  35886. */
  35887. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35888. /**
  35889. * Observer raised when all animations have looped
  35890. */
  35891. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35892. /**
  35893. * This observable will notify when all animations have ended.
  35894. */
  35895. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35896. /**
  35897. * This observable will notify when all animations have paused.
  35898. */
  35899. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35900. /**
  35901. * This observable will notify when all animations are playing.
  35902. */
  35903. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35904. /**
  35905. * Gets the first frame
  35906. */
  35907. get from(): number;
  35908. /**
  35909. * Gets the last frame
  35910. */
  35911. get to(): number;
  35912. /**
  35913. * Define if the animations are started
  35914. */
  35915. get isStarted(): boolean;
  35916. /**
  35917. * Gets a value indicating that the current group is playing
  35918. */
  35919. get isPlaying(): boolean;
  35920. /**
  35921. * Gets or sets the speed ratio to use for all animations
  35922. */
  35923. get speedRatio(): number;
  35924. /**
  35925. * Gets or sets the speed ratio to use for all animations
  35926. */
  35927. set speedRatio(value: number);
  35928. /**
  35929. * Gets or sets if all animations should loop or not
  35930. */
  35931. get loopAnimation(): boolean;
  35932. set loopAnimation(value: boolean);
  35933. /**
  35934. * Gets the targeted animations for this animation group
  35935. */
  35936. get targetedAnimations(): Array<TargetedAnimation>;
  35937. /**
  35938. * returning the list of animatables controlled by this animation group.
  35939. */
  35940. get animatables(): Array<Animatable>;
  35941. /**
  35942. * Instantiates a new Animation Group.
  35943. * This helps managing several animations at once.
  35944. * @see http://doc.babylonjs.com/how_to/group
  35945. * @param name Defines the name of the group
  35946. * @param scene Defines the scene the group belongs to
  35947. */
  35948. constructor(
  35949. /** The name of the animation group */
  35950. name: string, scene?: Nullable<Scene>);
  35951. /**
  35952. * Add an animation (with its target) in the group
  35953. * @param animation defines the animation we want to add
  35954. * @param target defines the target of the animation
  35955. * @returns the TargetedAnimation object
  35956. */
  35957. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35958. /**
  35959. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35960. * It can add constant keys at begin or end
  35961. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35962. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35963. * @returns the animation group
  35964. */
  35965. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35966. private _animationLoopCount;
  35967. private _animationLoopFlags;
  35968. private _processLoop;
  35969. /**
  35970. * Start all animations on given targets
  35971. * @param loop defines if animations must loop
  35972. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35973. * @param from defines the from key (optional)
  35974. * @param to defines the to key (optional)
  35975. * @returns the current animation group
  35976. */
  35977. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35978. /**
  35979. * Pause all animations
  35980. * @returns the animation group
  35981. */
  35982. pause(): AnimationGroup;
  35983. /**
  35984. * Play all animations to initial state
  35985. * This function will start() the animations if they were not started or will restart() them if they were paused
  35986. * @param loop defines if animations must loop
  35987. * @returns the animation group
  35988. */
  35989. play(loop?: boolean): AnimationGroup;
  35990. /**
  35991. * Reset all animations to initial state
  35992. * @returns the animation group
  35993. */
  35994. reset(): AnimationGroup;
  35995. /**
  35996. * Restart animations from key 0
  35997. * @returns the animation group
  35998. */
  35999. restart(): AnimationGroup;
  36000. /**
  36001. * Stop all animations
  36002. * @returns the animation group
  36003. */
  36004. stop(): AnimationGroup;
  36005. /**
  36006. * Set animation weight for all animatables
  36007. * @param weight defines the weight to use
  36008. * @return the animationGroup
  36009. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36010. */
  36011. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36012. /**
  36013. * Synchronize and normalize all animatables with a source animatable
  36014. * @param root defines the root animatable to synchronize with
  36015. * @return the animationGroup
  36016. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36017. */
  36018. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36019. /**
  36020. * Goes to a specific frame in this animation group
  36021. * @param frame the frame number to go to
  36022. * @return the animationGroup
  36023. */
  36024. goToFrame(frame: number): AnimationGroup;
  36025. /**
  36026. * Dispose all associated resources
  36027. */
  36028. dispose(): void;
  36029. private _checkAnimationGroupEnded;
  36030. /**
  36031. * Clone the current animation group and returns a copy
  36032. * @param newName defines the name of the new group
  36033. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36034. * @returns the new aniamtion group
  36035. */
  36036. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36037. /**
  36038. * Serializes the animationGroup to an object
  36039. * @returns Serialized object
  36040. */
  36041. serialize(): any;
  36042. /**
  36043. * Returns a new AnimationGroup object parsed from the source provided.
  36044. * @param parsedAnimationGroup defines the source
  36045. * @param scene defines the scene that will receive the animationGroup
  36046. * @returns a new AnimationGroup
  36047. */
  36048. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36049. /**
  36050. * Returns the string "AnimationGroup"
  36051. * @returns "AnimationGroup"
  36052. */
  36053. getClassName(): string;
  36054. /**
  36055. * Creates a detailled string about the object
  36056. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36057. * @returns a string representing the object
  36058. */
  36059. toString(fullDetails?: boolean): string;
  36060. }
  36061. }
  36062. declare module "babylonjs/scene" {
  36063. import { Nullable } from "babylonjs/types";
  36064. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36065. import { Observable } from "babylonjs/Misc/observable";
  36066. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36067. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36068. import { Geometry } from "babylonjs/Meshes/geometry";
  36069. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36070. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36072. import { Mesh } from "babylonjs/Meshes/mesh";
  36073. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36074. import { Bone } from "babylonjs/Bones/bone";
  36075. import { Skeleton } from "babylonjs/Bones/skeleton";
  36076. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36077. import { Camera } from "babylonjs/Cameras/camera";
  36078. import { AbstractScene } from "babylonjs/abstractScene";
  36079. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36080. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36081. import { Material } from "babylonjs/Materials/material";
  36082. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36083. import { Effect } from "babylonjs/Materials/effect";
  36084. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36085. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36086. import { Light } from "babylonjs/Lights/light";
  36087. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36088. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36089. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36090. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36091. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36092. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36093. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36094. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36095. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36096. import { Engine } from "babylonjs/Engines/engine";
  36097. import { Node } from "babylonjs/node";
  36098. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36099. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36100. import { WebRequest } from "babylonjs/Misc/webRequest";
  36101. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36102. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36103. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36104. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36105. import { Plane } from "babylonjs/Maths/math.plane";
  36106. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36107. import { Ray } from "babylonjs/Culling/ray";
  36108. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36109. import { Animation } from "babylonjs/Animations/animation";
  36110. import { Animatable } from "babylonjs/Animations/animatable";
  36111. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36112. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36113. import { Collider } from "babylonjs/Collisions/collider";
  36114. /**
  36115. * Define an interface for all classes that will hold resources
  36116. */
  36117. export interface IDisposable {
  36118. /**
  36119. * Releases all held resources
  36120. */
  36121. dispose(): void;
  36122. }
  36123. /** Interface defining initialization parameters for Scene class */
  36124. export interface SceneOptions {
  36125. /**
  36126. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36127. * It will improve performance when the number of geometries becomes important.
  36128. */
  36129. useGeometryUniqueIdsMap?: boolean;
  36130. /**
  36131. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36132. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36133. */
  36134. useMaterialMeshMap?: boolean;
  36135. /**
  36136. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36137. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36138. */
  36139. useClonedMeshMap?: boolean;
  36140. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36141. virtual?: boolean;
  36142. }
  36143. /**
  36144. * Represents a scene to be rendered by the engine.
  36145. * @see http://doc.babylonjs.com/features/scene
  36146. */
  36147. export class Scene extends AbstractScene implements IAnimatable {
  36148. /** The fog is deactivated */
  36149. static readonly FOGMODE_NONE: number;
  36150. /** The fog density is following an exponential function */
  36151. static readonly FOGMODE_EXP: number;
  36152. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36153. static readonly FOGMODE_EXP2: number;
  36154. /** The fog density is following a linear function. */
  36155. static readonly FOGMODE_LINEAR: number;
  36156. /**
  36157. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36158. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36159. */
  36160. static MinDeltaTime: number;
  36161. /**
  36162. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36163. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36164. */
  36165. static MaxDeltaTime: number;
  36166. /**
  36167. * Factory used to create the default material.
  36168. * @param name The name of the material to create
  36169. * @param scene The scene to create the material for
  36170. * @returns The default material
  36171. */
  36172. static DefaultMaterialFactory(scene: Scene): Material;
  36173. /**
  36174. * Factory used to create the a collision coordinator.
  36175. * @returns The collision coordinator
  36176. */
  36177. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36178. /** @hidden */
  36179. _inputManager: InputManager;
  36180. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36181. cameraToUseForPointers: Nullable<Camera>;
  36182. /** @hidden */
  36183. readonly _isScene: boolean;
  36184. /** @hidden */
  36185. _blockEntityCollection: boolean;
  36186. /**
  36187. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36188. */
  36189. autoClear: boolean;
  36190. /**
  36191. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36192. */
  36193. autoClearDepthAndStencil: boolean;
  36194. /**
  36195. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36196. */
  36197. clearColor: Color4;
  36198. /**
  36199. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36200. */
  36201. ambientColor: Color3;
  36202. /**
  36203. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36204. * It should only be one of the following (if not the default embedded one):
  36205. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36206. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36207. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36208. * The material properties need to be setup according to the type of texture in use.
  36209. */
  36210. environmentBRDFTexture: BaseTexture;
  36211. /** @hidden */
  36212. protected _environmentTexture: Nullable<BaseTexture>;
  36213. /**
  36214. * Texture used in all pbr material as the reflection texture.
  36215. * As in the majority of the scene they are the same (exception for multi room and so on),
  36216. * this is easier to reference from here than from all the materials.
  36217. */
  36218. get environmentTexture(): Nullable<BaseTexture>;
  36219. /**
  36220. * Texture used in all pbr material as the reflection texture.
  36221. * As in the majority of the scene they are the same (exception for multi room and so on),
  36222. * this is easier to set here than in all the materials.
  36223. */
  36224. set environmentTexture(value: Nullable<BaseTexture>);
  36225. /** @hidden */
  36226. protected _environmentIntensity: number;
  36227. /**
  36228. * Intensity of the environment in all pbr material.
  36229. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36230. * As in the majority of the scene they are the same (exception for multi room and so on),
  36231. * this is easier to reference from here than from all the materials.
  36232. */
  36233. get environmentIntensity(): number;
  36234. /**
  36235. * Intensity of the environment in all pbr material.
  36236. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36237. * As in the majority of the scene they are the same (exception for multi room and so on),
  36238. * this is easier to set here than in all the materials.
  36239. */
  36240. set environmentIntensity(value: number);
  36241. /** @hidden */
  36242. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36243. /**
  36244. * Default image processing configuration used either in the rendering
  36245. * Forward main pass or through the imageProcessingPostProcess if present.
  36246. * As in the majority of the scene they are the same (exception for multi camera),
  36247. * this is easier to reference from here than from all the materials and post process.
  36248. *
  36249. * No setter as we it is a shared configuration, you can set the values instead.
  36250. */
  36251. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36252. private _forceWireframe;
  36253. /**
  36254. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36255. */
  36256. set forceWireframe(value: boolean);
  36257. get forceWireframe(): boolean;
  36258. private _skipFrustumClipping;
  36259. /**
  36260. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36261. */
  36262. set skipFrustumClipping(value: boolean);
  36263. get skipFrustumClipping(): boolean;
  36264. private _forcePointsCloud;
  36265. /**
  36266. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36267. */
  36268. set forcePointsCloud(value: boolean);
  36269. get forcePointsCloud(): boolean;
  36270. /**
  36271. * Gets or sets the active clipplane 1
  36272. */
  36273. clipPlane: Nullable<Plane>;
  36274. /**
  36275. * Gets or sets the active clipplane 2
  36276. */
  36277. clipPlane2: Nullable<Plane>;
  36278. /**
  36279. * Gets or sets the active clipplane 3
  36280. */
  36281. clipPlane3: Nullable<Plane>;
  36282. /**
  36283. * Gets or sets the active clipplane 4
  36284. */
  36285. clipPlane4: Nullable<Plane>;
  36286. /**
  36287. * Gets or sets the active clipplane 5
  36288. */
  36289. clipPlane5: Nullable<Plane>;
  36290. /**
  36291. * Gets or sets the active clipplane 6
  36292. */
  36293. clipPlane6: Nullable<Plane>;
  36294. /**
  36295. * Gets or sets a boolean indicating if animations are enabled
  36296. */
  36297. animationsEnabled: boolean;
  36298. private _animationPropertiesOverride;
  36299. /**
  36300. * Gets or sets the animation properties override
  36301. */
  36302. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36303. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36304. /**
  36305. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36306. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36307. */
  36308. useConstantAnimationDeltaTime: boolean;
  36309. /**
  36310. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36311. * Please note that it requires to run a ray cast through the scene on every frame
  36312. */
  36313. constantlyUpdateMeshUnderPointer: boolean;
  36314. /**
  36315. * Defines the HTML cursor to use when hovering over interactive elements
  36316. */
  36317. hoverCursor: string;
  36318. /**
  36319. * Defines the HTML default cursor to use (empty by default)
  36320. */
  36321. defaultCursor: string;
  36322. /**
  36323. * Defines whether cursors are handled by the scene.
  36324. */
  36325. doNotHandleCursors: boolean;
  36326. /**
  36327. * This is used to call preventDefault() on pointer down
  36328. * in order to block unwanted artifacts like system double clicks
  36329. */
  36330. preventDefaultOnPointerDown: boolean;
  36331. /**
  36332. * This is used to call preventDefault() on pointer up
  36333. * in order to block unwanted artifacts like system double clicks
  36334. */
  36335. preventDefaultOnPointerUp: boolean;
  36336. /**
  36337. * Gets or sets user defined metadata
  36338. */
  36339. metadata: any;
  36340. /**
  36341. * For internal use only. Please do not use.
  36342. */
  36343. reservedDataStore: any;
  36344. /**
  36345. * Gets the name of the plugin used to load this scene (null by default)
  36346. */
  36347. loadingPluginName: string;
  36348. /**
  36349. * Use this array to add regular expressions used to disable offline support for specific urls
  36350. */
  36351. disableOfflineSupportExceptionRules: RegExp[];
  36352. /**
  36353. * An event triggered when the scene is disposed.
  36354. */
  36355. onDisposeObservable: Observable<Scene>;
  36356. private _onDisposeObserver;
  36357. /** Sets a function to be executed when this scene is disposed. */
  36358. set onDispose(callback: () => void);
  36359. /**
  36360. * An event triggered before rendering the scene (right after animations and physics)
  36361. */
  36362. onBeforeRenderObservable: Observable<Scene>;
  36363. private _onBeforeRenderObserver;
  36364. /** Sets a function to be executed before rendering this scene */
  36365. set beforeRender(callback: Nullable<() => void>);
  36366. /**
  36367. * An event triggered after rendering the scene
  36368. */
  36369. onAfterRenderObservable: Observable<Scene>;
  36370. /**
  36371. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36372. */
  36373. onAfterRenderCameraObservable: Observable<Camera>;
  36374. private _onAfterRenderObserver;
  36375. /** Sets a function to be executed after rendering this scene */
  36376. set afterRender(callback: Nullable<() => void>);
  36377. /**
  36378. * An event triggered before animating the scene
  36379. */
  36380. onBeforeAnimationsObservable: Observable<Scene>;
  36381. /**
  36382. * An event triggered after animations processing
  36383. */
  36384. onAfterAnimationsObservable: Observable<Scene>;
  36385. /**
  36386. * An event triggered before draw calls are ready to be sent
  36387. */
  36388. onBeforeDrawPhaseObservable: Observable<Scene>;
  36389. /**
  36390. * An event triggered after draw calls have been sent
  36391. */
  36392. onAfterDrawPhaseObservable: Observable<Scene>;
  36393. /**
  36394. * An event triggered when the scene is ready
  36395. */
  36396. onReadyObservable: Observable<Scene>;
  36397. /**
  36398. * An event triggered before rendering a camera
  36399. */
  36400. onBeforeCameraRenderObservable: Observable<Camera>;
  36401. private _onBeforeCameraRenderObserver;
  36402. /** Sets a function to be executed before rendering a camera*/
  36403. set beforeCameraRender(callback: () => void);
  36404. /**
  36405. * An event triggered after rendering a camera
  36406. */
  36407. onAfterCameraRenderObservable: Observable<Camera>;
  36408. private _onAfterCameraRenderObserver;
  36409. /** Sets a function to be executed after rendering a camera*/
  36410. set afterCameraRender(callback: () => void);
  36411. /**
  36412. * An event triggered when active meshes evaluation is about to start
  36413. */
  36414. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36415. /**
  36416. * An event triggered when active meshes evaluation is done
  36417. */
  36418. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36419. /**
  36420. * An event triggered when particles rendering is about to start
  36421. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36422. */
  36423. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36424. /**
  36425. * An event triggered when particles rendering is done
  36426. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36427. */
  36428. onAfterParticlesRenderingObservable: Observable<Scene>;
  36429. /**
  36430. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36431. */
  36432. onDataLoadedObservable: Observable<Scene>;
  36433. /**
  36434. * An event triggered when a camera is created
  36435. */
  36436. onNewCameraAddedObservable: Observable<Camera>;
  36437. /**
  36438. * An event triggered when a camera is removed
  36439. */
  36440. onCameraRemovedObservable: Observable<Camera>;
  36441. /**
  36442. * An event triggered when a light is created
  36443. */
  36444. onNewLightAddedObservable: Observable<Light>;
  36445. /**
  36446. * An event triggered when a light is removed
  36447. */
  36448. onLightRemovedObservable: Observable<Light>;
  36449. /**
  36450. * An event triggered when a geometry is created
  36451. */
  36452. onNewGeometryAddedObservable: Observable<Geometry>;
  36453. /**
  36454. * An event triggered when a geometry is removed
  36455. */
  36456. onGeometryRemovedObservable: Observable<Geometry>;
  36457. /**
  36458. * An event triggered when a transform node is created
  36459. */
  36460. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36461. /**
  36462. * An event triggered when a transform node is removed
  36463. */
  36464. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36465. /**
  36466. * An event triggered when a mesh is created
  36467. */
  36468. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36469. /**
  36470. * An event triggered when a mesh is removed
  36471. */
  36472. onMeshRemovedObservable: Observable<AbstractMesh>;
  36473. /**
  36474. * An event triggered when a skeleton is created
  36475. */
  36476. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36477. /**
  36478. * An event triggered when a skeleton is removed
  36479. */
  36480. onSkeletonRemovedObservable: Observable<Skeleton>;
  36481. /**
  36482. * An event triggered when a material is created
  36483. */
  36484. onNewMaterialAddedObservable: Observable<Material>;
  36485. /**
  36486. * An event triggered when a material is removed
  36487. */
  36488. onMaterialRemovedObservable: Observable<Material>;
  36489. /**
  36490. * An event triggered when a texture is created
  36491. */
  36492. onNewTextureAddedObservable: Observable<BaseTexture>;
  36493. /**
  36494. * An event triggered when a texture is removed
  36495. */
  36496. onTextureRemovedObservable: Observable<BaseTexture>;
  36497. /**
  36498. * An event triggered when render targets are about to be rendered
  36499. * Can happen multiple times per frame.
  36500. */
  36501. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36502. /**
  36503. * An event triggered when render targets were rendered.
  36504. * Can happen multiple times per frame.
  36505. */
  36506. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36507. /**
  36508. * An event triggered before calculating deterministic simulation step
  36509. */
  36510. onBeforeStepObservable: Observable<Scene>;
  36511. /**
  36512. * An event triggered after calculating deterministic simulation step
  36513. */
  36514. onAfterStepObservable: Observable<Scene>;
  36515. /**
  36516. * An event triggered when the activeCamera property is updated
  36517. */
  36518. onActiveCameraChanged: Observable<Scene>;
  36519. /**
  36520. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36521. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36522. * 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)
  36523. */
  36524. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36525. /**
  36526. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36527. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36528. * 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)
  36529. */
  36530. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36531. /**
  36532. * This Observable will when a mesh has been imported into the scene.
  36533. */
  36534. onMeshImportedObservable: Observable<AbstractMesh>;
  36535. /**
  36536. * This Observable will when an animation file has been imported into the scene.
  36537. */
  36538. onAnimationFileImportedObservable: Observable<Scene>;
  36539. /**
  36540. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36541. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36542. */
  36543. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36544. /** @hidden */
  36545. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36546. /**
  36547. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36548. */
  36549. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36550. /**
  36551. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36552. */
  36553. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36554. /**
  36555. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36556. */
  36557. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36558. /** Callback called when a pointer move is detected */
  36559. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36560. /** Callback called when a pointer down is detected */
  36561. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36562. /** Callback called when a pointer up is detected */
  36563. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36564. /** Callback called when a pointer pick is detected */
  36565. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36566. /**
  36567. * 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).
  36568. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36569. */
  36570. onPrePointerObservable: Observable<PointerInfoPre>;
  36571. /**
  36572. * Observable event triggered each time an input event is received from the rendering canvas
  36573. */
  36574. onPointerObservable: Observable<PointerInfo>;
  36575. /**
  36576. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36577. */
  36578. get unTranslatedPointer(): Vector2;
  36579. /**
  36580. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36581. */
  36582. static get DragMovementThreshold(): number;
  36583. static set DragMovementThreshold(value: number);
  36584. /**
  36585. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36586. */
  36587. static get LongPressDelay(): number;
  36588. static set LongPressDelay(value: number);
  36589. /**
  36590. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36591. */
  36592. static get DoubleClickDelay(): number;
  36593. static set DoubleClickDelay(value: number);
  36594. /** If you need to check double click without raising a single click at first click, enable this flag */
  36595. static get ExclusiveDoubleClickMode(): boolean;
  36596. static set ExclusiveDoubleClickMode(value: boolean);
  36597. /** @hidden */
  36598. _mirroredCameraPosition: Nullable<Vector3>;
  36599. /**
  36600. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36601. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36602. */
  36603. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36604. /**
  36605. * Observable event triggered each time an keyboard event is received from the hosting window
  36606. */
  36607. onKeyboardObservable: Observable<KeyboardInfo>;
  36608. private _useRightHandedSystem;
  36609. /**
  36610. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36611. */
  36612. set useRightHandedSystem(value: boolean);
  36613. get useRightHandedSystem(): boolean;
  36614. private _timeAccumulator;
  36615. private _currentStepId;
  36616. private _currentInternalStep;
  36617. /**
  36618. * Sets the step Id used by deterministic lock step
  36619. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36620. * @param newStepId defines the step Id
  36621. */
  36622. setStepId(newStepId: number): void;
  36623. /**
  36624. * Gets the step Id used by deterministic lock step
  36625. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36626. * @returns the step Id
  36627. */
  36628. getStepId(): number;
  36629. /**
  36630. * Gets the internal step used by deterministic lock step
  36631. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36632. * @returns the internal step
  36633. */
  36634. getInternalStep(): number;
  36635. private _fogEnabled;
  36636. /**
  36637. * Gets or sets a boolean indicating if fog is enabled on this scene
  36638. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36639. * (Default is true)
  36640. */
  36641. set fogEnabled(value: boolean);
  36642. get fogEnabled(): boolean;
  36643. private _fogMode;
  36644. /**
  36645. * Gets or sets the fog mode to use
  36646. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36647. * | mode | value |
  36648. * | --- | --- |
  36649. * | FOGMODE_NONE | 0 |
  36650. * | FOGMODE_EXP | 1 |
  36651. * | FOGMODE_EXP2 | 2 |
  36652. * | FOGMODE_LINEAR | 3 |
  36653. */
  36654. set fogMode(value: number);
  36655. get fogMode(): number;
  36656. /**
  36657. * Gets or sets the fog color to use
  36658. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36659. * (Default is Color3(0.2, 0.2, 0.3))
  36660. */
  36661. fogColor: Color3;
  36662. /**
  36663. * Gets or sets the fog density to use
  36664. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36665. * (Default is 0.1)
  36666. */
  36667. fogDensity: number;
  36668. /**
  36669. * Gets or sets the fog start distance to use
  36670. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36671. * (Default is 0)
  36672. */
  36673. fogStart: number;
  36674. /**
  36675. * Gets or sets the fog end distance to use
  36676. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36677. * (Default is 1000)
  36678. */
  36679. fogEnd: number;
  36680. private _shadowsEnabled;
  36681. /**
  36682. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36683. */
  36684. set shadowsEnabled(value: boolean);
  36685. get shadowsEnabled(): boolean;
  36686. private _lightsEnabled;
  36687. /**
  36688. * Gets or sets a boolean indicating if lights are enabled on this scene
  36689. */
  36690. set lightsEnabled(value: boolean);
  36691. get lightsEnabled(): boolean;
  36692. /** All of the active cameras added to this scene. */
  36693. activeCameras: Camera[];
  36694. /** @hidden */
  36695. _activeCamera: Nullable<Camera>;
  36696. /** Gets or sets the current active camera */
  36697. get activeCamera(): Nullable<Camera>;
  36698. set activeCamera(value: Nullable<Camera>);
  36699. private _defaultMaterial;
  36700. /** The default material used on meshes when no material is affected */
  36701. get defaultMaterial(): Material;
  36702. /** The default material used on meshes when no material is affected */
  36703. set defaultMaterial(value: Material);
  36704. private _texturesEnabled;
  36705. /**
  36706. * Gets or sets a boolean indicating if textures are enabled on this scene
  36707. */
  36708. set texturesEnabled(value: boolean);
  36709. get texturesEnabled(): boolean;
  36710. /**
  36711. * Gets or sets a boolean indicating if particles are enabled on this scene
  36712. */
  36713. particlesEnabled: boolean;
  36714. /**
  36715. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36716. */
  36717. spritesEnabled: boolean;
  36718. private _skeletonsEnabled;
  36719. /**
  36720. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36721. */
  36722. set skeletonsEnabled(value: boolean);
  36723. get skeletonsEnabled(): boolean;
  36724. /**
  36725. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36726. */
  36727. lensFlaresEnabled: boolean;
  36728. /**
  36729. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36730. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36731. */
  36732. collisionsEnabled: boolean;
  36733. private _collisionCoordinator;
  36734. /** @hidden */
  36735. get collisionCoordinator(): ICollisionCoordinator;
  36736. /**
  36737. * Defines the gravity applied to this scene (used only for collisions)
  36738. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36739. */
  36740. gravity: Vector3;
  36741. /**
  36742. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36743. */
  36744. postProcessesEnabled: boolean;
  36745. /**
  36746. * The list of postprocesses added to the scene
  36747. */
  36748. postProcesses: PostProcess[];
  36749. /**
  36750. * Gets the current postprocess manager
  36751. */
  36752. postProcessManager: PostProcessManager;
  36753. /**
  36754. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36755. */
  36756. renderTargetsEnabled: boolean;
  36757. /**
  36758. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36759. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36760. */
  36761. dumpNextRenderTargets: boolean;
  36762. /**
  36763. * The list of user defined render targets added to the scene
  36764. */
  36765. customRenderTargets: RenderTargetTexture[];
  36766. /**
  36767. * Defines if texture loading must be delayed
  36768. * If true, textures will only be loaded when they need to be rendered
  36769. */
  36770. useDelayedTextureLoading: boolean;
  36771. /**
  36772. * Gets the list of meshes imported to the scene through SceneLoader
  36773. */
  36774. importedMeshesFiles: String[];
  36775. /**
  36776. * Gets or sets a boolean indicating if probes are enabled on this scene
  36777. */
  36778. probesEnabled: boolean;
  36779. /**
  36780. * Gets or sets the current offline provider to use to store scene data
  36781. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36782. */
  36783. offlineProvider: IOfflineProvider;
  36784. /**
  36785. * Gets or sets the action manager associated with the scene
  36786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36787. */
  36788. actionManager: AbstractActionManager;
  36789. private _meshesForIntersections;
  36790. /**
  36791. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36792. */
  36793. proceduralTexturesEnabled: boolean;
  36794. private _engine;
  36795. private _totalVertices;
  36796. /** @hidden */
  36797. _activeIndices: PerfCounter;
  36798. /** @hidden */
  36799. _activeParticles: PerfCounter;
  36800. /** @hidden */
  36801. _activeBones: PerfCounter;
  36802. private _animationRatio;
  36803. /** @hidden */
  36804. _animationTimeLast: number;
  36805. /** @hidden */
  36806. _animationTime: number;
  36807. /**
  36808. * Gets or sets a general scale for animation speed
  36809. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36810. */
  36811. animationTimeScale: number;
  36812. /** @hidden */
  36813. _cachedMaterial: Nullable<Material>;
  36814. /** @hidden */
  36815. _cachedEffect: Nullable<Effect>;
  36816. /** @hidden */
  36817. _cachedVisibility: Nullable<number>;
  36818. private _renderId;
  36819. private _frameId;
  36820. private _executeWhenReadyTimeoutId;
  36821. private _intermediateRendering;
  36822. private _viewUpdateFlag;
  36823. private _projectionUpdateFlag;
  36824. /** @hidden */
  36825. _toBeDisposed: Nullable<IDisposable>[];
  36826. private _activeRequests;
  36827. /** @hidden */
  36828. _pendingData: any[];
  36829. private _isDisposed;
  36830. /**
  36831. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36832. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36833. */
  36834. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36835. private _activeMeshes;
  36836. private _processedMaterials;
  36837. private _renderTargets;
  36838. /** @hidden */
  36839. _activeParticleSystems: SmartArray<IParticleSystem>;
  36840. private _activeSkeletons;
  36841. private _softwareSkinnedMeshes;
  36842. private _renderingManager;
  36843. /** @hidden */
  36844. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36845. private _transformMatrix;
  36846. private _sceneUbo;
  36847. /** @hidden */
  36848. _viewMatrix: Matrix;
  36849. private _projectionMatrix;
  36850. /** @hidden */
  36851. _forcedViewPosition: Nullable<Vector3>;
  36852. /** @hidden */
  36853. _frustumPlanes: Plane[];
  36854. /**
  36855. * Gets the list of frustum planes (built from the active camera)
  36856. */
  36857. get frustumPlanes(): Plane[];
  36858. /**
  36859. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36860. * This is useful if there are more lights that the maximum simulteanous authorized
  36861. */
  36862. requireLightSorting: boolean;
  36863. /** @hidden */
  36864. readonly useMaterialMeshMap: boolean;
  36865. /** @hidden */
  36866. readonly useClonedMeshMap: boolean;
  36867. private _externalData;
  36868. private _uid;
  36869. /**
  36870. * @hidden
  36871. * Backing store of defined scene components.
  36872. */
  36873. _components: ISceneComponent[];
  36874. /**
  36875. * @hidden
  36876. * Backing store of defined scene components.
  36877. */
  36878. _serializableComponents: ISceneSerializableComponent[];
  36879. /**
  36880. * List of components to register on the next registration step.
  36881. */
  36882. private _transientComponents;
  36883. /**
  36884. * Registers the transient components if needed.
  36885. */
  36886. private _registerTransientComponents;
  36887. /**
  36888. * @hidden
  36889. * Add a component to the scene.
  36890. * Note that the ccomponent could be registered on th next frame if this is called after
  36891. * the register component stage.
  36892. * @param component Defines the component to add to the scene
  36893. */
  36894. _addComponent(component: ISceneComponent): void;
  36895. /**
  36896. * @hidden
  36897. * Gets a component from the scene.
  36898. * @param name defines the name of the component to retrieve
  36899. * @returns the component or null if not present
  36900. */
  36901. _getComponent(name: string): Nullable<ISceneComponent>;
  36902. /**
  36903. * @hidden
  36904. * Defines the actions happening before camera updates.
  36905. */
  36906. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36907. /**
  36908. * @hidden
  36909. * Defines the actions happening before clear the canvas.
  36910. */
  36911. _beforeClearStage: Stage<SimpleStageAction>;
  36912. /**
  36913. * @hidden
  36914. * Defines the actions when collecting render targets for the frame.
  36915. */
  36916. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36917. /**
  36918. * @hidden
  36919. * Defines the actions happening for one camera in the frame.
  36920. */
  36921. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36922. /**
  36923. * @hidden
  36924. * Defines the actions happening during the per mesh ready checks.
  36925. */
  36926. _isReadyForMeshStage: Stage<MeshStageAction>;
  36927. /**
  36928. * @hidden
  36929. * Defines the actions happening before evaluate active mesh checks.
  36930. */
  36931. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36932. /**
  36933. * @hidden
  36934. * Defines the actions happening during the evaluate sub mesh checks.
  36935. */
  36936. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36937. /**
  36938. * @hidden
  36939. * Defines the actions happening during the active mesh stage.
  36940. */
  36941. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36942. /**
  36943. * @hidden
  36944. * Defines the actions happening during the per camera render target step.
  36945. */
  36946. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36947. /**
  36948. * @hidden
  36949. * Defines the actions happening just before the active camera is drawing.
  36950. */
  36951. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36952. /**
  36953. * @hidden
  36954. * Defines the actions happening just before a render target is drawing.
  36955. */
  36956. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36957. /**
  36958. * @hidden
  36959. * Defines the actions happening just before a rendering group is drawing.
  36960. */
  36961. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36962. /**
  36963. * @hidden
  36964. * Defines the actions happening just before a mesh is drawing.
  36965. */
  36966. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36967. /**
  36968. * @hidden
  36969. * Defines the actions happening just after a mesh has been drawn.
  36970. */
  36971. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36972. /**
  36973. * @hidden
  36974. * Defines the actions happening just after a rendering group has been drawn.
  36975. */
  36976. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36977. /**
  36978. * @hidden
  36979. * Defines the actions happening just after the active camera has been drawn.
  36980. */
  36981. _afterCameraDrawStage: Stage<CameraStageAction>;
  36982. /**
  36983. * @hidden
  36984. * Defines the actions happening just after a render target has been drawn.
  36985. */
  36986. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36987. /**
  36988. * @hidden
  36989. * Defines the actions happening just after rendering all cameras and computing intersections.
  36990. */
  36991. _afterRenderStage: Stage<SimpleStageAction>;
  36992. /**
  36993. * @hidden
  36994. * Defines the actions happening when a pointer move event happens.
  36995. */
  36996. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36997. /**
  36998. * @hidden
  36999. * Defines the actions happening when a pointer down event happens.
  37000. */
  37001. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37002. /**
  37003. * @hidden
  37004. * Defines the actions happening when a pointer up event happens.
  37005. */
  37006. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37007. /**
  37008. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37009. */
  37010. private geometriesByUniqueId;
  37011. /**
  37012. * Creates a new Scene
  37013. * @param engine defines the engine to use to render this scene
  37014. * @param options defines the scene options
  37015. */
  37016. constructor(engine: Engine, options?: SceneOptions);
  37017. /**
  37018. * Gets a string idenfifying the name of the class
  37019. * @returns "Scene" string
  37020. */
  37021. getClassName(): string;
  37022. private _defaultMeshCandidates;
  37023. /**
  37024. * @hidden
  37025. */
  37026. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37027. private _defaultSubMeshCandidates;
  37028. /**
  37029. * @hidden
  37030. */
  37031. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37032. /**
  37033. * Sets the default candidate providers for the scene.
  37034. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37035. * and getCollidingSubMeshCandidates to their default function
  37036. */
  37037. setDefaultCandidateProviders(): void;
  37038. /**
  37039. * Gets the mesh that is currently under the pointer
  37040. */
  37041. get meshUnderPointer(): Nullable<AbstractMesh>;
  37042. /**
  37043. * Gets or sets the current on-screen X position of the pointer
  37044. */
  37045. get pointerX(): number;
  37046. set pointerX(value: number);
  37047. /**
  37048. * Gets or sets the current on-screen Y position of the pointer
  37049. */
  37050. get pointerY(): number;
  37051. set pointerY(value: number);
  37052. /**
  37053. * Gets the cached material (ie. the latest rendered one)
  37054. * @returns the cached material
  37055. */
  37056. getCachedMaterial(): Nullable<Material>;
  37057. /**
  37058. * Gets the cached effect (ie. the latest rendered one)
  37059. * @returns the cached effect
  37060. */
  37061. getCachedEffect(): Nullable<Effect>;
  37062. /**
  37063. * Gets the cached visibility state (ie. the latest rendered one)
  37064. * @returns the cached visibility state
  37065. */
  37066. getCachedVisibility(): Nullable<number>;
  37067. /**
  37068. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37069. * @param material defines the current material
  37070. * @param effect defines the current effect
  37071. * @param visibility defines the current visibility state
  37072. * @returns true if one parameter is not cached
  37073. */
  37074. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37075. /**
  37076. * Gets the engine associated with the scene
  37077. * @returns an Engine
  37078. */
  37079. getEngine(): Engine;
  37080. /**
  37081. * Gets the total number of vertices rendered per frame
  37082. * @returns the total number of vertices rendered per frame
  37083. */
  37084. getTotalVertices(): number;
  37085. /**
  37086. * Gets the performance counter for total vertices
  37087. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37088. */
  37089. get totalVerticesPerfCounter(): PerfCounter;
  37090. /**
  37091. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37092. * @returns the total number of active indices rendered per frame
  37093. */
  37094. getActiveIndices(): number;
  37095. /**
  37096. * Gets the performance counter for active indices
  37097. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37098. */
  37099. get totalActiveIndicesPerfCounter(): PerfCounter;
  37100. /**
  37101. * Gets the total number of active particles rendered per frame
  37102. * @returns the total number of active particles rendered per frame
  37103. */
  37104. getActiveParticles(): number;
  37105. /**
  37106. * Gets the performance counter for active particles
  37107. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37108. */
  37109. get activeParticlesPerfCounter(): PerfCounter;
  37110. /**
  37111. * Gets the total number of active bones rendered per frame
  37112. * @returns the total number of active bones rendered per frame
  37113. */
  37114. getActiveBones(): number;
  37115. /**
  37116. * Gets the performance counter for active bones
  37117. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37118. */
  37119. get activeBonesPerfCounter(): PerfCounter;
  37120. /**
  37121. * Gets the array of active meshes
  37122. * @returns an array of AbstractMesh
  37123. */
  37124. getActiveMeshes(): SmartArray<AbstractMesh>;
  37125. /**
  37126. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37127. * @returns a number
  37128. */
  37129. getAnimationRatio(): number;
  37130. /**
  37131. * Gets an unique Id for the current render phase
  37132. * @returns a number
  37133. */
  37134. getRenderId(): number;
  37135. /**
  37136. * Gets an unique Id for the current frame
  37137. * @returns a number
  37138. */
  37139. getFrameId(): number;
  37140. /** Call this function if you want to manually increment the render Id*/
  37141. incrementRenderId(): void;
  37142. private _createUbo;
  37143. /**
  37144. * Use this method to simulate a pointer move on a mesh
  37145. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37146. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37147. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37148. * @returns the current scene
  37149. */
  37150. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37151. /**
  37152. * Use this method to simulate a pointer down on a mesh
  37153. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37154. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37155. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37156. * @returns the current scene
  37157. */
  37158. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37159. /**
  37160. * Use this method to simulate a pointer up on a mesh
  37161. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37162. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37163. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37164. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37165. * @returns the current scene
  37166. */
  37167. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37168. /**
  37169. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37170. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37171. * @returns true if the pointer was captured
  37172. */
  37173. isPointerCaptured(pointerId?: number): boolean;
  37174. /**
  37175. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37176. * @param attachUp defines if you want to attach events to pointerup
  37177. * @param attachDown defines if you want to attach events to pointerdown
  37178. * @param attachMove defines if you want to attach events to pointermove
  37179. */
  37180. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37181. /** Detaches all event handlers*/
  37182. detachControl(): void;
  37183. /**
  37184. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37185. * Delay loaded resources are not taking in account
  37186. * @return true if all required resources are ready
  37187. */
  37188. isReady(): boolean;
  37189. /** Resets all cached information relative to material (including effect and visibility) */
  37190. resetCachedMaterial(): void;
  37191. /**
  37192. * Registers a function to be called before every frame render
  37193. * @param func defines the function to register
  37194. */
  37195. registerBeforeRender(func: () => void): void;
  37196. /**
  37197. * Unregisters a function called before every frame render
  37198. * @param func defines the function to unregister
  37199. */
  37200. unregisterBeforeRender(func: () => void): void;
  37201. /**
  37202. * Registers a function to be called after every frame render
  37203. * @param func defines the function to register
  37204. */
  37205. registerAfterRender(func: () => void): void;
  37206. /**
  37207. * Unregisters a function called after every frame render
  37208. * @param func defines the function to unregister
  37209. */
  37210. unregisterAfterRender(func: () => void): void;
  37211. private _executeOnceBeforeRender;
  37212. /**
  37213. * The provided function will run before render once and will be disposed afterwards.
  37214. * A timeout delay can be provided so that the function will be executed in N ms.
  37215. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37216. * @param func The function to be executed.
  37217. * @param timeout optional delay in ms
  37218. */
  37219. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37220. /** @hidden */
  37221. _addPendingData(data: any): void;
  37222. /** @hidden */
  37223. _removePendingData(data: any): void;
  37224. /**
  37225. * Returns the number of items waiting to be loaded
  37226. * @returns the number of items waiting to be loaded
  37227. */
  37228. getWaitingItemsCount(): number;
  37229. /**
  37230. * Returns a boolean indicating if the scene is still loading data
  37231. */
  37232. get isLoading(): boolean;
  37233. /**
  37234. * Registers a function to be executed when the scene is ready
  37235. * @param {Function} func - the function to be executed
  37236. */
  37237. executeWhenReady(func: () => void): void;
  37238. /**
  37239. * Returns a promise that resolves when the scene is ready
  37240. * @returns A promise that resolves when the scene is ready
  37241. */
  37242. whenReadyAsync(): Promise<void>;
  37243. /** @hidden */
  37244. _checkIsReady(): void;
  37245. /**
  37246. * Gets all animatable attached to the scene
  37247. */
  37248. get animatables(): Animatable[];
  37249. /**
  37250. * Resets the last animation time frame.
  37251. * Useful to override when animations start running when loading a scene for the first time.
  37252. */
  37253. resetLastAnimationTimeFrame(): void;
  37254. /**
  37255. * Gets the current view matrix
  37256. * @returns a Matrix
  37257. */
  37258. getViewMatrix(): Matrix;
  37259. /**
  37260. * Gets the current projection matrix
  37261. * @returns a Matrix
  37262. */
  37263. getProjectionMatrix(): Matrix;
  37264. /**
  37265. * Gets the current transform matrix
  37266. * @returns a Matrix made of View * Projection
  37267. */
  37268. getTransformMatrix(): Matrix;
  37269. /**
  37270. * Sets the current transform matrix
  37271. * @param viewL defines the View matrix to use
  37272. * @param projectionL defines the Projection matrix to use
  37273. * @param viewR defines the right View matrix to use (if provided)
  37274. * @param projectionR defines the right Projection matrix to use (if provided)
  37275. */
  37276. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37277. /**
  37278. * Gets the uniform buffer used to store scene data
  37279. * @returns a UniformBuffer
  37280. */
  37281. getSceneUniformBuffer(): UniformBuffer;
  37282. /**
  37283. * Gets an unique (relatively to the current scene) Id
  37284. * @returns an unique number for the scene
  37285. */
  37286. getUniqueId(): number;
  37287. /**
  37288. * Add a mesh to the list of scene's meshes
  37289. * @param newMesh defines the mesh to add
  37290. * @param recursive if all child meshes should also be added to the scene
  37291. */
  37292. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37293. /**
  37294. * Remove a mesh for the list of scene's meshes
  37295. * @param toRemove defines the mesh to remove
  37296. * @param recursive if all child meshes should also be removed from the scene
  37297. * @returns the index where the mesh was in the mesh list
  37298. */
  37299. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37300. /**
  37301. * Add a transform node to the list of scene's transform nodes
  37302. * @param newTransformNode defines the transform node to add
  37303. */
  37304. addTransformNode(newTransformNode: TransformNode): void;
  37305. /**
  37306. * Remove a transform node for the list of scene's transform nodes
  37307. * @param toRemove defines the transform node to remove
  37308. * @returns the index where the transform node was in the transform node list
  37309. */
  37310. removeTransformNode(toRemove: TransformNode): number;
  37311. /**
  37312. * Remove a skeleton for the list of scene's skeletons
  37313. * @param toRemove defines the skeleton to remove
  37314. * @returns the index where the skeleton was in the skeleton list
  37315. */
  37316. removeSkeleton(toRemove: Skeleton): number;
  37317. /**
  37318. * Remove a morph target for the list of scene's morph targets
  37319. * @param toRemove defines the morph target to remove
  37320. * @returns the index where the morph target was in the morph target list
  37321. */
  37322. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37323. /**
  37324. * Remove a light for the list of scene's lights
  37325. * @param toRemove defines the light to remove
  37326. * @returns the index where the light was in the light list
  37327. */
  37328. removeLight(toRemove: Light): number;
  37329. /**
  37330. * Remove a camera for the list of scene's cameras
  37331. * @param toRemove defines the camera to remove
  37332. * @returns the index where the camera was in the camera list
  37333. */
  37334. removeCamera(toRemove: Camera): number;
  37335. /**
  37336. * Remove a particle system for the list of scene's particle systems
  37337. * @param toRemove defines the particle system to remove
  37338. * @returns the index where the particle system was in the particle system list
  37339. */
  37340. removeParticleSystem(toRemove: IParticleSystem): number;
  37341. /**
  37342. * Remove a animation for the list of scene's animations
  37343. * @param toRemove defines the animation to remove
  37344. * @returns the index where the animation was in the animation list
  37345. */
  37346. removeAnimation(toRemove: Animation): number;
  37347. /**
  37348. * Will stop the animation of the given target
  37349. * @param target - the target
  37350. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37351. * @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)
  37352. */
  37353. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37354. /**
  37355. * Removes the given animation group from this scene.
  37356. * @param toRemove The animation group to remove
  37357. * @returns The index of the removed animation group
  37358. */
  37359. removeAnimationGroup(toRemove: AnimationGroup): number;
  37360. /**
  37361. * Removes the given multi-material from this scene.
  37362. * @param toRemove The multi-material to remove
  37363. * @returns The index of the removed multi-material
  37364. */
  37365. removeMultiMaterial(toRemove: MultiMaterial): number;
  37366. /**
  37367. * Removes the given material from this scene.
  37368. * @param toRemove The material to remove
  37369. * @returns The index of the removed material
  37370. */
  37371. removeMaterial(toRemove: Material): number;
  37372. /**
  37373. * Removes the given action manager from this scene.
  37374. * @param toRemove The action manager to remove
  37375. * @returns The index of the removed action manager
  37376. */
  37377. removeActionManager(toRemove: AbstractActionManager): number;
  37378. /**
  37379. * Removes the given texture from this scene.
  37380. * @param toRemove The texture to remove
  37381. * @returns The index of the removed texture
  37382. */
  37383. removeTexture(toRemove: BaseTexture): number;
  37384. /**
  37385. * Adds the given light to this scene
  37386. * @param newLight The light to add
  37387. */
  37388. addLight(newLight: Light): void;
  37389. /**
  37390. * Sorts the list list based on light priorities
  37391. */
  37392. sortLightsByPriority(): void;
  37393. /**
  37394. * Adds the given camera to this scene
  37395. * @param newCamera The camera to add
  37396. */
  37397. addCamera(newCamera: Camera): void;
  37398. /**
  37399. * Adds the given skeleton to this scene
  37400. * @param newSkeleton The skeleton to add
  37401. */
  37402. addSkeleton(newSkeleton: Skeleton): void;
  37403. /**
  37404. * Adds the given particle system to this scene
  37405. * @param newParticleSystem The particle system to add
  37406. */
  37407. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37408. /**
  37409. * Adds the given animation to this scene
  37410. * @param newAnimation The animation to add
  37411. */
  37412. addAnimation(newAnimation: Animation): void;
  37413. /**
  37414. * Adds the given animation group to this scene.
  37415. * @param newAnimationGroup The animation group to add
  37416. */
  37417. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37418. /**
  37419. * Adds the given multi-material to this scene
  37420. * @param newMultiMaterial The multi-material to add
  37421. */
  37422. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37423. /**
  37424. * Adds the given material to this scene
  37425. * @param newMaterial The material to add
  37426. */
  37427. addMaterial(newMaterial: Material): void;
  37428. /**
  37429. * Adds the given morph target to this scene
  37430. * @param newMorphTargetManager The morph target to add
  37431. */
  37432. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37433. /**
  37434. * Adds the given geometry to this scene
  37435. * @param newGeometry The geometry to add
  37436. */
  37437. addGeometry(newGeometry: Geometry): void;
  37438. /**
  37439. * Adds the given action manager to this scene
  37440. * @param newActionManager The action manager to add
  37441. */
  37442. addActionManager(newActionManager: AbstractActionManager): void;
  37443. /**
  37444. * Adds the given texture to this scene.
  37445. * @param newTexture The texture to add
  37446. */
  37447. addTexture(newTexture: BaseTexture): void;
  37448. /**
  37449. * Switch active camera
  37450. * @param newCamera defines the new active camera
  37451. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37452. */
  37453. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37454. /**
  37455. * sets the active camera of the scene using its ID
  37456. * @param id defines the camera's ID
  37457. * @return the new active camera or null if none found.
  37458. */
  37459. setActiveCameraByID(id: string): Nullable<Camera>;
  37460. /**
  37461. * sets the active camera of the scene using its name
  37462. * @param name defines the camera's name
  37463. * @returns the new active camera or null if none found.
  37464. */
  37465. setActiveCameraByName(name: string): Nullable<Camera>;
  37466. /**
  37467. * get an animation group using its name
  37468. * @param name defines the material's name
  37469. * @return the animation group or null if none found.
  37470. */
  37471. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37472. /**
  37473. * Get a material using its unique id
  37474. * @param uniqueId defines the material's unique id
  37475. * @return the material or null if none found.
  37476. */
  37477. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37478. /**
  37479. * get a material using its id
  37480. * @param id defines the material's ID
  37481. * @return the material or null if none found.
  37482. */
  37483. getMaterialByID(id: string): Nullable<Material>;
  37484. /**
  37485. * Gets a the last added material using a given id
  37486. * @param id defines the material's ID
  37487. * @return the last material with the given id or null if none found.
  37488. */
  37489. getLastMaterialByID(id: string): Nullable<Material>;
  37490. /**
  37491. * Gets a material using its name
  37492. * @param name defines the material's name
  37493. * @return the material or null if none found.
  37494. */
  37495. getMaterialByName(name: string): Nullable<Material>;
  37496. /**
  37497. * Get a texture using its unique id
  37498. * @param uniqueId defines the texture's unique id
  37499. * @return the texture or null if none found.
  37500. */
  37501. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37502. /**
  37503. * Gets a camera using its id
  37504. * @param id defines the id to look for
  37505. * @returns the camera or null if not found
  37506. */
  37507. getCameraByID(id: string): Nullable<Camera>;
  37508. /**
  37509. * Gets a camera using its unique id
  37510. * @param uniqueId defines the unique id to look for
  37511. * @returns the camera or null if not found
  37512. */
  37513. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37514. /**
  37515. * Gets a camera using its name
  37516. * @param name defines the camera's name
  37517. * @return the camera or null if none found.
  37518. */
  37519. getCameraByName(name: string): Nullable<Camera>;
  37520. /**
  37521. * Gets a bone using its id
  37522. * @param id defines the bone's id
  37523. * @return the bone or null if not found
  37524. */
  37525. getBoneByID(id: string): Nullable<Bone>;
  37526. /**
  37527. * Gets a bone using its id
  37528. * @param name defines the bone's name
  37529. * @return the bone or null if not found
  37530. */
  37531. getBoneByName(name: string): Nullable<Bone>;
  37532. /**
  37533. * Gets a light node using its name
  37534. * @param name defines the the light's name
  37535. * @return the light or null if none found.
  37536. */
  37537. getLightByName(name: string): Nullable<Light>;
  37538. /**
  37539. * Gets a light node using its id
  37540. * @param id defines the light's id
  37541. * @return the light or null if none found.
  37542. */
  37543. getLightByID(id: string): Nullable<Light>;
  37544. /**
  37545. * Gets a light node using its scene-generated unique ID
  37546. * @param uniqueId defines the light's unique id
  37547. * @return the light or null if none found.
  37548. */
  37549. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37550. /**
  37551. * Gets a particle system by id
  37552. * @param id defines the particle system id
  37553. * @return the corresponding system or null if none found
  37554. */
  37555. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37556. /**
  37557. * Gets a geometry using its ID
  37558. * @param id defines the geometry's id
  37559. * @return the geometry or null if none found.
  37560. */
  37561. getGeometryByID(id: string): Nullable<Geometry>;
  37562. private _getGeometryByUniqueID;
  37563. /**
  37564. * Add a new geometry to this scene
  37565. * @param geometry defines the geometry to be added to the scene.
  37566. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37567. * @return a boolean defining if the geometry was added or not
  37568. */
  37569. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37570. /**
  37571. * Removes an existing geometry
  37572. * @param geometry defines the geometry to be removed from the scene
  37573. * @return a boolean defining if the geometry was removed or not
  37574. */
  37575. removeGeometry(geometry: Geometry): boolean;
  37576. /**
  37577. * Gets the list of geometries attached to the scene
  37578. * @returns an array of Geometry
  37579. */
  37580. getGeometries(): Geometry[];
  37581. /**
  37582. * Gets the first added mesh found of a given ID
  37583. * @param id defines the id to search for
  37584. * @return the mesh found or null if not found at all
  37585. */
  37586. getMeshByID(id: string): Nullable<AbstractMesh>;
  37587. /**
  37588. * Gets a list of meshes using their id
  37589. * @param id defines the id to search for
  37590. * @returns a list of meshes
  37591. */
  37592. getMeshesByID(id: string): Array<AbstractMesh>;
  37593. /**
  37594. * Gets the first added transform node found of a given ID
  37595. * @param id defines the id to search for
  37596. * @return the found transform node or null if not found at all.
  37597. */
  37598. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37599. /**
  37600. * Gets a transform node with its auto-generated unique id
  37601. * @param uniqueId efines the unique id to search for
  37602. * @return the found transform node or null if not found at all.
  37603. */
  37604. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37605. /**
  37606. * Gets a list of transform nodes using their id
  37607. * @param id defines the id to search for
  37608. * @returns a list of transform nodes
  37609. */
  37610. getTransformNodesByID(id: string): Array<TransformNode>;
  37611. /**
  37612. * Gets a mesh with its auto-generated unique id
  37613. * @param uniqueId defines the unique id to search for
  37614. * @return the found mesh or null if not found at all.
  37615. */
  37616. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37617. /**
  37618. * Gets a the last added mesh using a given id
  37619. * @param id defines the id to search for
  37620. * @return the found mesh or null if not found at all.
  37621. */
  37622. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37623. /**
  37624. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37625. * @param id defines the id to search for
  37626. * @return the found node or null if not found at all
  37627. */
  37628. getLastEntryByID(id: string): Nullable<Node>;
  37629. /**
  37630. * Gets a node (Mesh, Camera, Light) using a given id
  37631. * @param id defines the id to search for
  37632. * @return the found node or null if not found at all
  37633. */
  37634. getNodeByID(id: string): Nullable<Node>;
  37635. /**
  37636. * Gets a node (Mesh, Camera, Light) using a given name
  37637. * @param name defines the name to search for
  37638. * @return the found node or null if not found at all.
  37639. */
  37640. getNodeByName(name: string): Nullable<Node>;
  37641. /**
  37642. * Gets a mesh using a given name
  37643. * @param name defines the name to search for
  37644. * @return the found mesh or null if not found at all.
  37645. */
  37646. getMeshByName(name: string): Nullable<AbstractMesh>;
  37647. /**
  37648. * Gets a transform node using a given name
  37649. * @param name defines the name to search for
  37650. * @return the found transform node or null if not found at all.
  37651. */
  37652. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37653. /**
  37654. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37655. * @param id defines the id to search for
  37656. * @return the found skeleton or null if not found at all.
  37657. */
  37658. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37659. /**
  37660. * Gets a skeleton using a given auto generated unique id
  37661. * @param uniqueId defines the unique id to search for
  37662. * @return the found skeleton or null if not found at all.
  37663. */
  37664. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37665. /**
  37666. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37667. * @param id defines the id to search for
  37668. * @return the found skeleton or null if not found at all.
  37669. */
  37670. getSkeletonById(id: string): Nullable<Skeleton>;
  37671. /**
  37672. * Gets a skeleton using a given name
  37673. * @param name defines the name to search for
  37674. * @return the found skeleton or null if not found at all.
  37675. */
  37676. getSkeletonByName(name: string): Nullable<Skeleton>;
  37677. /**
  37678. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37679. * @param id defines the id to search for
  37680. * @return the found morph target manager or null if not found at all.
  37681. */
  37682. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37683. /**
  37684. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37685. * @param id defines the id to search for
  37686. * @return the found morph target or null if not found at all.
  37687. */
  37688. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37689. /**
  37690. * Gets a boolean indicating if the given mesh is active
  37691. * @param mesh defines the mesh to look for
  37692. * @returns true if the mesh is in the active list
  37693. */
  37694. isActiveMesh(mesh: AbstractMesh): boolean;
  37695. /**
  37696. * Return a unique id as a string which can serve as an identifier for the scene
  37697. */
  37698. get uid(): string;
  37699. /**
  37700. * Add an externaly attached data from its key.
  37701. * This method call will fail and return false, if such key already exists.
  37702. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37703. * @param key the unique key that identifies the data
  37704. * @param data the data object to associate to the key for this Engine instance
  37705. * @return true if no such key were already present and the data was added successfully, false otherwise
  37706. */
  37707. addExternalData<T>(key: string, data: T): boolean;
  37708. /**
  37709. * Get an externaly attached data from its key
  37710. * @param key the unique key that identifies the data
  37711. * @return the associated data, if present (can be null), or undefined if not present
  37712. */
  37713. getExternalData<T>(key: string): Nullable<T>;
  37714. /**
  37715. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37716. * @param key the unique key that identifies the data
  37717. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37718. * @return the associated data, can be null if the factory returned null.
  37719. */
  37720. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37721. /**
  37722. * Remove an externaly attached data from the Engine instance
  37723. * @param key the unique key that identifies the data
  37724. * @return true if the data was successfully removed, false if it doesn't exist
  37725. */
  37726. removeExternalData(key: string): boolean;
  37727. private _evaluateSubMesh;
  37728. /**
  37729. * Clear the processed materials smart array preventing retention point in material dispose.
  37730. */
  37731. freeProcessedMaterials(): void;
  37732. private _preventFreeActiveMeshesAndRenderingGroups;
  37733. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37734. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37735. * when disposing several meshes in a row or a hierarchy of meshes.
  37736. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37737. */
  37738. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37739. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37740. /**
  37741. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37742. */
  37743. freeActiveMeshes(): void;
  37744. /**
  37745. * Clear the info related to rendering groups preventing retention points during dispose.
  37746. */
  37747. freeRenderingGroups(): void;
  37748. /** @hidden */
  37749. _isInIntermediateRendering(): boolean;
  37750. /**
  37751. * Lambda returning the list of potentially active meshes.
  37752. */
  37753. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37754. /**
  37755. * Lambda returning the list of potentially active sub meshes.
  37756. */
  37757. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37758. /**
  37759. * Lambda returning the list of potentially intersecting sub meshes.
  37760. */
  37761. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37762. /**
  37763. * Lambda returning the list of potentially colliding sub meshes.
  37764. */
  37765. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37766. private _activeMeshesFrozen;
  37767. private _skipEvaluateActiveMeshesCompletely;
  37768. /**
  37769. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37770. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37771. * @returns the current scene
  37772. */
  37773. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37774. /**
  37775. * Use this function to restart evaluating active meshes on every frame
  37776. * @returns the current scene
  37777. */
  37778. unfreezeActiveMeshes(): Scene;
  37779. private _evaluateActiveMeshes;
  37780. private _activeMesh;
  37781. /**
  37782. * Update the transform matrix to update from the current active camera
  37783. * @param force defines a boolean used to force the update even if cache is up to date
  37784. */
  37785. updateTransformMatrix(force?: boolean): void;
  37786. private _bindFrameBuffer;
  37787. /** @hidden */
  37788. _allowPostProcessClearColor: boolean;
  37789. /** @hidden */
  37790. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37791. private _processSubCameras;
  37792. private _checkIntersections;
  37793. /** @hidden */
  37794. _advancePhysicsEngineStep(step: number): void;
  37795. /**
  37796. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37797. */
  37798. getDeterministicFrameTime: () => number;
  37799. /** @hidden */
  37800. _animate(): void;
  37801. /** Execute all animations (for a frame) */
  37802. animate(): void;
  37803. /**
  37804. * Render the scene
  37805. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37806. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37807. */
  37808. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37809. /**
  37810. * Freeze all materials
  37811. * A frozen material will not be updatable but should be faster to render
  37812. */
  37813. freezeMaterials(): void;
  37814. /**
  37815. * Unfreeze all materials
  37816. * A frozen material will not be updatable but should be faster to render
  37817. */
  37818. unfreezeMaterials(): void;
  37819. /**
  37820. * Releases all held ressources
  37821. */
  37822. dispose(): void;
  37823. /**
  37824. * Gets if the scene is already disposed
  37825. */
  37826. get isDisposed(): boolean;
  37827. /**
  37828. * Call this function to reduce memory footprint of the scene.
  37829. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37830. */
  37831. clearCachedVertexData(): void;
  37832. /**
  37833. * This function will remove the local cached buffer data from texture.
  37834. * It will save memory but will prevent the texture from being rebuilt
  37835. */
  37836. cleanCachedTextureBuffer(): void;
  37837. /**
  37838. * Get the world extend vectors with an optional filter
  37839. *
  37840. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37841. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37842. */
  37843. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37844. min: Vector3;
  37845. max: Vector3;
  37846. };
  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 camera defines the camera to use for the picking
  37853. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37854. * @returns a Ray
  37855. */
  37856. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37857. /**
  37858. * Creates a ray that can be used to pick in the scene
  37859. * @param x defines the x coordinate of the origin (on-screen)
  37860. * @param y defines the y coordinate of the origin (on-screen)
  37861. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37862. * @param result defines the ray where to store the picking ray
  37863. * @param camera defines the camera to use for the picking
  37864. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37865. * @returns the current scene
  37866. */
  37867. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37868. /**
  37869. * Creates a ray that can be used to pick in the scene
  37870. * @param x defines the x coordinate of the origin (on-screen)
  37871. * @param y defines the y coordinate of the origin (on-screen)
  37872. * @param camera defines the camera to use for the picking
  37873. * @returns a Ray
  37874. */
  37875. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37876. /**
  37877. * Creates a ray that can be used to pick in the scene
  37878. * @param x defines the x coordinate of the origin (on-screen)
  37879. * @param y defines the y coordinate of the origin (on-screen)
  37880. * @param result defines the ray where to store the picking ray
  37881. * @param camera defines the camera to use for the picking
  37882. * @returns the current scene
  37883. */
  37884. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37885. /** Launch a ray to try to pick a mesh in the scene
  37886. * @param x position on screen
  37887. * @param y position on screen
  37888. * @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
  37889. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37890. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37891. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37892. * @returns a PickingInfo
  37893. */
  37894. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37895. /** Use the given ray to pick a mesh in the scene
  37896. * @param ray The ray to use to pick meshes
  37897. * @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
  37898. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37899. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37900. * @returns a PickingInfo
  37901. */
  37902. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37903. /**
  37904. * Launch a ray to try to pick a mesh in the scene
  37905. * @param x X position on screen
  37906. * @param y Y position on screen
  37907. * @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
  37908. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37909. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37910. * @returns an array of PickingInfo
  37911. */
  37912. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37913. /**
  37914. * Launch a ray to try to pick a mesh in the scene
  37915. * @param ray Ray to use
  37916. * @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
  37917. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37918. * @returns an array of PickingInfo
  37919. */
  37920. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37921. /**
  37922. * Force the value of meshUnderPointer
  37923. * @param mesh defines the mesh to use
  37924. */
  37925. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37926. /**
  37927. * Gets the mesh under the pointer
  37928. * @returns a Mesh or null if no mesh is under the pointer
  37929. */
  37930. getPointerOverMesh(): Nullable<AbstractMesh>;
  37931. /** @hidden */
  37932. _rebuildGeometries(): void;
  37933. /** @hidden */
  37934. _rebuildTextures(): void;
  37935. private _getByTags;
  37936. /**
  37937. * Get a list of meshes by tags
  37938. * @param tagsQuery defines the tags query to use
  37939. * @param forEach defines a predicate used to filter results
  37940. * @returns an array of Mesh
  37941. */
  37942. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37943. /**
  37944. * Get a list of cameras by tags
  37945. * @param tagsQuery defines the tags query to use
  37946. * @param forEach defines a predicate used to filter results
  37947. * @returns an array of Camera
  37948. */
  37949. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37950. /**
  37951. * Get a list of lights by tags
  37952. * @param tagsQuery defines the tags query to use
  37953. * @param forEach defines a predicate used to filter results
  37954. * @returns an array of Light
  37955. */
  37956. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37957. /**
  37958. * Get a list of materials by tags
  37959. * @param tagsQuery defines the tags query to use
  37960. * @param forEach defines a predicate used to filter results
  37961. * @returns an array of Material
  37962. */
  37963. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37964. /**
  37965. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37966. * This allowed control for front to back rendering or reversly depending of the special needs.
  37967. *
  37968. * @param renderingGroupId The rendering group id corresponding to its index
  37969. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37970. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37971. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37972. */
  37973. 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;
  37974. /**
  37975. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37976. *
  37977. * @param renderingGroupId The rendering group id corresponding to its index
  37978. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37979. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37980. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37981. */
  37982. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37983. /**
  37984. * Gets the current auto clear configuration for one rendering group of the rendering
  37985. * manager.
  37986. * @param index the rendering group index to get the information for
  37987. * @returns The auto clear setup for the requested rendering group
  37988. */
  37989. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37990. private _blockMaterialDirtyMechanism;
  37991. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37992. get blockMaterialDirtyMechanism(): boolean;
  37993. set blockMaterialDirtyMechanism(value: boolean);
  37994. /**
  37995. * Will flag all materials as dirty to trigger new shader compilation
  37996. * @param flag defines the flag used to specify which material part must be marked as dirty
  37997. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37998. */
  37999. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38000. /** @hidden */
  38001. _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;
  38002. /** @hidden */
  38003. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38004. /** @hidden */
  38005. _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;
  38006. /** @hidden */
  38007. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38008. /** @hidden */
  38009. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38010. /** @hidden */
  38011. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38012. }
  38013. }
  38014. declare module "babylonjs/assetContainer" {
  38015. import { AbstractScene } from "babylonjs/abstractScene";
  38016. import { Scene } from "babylonjs/scene";
  38017. import { Mesh } from "babylonjs/Meshes/mesh";
  38018. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38019. import { Skeleton } from "babylonjs/Bones/skeleton";
  38020. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38021. import { Animatable } from "babylonjs/Animations/animatable";
  38022. import { Nullable } from "babylonjs/types";
  38023. import { Node } from "babylonjs/node";
  38024. /**
  38025. * Set of assets to keep when moving a scene into an asset container.
  38026. */
  38027. export class KeepAssets extends AbstractScene {
  38028. }
  38029. /**
  38030. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38031. */
  38032. export class InstantiatedEntries {
  38033. /**
  38034. * List of new root nodes (eg. nodes with no parent)
  38035. */
  38036. rootNodes: TransformNode[];
  38037. /**
  38038. * List of new skeletons
  38039. */
  38040. skeletons: Skeleton[];
  38041. /**
  38042. * List of new animation groups
  38043. */
  38044. animationGroups: AnimationGroup[];
  38045. }
  38046. /**
  38047. * Container with a set of assets that can be added or removed from a scene.
  38048. */
  38049. export class AssetContainer extends AbstractScene {
  38050. private _wasAddedToScene;
  38051. /**
  38052. * The scene the AssetContainer belongs to.
  38053. */
  38054. scene: Scene;
  38055. /**
  38056. * Instantiates an AssetContainer.
  38057. * @param scene The scene the AssetContainer belongs to.
  38058. */
  38059. constructor(scene: Scene);
  38060. /**
  38061. * Instantiate or clone all meshes and add the new ones to the scene.
  38062. * Skeletons and animation groups will all be cloned
  38063. * @param nameFunction defines an optional function used to get new names for clones
  38064. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38065. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38066. */
  38067. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38068. /**
  38069. * Adds all the assets from the container to the scene.
  38070. */
  38071. addAllToScene(): void;
  38072. /**
  38073. * Removes all the assets in the container from the scene
  38074. */
  38075. removeAllFromScene(): void;
  38076. /**
  38077. * Disposes all the assets in the container
  38078. */
  38079. dispose(): void;
  38080. private _moveAssets;
  38081. /**
  38082. * Removes all the assets contained in the scene and adds them to the container.
  38083. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38084. */
  38085. moveAllFromScene(keepAssets?: KeepAssets): void;
  38086. /**
  38087. * 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.
  38088. * @returns the root mesh
  38089. */
  38090. createRootMesh(): Mesh;
  38091. /**
  38092. * Merge animations from this asset container into a scene
  38093. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38094. * @param animatables set of animatables to retarget to a node from the scene
  38095. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38096. */
  38097. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38098. }
  38099. }
  38100. declare module "babylonjs/abstractScene" {
  38101. import { Scene } from "babylonjs/scene";
  38102. import { Nullable } from "babylonjs/types";
  38103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38104. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38105. import { Geometry } from "babylonjs/Meshes/geometry";
  38106. import { Skeleton } from "babylonjs/Bones/skeleton";
  38107. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38108. import { AssetContainer } from "babylonjs/assetContainer";
  38109. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38110. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38111. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38112. import { Material } from "babylonjs/Materials/material";
  38113. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38114. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38115. import { Camera } from "babylonjs/Cameras/camera";
  38116. import { Light } from "babylonjs/Lights/light";
  38117. import { Node } from "babylonjs/node";
  38118. import { Animation } from "babylonjs/Animations/animation";
  38119. /**
  38120. * Defines how the parser contract is defined.
  38121. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38122. */
  38123. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38124. /**
  38125. * Defines how the individual parser contract is defined.
  38126. * These parser can parse an individual asset
  38127. */
  38128. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38129. /**
  38130. * Base class of the scene acting as a container for the different elements composing a scene.
  38131. * This class is dynamically extended by the different components of the scene increasing
  38132. * flexibility and reducing coupling
  38133. */
  38134. export abstract class AbstractScene {
  38135. /**
  38136. * Stores the list of available parsers in the application.
  38137. */
  38138. private static _BabylonFileParsers;
  38139. /**
  38140. * Stores the list of available individual parsers in the application.
  38141. */
  38142. private static _IndividualBabylonFileParsers;
  38143. /**
  38144. * Adds a parser in the list of available ones
  38145. * @param name Defines the name of the parser
  38146. * @param parser Defines the parser to add
  38147. */
  38148. static AddParser(name: string, parser: BabylonFileParser): void;
  38149. /**
  38150. * Gets a general parser from the list of avaialble ones
  38151. * @param name Defines the name of the parser
  38152. * @returns the requested parser or null
  38153. */
  38154. static GetParser(name: string): Nullable<BabylonFileParser>;
  38155. /**
  38156. * Adds n individual parser in the list of available ones
  38157. * @param name Defines the name of the parser
  38158. * @param parser Defines the parser to add
  38159. */
  38160. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38161. /**
  38162. * Gets an individual parser from the list of avaialble ones
  38163. * @param name Defines the name of the parser
  38164. * @returns the requested parser or null
  38165. */
  38166. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38167. /**
  38168. * Parser json data and populate both a scene and its associated container object
  38169. * @param jsonData Defines the data to parse
  38170. * @param scene Defines the scene to parse the data for
  38171. * @param container Defines the container attached to the parsing sequence
  38172. * @param rootUrl Defines the root url of the data
  38173. */
  38174. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38175. /**
  38176. * Gets the list of root nodes (ie. nodes with no parent)
  38177. */
  38178. rootNodes: Node[];
  38179. /** All of the cameras added to this scene
  38180. * @see http://doc.babylonjs.com/babylon101/cameras
  38181. */
  38182. cameras: Camera[];
  38183. /**
  38184. * All of the lights added to this scene
  38185. * @see http://doc.babylonjs.com/babylon101/lights
  38186. */
  38187. lights: Light[];
  38188. /**
  38189. * All of the (abstract) meshes added to this scene
  38190. */
  38191. meshes: AbstractMesh[];
  38192. /**
  38193. * The list of skeletons added to the scene
  38194. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38195. */
  38196. skeletons: Skeleton[];
  38197. /**
  38198. * All of the particle systems added to this scene
  38199. * @see http://doc.babylonjs.com/babylon101/particles
  38200. */
  38201. particleSystems: IParticleSystem[];
  38202. /**
  38203. * Gets a list of Animations associated with the scene
  38204. */
  38205. animations: Animation[];
  38206. /**
  38207. * All of the animation groups added to this scene
  38208. * @see http://doc.babylonjs.com/how_to/group
  38209. */
  38210. animationGroups: AnimationGroup[];
  38211. /**
  38212. * All of the multi-materials added to this scene
  38213. * @see http://doc.babylonjs.com/how_to/multi_materials
  38214. */
  38215. multiMaterials: MultiMaterial[];
  38216. /**
  38217. * All of the materials added to this scene
  38218. * In the context of a Scene, it is not supposed to be modified manually.
  38219. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38220. * Note also that the order of the Material within the array is not significant and might change.
  38221. * @see http://doc.babylonjs.com/babylon101/materials
  38222. */
  38223. materials: Material[];
  38224. /**
  38225. * The list of morph target managers added to the scene
  38226. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38227. */
  38228. morphTargetManagers: MorphTargetManager[];
  38229. /**
  38230. * The list of geometries used in the scene.
  38231. */
  38232. geometries: Geometry[];
  38233. /**
  38234. * All of the tranform nodes added to this scene
  38235. * In the context of a Scene, it is not supposed to be modified manually.
  38236. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38237. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38238. * @see http://doc.babylonjs.com/how_to/transformnode
  38239. */
  38240. transformNodes: TransformNode[];
  38241. /**
  38242. * ActionManagers available on the scene.
  38243. */
  38244. actionManagers: AbstractActionManager[];
  38245. /**
  38246. * Textures to keep.
  38247. */
  38248. textures: BaseTexture[];
  38249. /**
  38250. * Environment texture for the scene
  38251. */
  38252. environmentTexture: Nullable<BaseTexture>;
  38253. /**
  38254. * @returns all meshes, lights, cameras, transformNodes and bones
  38255. */
  38256. getNodes(): Array<Node>;
  38257. }
  38258. }
  38259. declare module "babylonjs/Audio/sound" {
  38260. import { Observable } from "babylonjs/Misc/observable";
  38261. import { Vector3 } from "babylonjs/Maths/math.vector";
  38262. import { Nullable } from "babylonjs/types";
  38263. import { Scene } from "babylonjs/scene";
  38264. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38265. /**
  38266. * Interface used to define options for Sound class
  38267. */
  38268. export interface ISoundOptions {
  38269. /**
  38270. * Does the sound autoplay once loaded.
  38271. */
  38272. autoplay?: boolean;
  38273. /**
  38274. * Does the sound loop after it finishes playing once.
  38275. */
  38276. loop?: boolean;
  38277. /**
  38278. * Sound's volume
  38279. */
  38280. volume?: number;
  38281. /**
  38282. * Is it a spatial sound?
  38283. */
  38284. spatialSound?: boolean;
  38285. /**
  38286. * Maximum distance to hear that sound
  38287. */
  38288. maxDistance?: number;
  38289. /**
  38290. * Uses user defined attenuation function
  38291. */
  38292. useCustomAttenuation?: boolean;
  38293. /**
  38294. * Define the roll off factor of spatial sounds.
  38295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38296. */
  38297. rolloffFactor?: number;
  38298. /**
  38299. * Define the reference distance the sound should be heard perfectly.
  38300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38301. */
  38302. refDistance?: number;
  38303. /**
  38304. * Define the distance attenuation model the sound will follow.
  38305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38306. */
  38307. distanceModel?: string;
  38308. /**
  38309. * Defines the playback speed (1 by default)
  38310. */
  38311. playbackRate?: number;
  38312. /**
  38313. * Defines if the sound is from a streaming source
  38314. */
  38315. streaming?: boolean;
  38316. /**
  38317. * Defines an optional length (in seconds) inside the sound file
  38318. */
  38319. length?: number;
  38320. /**
  38321. * Defines an optional offset (in seconds) inside the sound file
  38322. */
  38323. offset?: number;
  38324. /**
  38325. * If true, URLs will not be required to state the audio file codec to use.
  38326. */
  38327. skipCodecCheck?: boolean;
  38328. }
  38329. /**
  38330. * Defines a sound that can be played in the application.
  38331. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38332. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38333. */
  38334. export class Sound {
  38335. /**
  38336. * The name of the sound in the scene.
  38337. */
  38338. name: string;
  38339. /**
  38340. * Does the sound autoplay once loaded.
  38341. */
  38342. autoplay: boolean;
  38343. /**
  38344. * Does the sound loop after it finishes playing once.
  38345. */
  38346. loop: boolean;
  38347. /**
  38348. * Does the sound use a custom attenuation curve to simulate the falloff
  38349. * happening when the source gets further away from the camera.
  38350. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38351. */
  38352. useCustomAttenuation: boolean;
  38353. /**
  38354. * The sound track id this sound belongs to.
  38355. */
  38356. soundTrackId: number;
  38357. /**
  38358. * Is this sound currently played.
  38359. */
  38360. isPlaying: boolean;
  38361. /**
  38362. * Is this sound currently paused.
  38363. */
  38364. isPaused: boolean;
  38365. /**
  38366. * Does this sound enables spatial sound.
  38367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38368. */
  38369. spatialSound: boolean;
  38370. /**
  38371. * Define the reference distance the sound should be heard perfectly.
  38372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38373. */
  38374. refDistance: number;
  38375. /**
  38376. * Define the roll off factor of spatial sounds.
  38377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38378. */
  38379. rolloffFactor: number;
  38380. /**
  38381. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38382. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38383. */
  38384. maxDistance: number;
  38385. /**
  38386. * Define the distance attenuation model the sound will follow.
  38387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38388. */
  38389. distanceModel: string;
  38390. /**
  38391. * @hidden
  38392. * Back Compat
  38393. **/
  38394. onended: () => any;
  38395. /**
  38396. * Observable event when the current playing sound finishes.
  38397. */
  38398. onEndedObservable: Observable<Sound>;
  38399. private _panningModel;
  38400. private _playbackRate;
  38401. private _streaming;
  38402. private _startTime;
  38403. private _startOffset;
  38404. private _position;
  38405. /** @hidden */
  38406. _positionInEmitterSpace: boolean;
  38407. private _localDirection;
  38408. private _volume;
  38409. private _isReadyToPlay;
  38410. private _isDirectional;
  38411. private _readyToPlayCallback;
  38412. private _audioBuffer;
  38413. private _soundSource;
  38414. private _streamingSource;
  38415. private _soundPanner;
  38416. private _soundGain;
  38417. private _inputAudioNode;
  38418. private _outputAudioNode;
  38419. private _coneInnerAngle;
  38420. private _coneOuterAngle;
  38421. private _coneOuterGain;
  38422. private _scene;
  38423. private _connectedTransformNode;
  38424. private _customAttenuationFunction;
  38425. private _registerFunc;
  38426. private _isOutputConnected;
  38427. private _htmlAudioElement;
  38428. private _urlType;
  38429. private _length?;
  38430. private _offset?;
  38431. /** @hidden */
  38432. static _SceneComponentInitialization: (scene: Scene) => void;
  38433. /**
  38434. * Create a sound and attach it to a scene
  38435. * @param name Name of your sound
  38436. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38437. * @param scene defines the scene the sound belongs to
  38438. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38439. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38440. */
  38441. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38442. /**
  38443. * Release the sound and its associated resources
  38444. */
  38445. dispose(): void;
  38446. /**
  38447. * Gets if the sounds is ready to be played or not.
  38448. * @returns true if ready, otherwise false
  38449. */
  38450. isReady(): boolean;
  38451. private _soundLoaded;
  38452. /**
  38453. * Sets the data of the sound from an audiobuffer
  38454. * @param audioBuffer The audioBuffer containing the data
  38455. */
  38456. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38457. /**
  38458. * Updates the current sounds options such as maxdistance, loop...
  38459. * @param options A JSON object containing values named as the object properties
  38460. */
  38461. updateOptions(options: ISoundOptions): void;
  38462. private _createSpatialParameters;
  38463. private _updateSpatialParameters;
  38464. /**
  38465. * Switch the panning model to HRTF:
  38466. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38468. */
  38469. switchPanningModelToHRTF(): void;
  38470. /**
  38471. * Switch the panning model to Equal Power:
  38472. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38474. */
  38475. switchPanningModelToEqualPower(): void;
  38476. private _switchPanningModel;
  38477. /**
  38478. * Connect this sound to a sound track audio node like gain...
  38479. * @param soundTrackAudioNode the sound track audio node to connect to
  38480. */
  38481. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38482. /**
  38483. * Transform this sound into a directional source
  38484. * @param coneInnerAngle Size of the inner cone in degree
  38485. * @param coneOuterAngle Size of the outer cone in degree
  38486. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38487. */
  38488. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38489. /**
  38490. * Gets or sets the inner angle for the directional cone.
  38491. */
  38492. get directionalConeInnerAngle(): number;
  38493. /**
  38494. * Gets or sets the inner angle for the directional cone.
  38495. */
  38496. set directionalConeInnerAngle(value: number);
  38497. /**
  38498. * Gets or sets the outer angle for the directional cone.
  38499. */
  38500. get directionalConeOuterAngle(): number;
  38501. /**
  38502. * Gets or sets the outer angle for the directional cone.
  38503. */
  38504. set directionalConeOuterAngle(value: number);
  38505. /**
  38506. * Sets the position of the emitter if spatial sound is enabled
  38507. * @param newPosition Defines the new posisiton
  38508. */
  38509. setPosition(newPosition: Vector3): void;
  38510. /**
  38511. * Sets the local direction of the emitter if spatial sound is enabled
  38512. * @param newLocalDirection Defines the new local direction
  38513. */
  38514. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38515. private _updateDirection;
  38516. /** @hidden */
  38517. updateDistanceFromListener(): void;
  38518. /**
  38519. * Sets a new custom attenuation function for the sound.
  38520. * @param callback Defines the function used for the attenuation
  38521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38522. */
  38523. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38524. /**
  38525. * Play the sound
  38526. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38527. * @param offset (optional) Start the sound at a specific time in seconds
  38528. * @param length (optional) Sound duration (in seconds)
  38529. */
  38530. play(time?: number, offset?: number, length?: number): void;
  38531. private _onended;
  38532. /**
  38533. * Stop the sound
  38534. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38535. */
  38536. stop(time?: number): void;
  38537. /**
  38538. * Put the sound in pause
  38539. */
  38540. pause(): void;
  38541. /**
  38542. * Sets a dedicated volume for this sounds
  38543. * @param newVolume Define the new volume of the sound
  38544. * @param time Define time for gradual change to new volume
  38545. */
  38546. setVolume(newVolume: number, time?: number): void;
  38547. /**
  38548. * Set the sound play back rate
  38549. * @param newPlaybackRate Define the playback rate the sound should be played at
  38550. */
  38551. setPlaybackRate(newPlaybackRate: number): void;
  38552. /**
  38553. * Gets the volume of the sound.
  38554. * @returns the volume of the sound
  38555. */
  38556. getVolume(): number;
  38557. /**
  38558. * Attach the sound to a dedicated mesh
  38559. * @param transformNode The transform node to connect the sound with
  38560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38561. */
  38562. attachToMesh(transformNode: TransformNode): void;
  38563. /**
  38564. * Detach the sound from the previously attached mesh
  38565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38566. */
  38567. detachFromMesh(): void;
  38568. private _onRegisterAfterWorldMatrixUpdate;
  38569. /**
  38570. * Clone the current sound in the scene.
  38571. * @returns the new sound clone
  38572. */
  38573. clone(): Nullable<Sound>;
  38574. /**
  38575. * Gets the current underlying audio buffer containing the data
  38576. * @returns the audio buffer
  38577. */
  38578. getAudioBuffer(): Nullable<AudioBuffer>;
  38579. /**
  38580. * Serializes the Sound in a JSON representation
  38581. * @returns the JSON representation of the sound
  38582. */
  38583. serialize(): any;
  38584. /**
  38585. * Parse a JSON representation of a sound to innstantiate in a given scene
  38586. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38587. * @param scene Define the scene the new parsed sound should be created in
  38588. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38589. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38590. * @returns the newly parsed sound
  38591. */
  38592. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38593. }
  38594. }
  38595. declare module "babylonjs/Actions/directAudioActions" {
  38596. import { Action } from "babylonjs/Actions/action";
  38597. import { Condition } from "babylonjs/Actions/condition";
  38598. import { Sound } from "babylonjs/Audio/sound";
  38599. /**
  38600. * This defines an action helpful to play a defined sound on a triggered action.
  38601. */
  38602. export class PlaySoundAction extends Action {
  38603. private _sound;
  38604. /**
  38605. * Instantiate the action
  38606. * @param triggerOptions defines the trigger options
  38607. * @param sound defines the sound to play
  38608. * @param condition defines the trigger related conditions
  38609. */
  38610. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38611. /** @hidden */
  38612. _prepare(): void;
  38613. /**
  38614. * Execute the action and play the sound.
  38615. */
  38616. execute(): void;
  38617. /**
  38618. * Serializes the actions and its related information.
  38619. * @param parent defines the object to serialize in
  38620. * @returns the serialized object
  38621. */
  38622. serialize(parent: any): any;
  38623. }
  38624. /**
  38625. * This defines an action helpful to stop a defined sound on a triggered action.
  38626. */
  38627. export class StopSoundAction extends Action {
  38628. private _sound;
  38629. /**
  38630. * Instantiate the action
  38631. * @param triggerOptions defines the trigger options
  38632. * @param sound defines the sound to stop
  38633. * @param condition defines the trigger related conditions
  38634. */
  38635. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38636. /** @hidden */
  38637. _prepare(): void;
  38638. /**
  38639. * Execute the action and stop the sound.
  38640. */
  38641. execute(): void;
  38642. /**
  38643. * Serializes the actions and its related information.
  38644. * @param parent defines the object to serialize in
  38645. * @returns the serialized object
  38646. */
  38647. serialize(parent: any): any;
  38648. }
  38649. }
  38650. declare module "babylonjs/Actions/interpolateValueAction" {
  38651. import { Action } from "babylonjs/Actions/action";
  38652. import { Condition } from "babylonjs/Actions/condition";
  38653. import { Observable } from "babylonjs/Misc/observable";
  38654. /**
  38655. * This defines an action responsible to change the value of a property
  38656. * by interpolating between its current value and the newly set one once triggered.
  38657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38658. */
  38659. export class InterpolateValueAction extends Action {
  38660. /**
  38661. * Defines the path of the property where the value should be interpolated
  38662. */
  38663. propertyPath: string;
  38664. /**
  38665. * Defines the target value at the end of the interpolation.
  38666. */
  38667. value: any;
  38668. /**
  38669. * Defines the time it will take for the property to interpolate to the value.
  38670. */
  38671. duration: number;
  38672. /**
  38673. * Defines if the other scene animations should be stopped when the action has been triggered
  38674. */
  38675. stopOtherAnimations?: boolean;
  38676. /**
  38677. * Defines a callback raised once the interpolation animation has been done.
  38678. */
  38679. onInterpolationDone?: () => void;
  38680. /**
  38681. * Observable triggered once the interpolation animation has been done.
  38682. */
  38683. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38684. private _target;
  38685. private _effectiveTarget;
  38686. private _property;
  38687. /**
  38688. * Instantiate the action
  38689. * @param triggerOptions defines the trigger options
  38690. * @param target defines the object containing the value to interpolate
  38691. * @param propertyPath defines the path to the property in the target object
  38692. * @param value defines the target value at the end of the interpolation
  38693. * @param duration deines the time it will take for the property to interpolate to the value.
  38694. * @param condition defines the trigger related conditions
  38695. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38696. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38697. */
  38698. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38699. /** @hidden */
  38700. _prepare(): void;
  38701. /**
  38702. * Execute the action starts the value interpolation.
  38703. */
  38704. execute(): void;
  38705. /**
  38706. * Serializes the actions and its related information.
  38707. * @param parent defines the object to serialize in
  38708. * @returns the serialized object
  38709. */
  38710. serialize(parent: any): any;
  38711. }
  38712. }
  38713. declare module "babylonjs/Actions/index" {
  38714. export * from "babylonjs/Actions/abstractActionManager";
  38715. export * from "babylonjs/Actions/action";
  38716. export * from "babylonjs/Actions/actionEvent";
  38717. export * from "babylonjs/Actions/actionManager";
  38718. export * from "babylonjs/Actions/condition";
  38719. export * from "babylonjs/Actions/directActions";
  38720. export * from "babylonjs/Actions/directAudioActions";
  38721. export * from "babylonjs/Actions/interpolateValueAction";
  38722. }
  38723. declare module "babylonjs/Animations/index" {
  38724. export * from "babylonjs/Animations/animatable";
  38725. export * from "babylonjs/Animations/animation";
  38726. export * from "babylonjs/Animations/animationGroup";
  38727. export * from "babylonjs/Animations/animationPropertiesOverride";
  38728. export * from "babylonjs/Animations/easing";
  38729. export * from "babylonjs/Animations/runtimeAnimation";
  38730. export * from "babylonjs/Animations/animationEvent";
  38731. export * from "babylonjs/Animations/animationGroup";
  38732. export * from "babylonjs/Animations/animationKey";
  38733. export * from "babylonjs/Animations/animationRange";
  38734. export * from "babylonjs/Animations/animatable.interface";
  38735. }
  38736. declare module "babylonjs/Audio/soundTrack" {
  38737. import { Sound } from "babylonjs/Audio/sound";
  38738. import { Analyser } from "babylonjs/Audio/analyser";
  38739. import { Scene } from "babylonjs/scene";
  38740. /**
  38741. * Options allowed during the creation of a sound track.
  38742. */
  38743. export interface ISoundTrackOptions {
  38744. /**
  38745. * The volume the sound track should take during creation
  38746. */
  38747. volume?: number;
  38748. /**
  38749. * Define if the sound track is the main sound track of the scene
  38750. */
  38751. mainTrack?: boolean;
  38752. }
  38753. /**
  38754. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38755. * It will be also used in a future release to apply effects on a specific track.
  38756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38757. */
  38758. export class SoundTrack {
  38759. /**
  38760. * The unique identifier of the sound track in the scene.
  38761. */
  38762. id: number;
  38763. /**
  38764. * The list of sounds included in the sound track.
  38765. */
  38766. soundCollection: Array<Sound>;
  38767. private _outputAudioNode;
  38768. private _scene;
  38769. private _connectedAnalyser;
  38770. private _options;
  38771. private _isInitialized;
  38772. /**
  38773. * Creates a new sound track.
  38774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38775. * @param scene Define the scene the sound track belongs to
  38776. * @param options
  38777. */
  38778. constructor(scene: Scene, options?: ISoundTrackOptions);
  38779. private _initializeSoundTrackAudioGraph;
  38780. /**
  38781. * Release the sound track and its associated resources
  38782. */
  38783. dispose(): void;
  38784. /**
  38785. * Adds a sound to this sound track
  38786. * @param sound define the cound to add
  38787. * @ignoreNaming
  38788. */
  38789. AddSound(sound: Sound): void;
  38790. /**
  38791. * Removes a sound to this sound track
  38792. * @param sound define the cound to remove
  38793. * @ignoreNaming
  38794. */
  38795. RemoveSound(sound: Sound): void;
  38796. /**
  38797. * Set a global volume for the full sound track.
  38798. * @param newVolume Define the new volume of the sound track
  38799. */
  38800. setVolume(newVolume: number): void;
  38801. /**
  38802. * Switch the panning model to HRTF:
  38803. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38805. */
  38806. switchPanningModelToHRTF(): void;
  38807. /**
  38808. * Switch the panning model to Equal Power:
  38809. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38811. */
  38812. switchPanningModelToEqualPower(): void;
  38813. /**
  38814. * Connect the sound track to an audio analyser allowing some amazing
  38815. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38817. * @param analyser The analyser to connect to the engine
  38818. */
  38819. connectToAnalyser(analyser: Analyser): void;
  38820. }
  38821. }
  38822. declare module "babylonjs/Audio/audioSceneComponent" {
  38823. import { Sound } from "babylonjs/Audio/sound";
  38824. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38825. import { Nullable } from "babylonjs/types";
  38826. import { Vector3 } from "babylonjs/Maths/math.vector";
  38827. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38828. import { Scene } from "babylonjs/scene";
  38829. import { AbstractScene } from "babylonjs/abstractScene";
  38830. import "babylonjs/Audio/audioEngine";
  38831. module "babylonjs/abstractScene" {
  38832. interface AbstractScene {
  38833. /**
  38834. * The list of sounds used in the scene.
  38835. */
  38836. sounds: Nullable<Array<Sound>>;
  38837. }
  38838. }
  38839. module "babylonjs/scene" {
  38840. interface Scene {
  38841. /**
  38842. * @hidden
  38843. * Backing field
  38844. */
  38845. _mainSoundTrack: SoundTrack;
  38846. /**
  38847. * The main sound track played by the scene.
  38848. * It cotains your primary collection of sounds.
  38849. */
  38850. mainSoundTrack: SoundTrack;
  38851. /**
  38852. * The list of sound tracks added to the scene
  38853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38854. */
  38855. soundTracks: Nullable<Array<SoundTrack>>;
  38856. /**
  38857. * Gets a sound using a given name
  38858. * @param name defines the name to search for
  38859. * @return the found sound or null if not found at all.
  38860. */
  38861. getSoundByName(name: string): Nullable<Sound>;
  38862. /**
  38863. * Gets or sets if audio support is enabled
  38864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38865. */
  38866. audioEnabled: boolean;
  38867. /**
  38868. * Gets or sets if audio will be output to headphones
  38869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38870. */
  38871. headphone: boolean;
  38872. /**
  38873. * Gets or sets custom audio listener position provider
  38874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38875. */
  38876. audioListenerPositionProvider: Nullable<() => Vector3>;
  38877. /**
  38878. * Gets or sets a refresh rate when using 3D audio positioning
  38879. */
  38880. audioPositioningRefreshRate: number;
  38881. }
  38882. }
  38883. /**
  38884. * Defines the sound scene component responsible to manage any sounds
  38885. * in a given scene.
  38886. */
  38887. export class AudioSceneComponent implements ISceneSerializableComponent {
  38888. /**
  38889. * The component name helpfull to identify the component in the list of scene components.
  38890. */
  38891. readonly name: string;
  38892. /**
  38893. * The scene the component belongs to.
  38894. */
  38895. scene: Scene;
  38896. private _audioEnabled;
  38897. /**
  38898. * Gets whether audio is enabled or not.
  38899. * Please use related enable/disable method to switch state.
  38900. */
  38901. get audioEnabled(): boolean;
  38902. private _headphone;
  38903. /**
  38904. * Gets whether audio is outputing to headphone or not.
  38905. * Please use the according Switch methods to change output.
  38906. */
  38907. get headphone(): boolean;
  38908. /**
  38909. * Gets or sets a refresh rate when using 3D audio positioning
  38910. */
  38911. audioPositioningRefreshRate: number;
  38912. private _audioListenerPositionProvider;
  38913. /**
  38914. * Gets the current audio listener position provider
  38915. */
  38916. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38917. /**
  38918. * Sets a custom listener position for all sounds in the scene
  38919. * By default, this is the position of the first active camera
  38920. */
  38921. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38922. /**
  38923. * Creates a new instance of the component for the given scene
  38924. * @param scene Defines the scene to register the component in
  38925. */
  38926. constructor(scene: Scene);
  38927. /**
  38928. * Registers the component in a given scene
  38929. */
  38930. register(): void;
  38931. /**
  38932. * Rebuilds the elements related to this component in case of
  38933. * context lost for instance.
  38934. */
  38935. rebuild(): void;
  38936. /**
  38937. * Serializes the component data to the specified json object
  38938. * @param serializationObject The object to serialize to
  38939. */
  38940. serialize(serializationObject: any): void;
  38941. /**
  38942. * Adds all the elements from the container to the scene
  38943. * @param container the container holding the elements
  38944. */
  38945. addFromContainer(container: AbstractScene): void;
  38946. /**
  38947. * Removes all the elements in the container from the scene
  38948. * @param container contains the elements to remove
  38949. * @param dispose if the removed element should be disposed (default: false)
  38950. */
  38951. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38952. /**
  38953. * Disposes the component and the associated ressources.
  38954. */
  38955. dispose(): void;
  38956. /**
  38957. * Disables audio in the associated scene.
  38958. */
  38959. disableAudio(): void;
  38960. /**
  38961. * Enables audio in the associated scene.
  38962. */
  38963. enableAudio(): void;
  38964. /**
  38965. * Switch audio to headphone output.
  38966. */
  38967. switchAudioModeForHeadphones(): void;
  38968. /**
  38969. * Switch audio to normal speakers.
  38970. */
  38971. switchAudioModeForNormalSpeakers(): void;
  38972. private _cachedCameraDirection;
  38973. private _cachedCameraPosition;
  38974. private _lastCheck;
  38975. private _afterRender;
  38976. }
  38977. }
  38978. declare module "babylonjs/Audio/weightedsound" {
  38979. import { Sound } from "babylonjs/Audio/sound";
  38980. /**
  38981. * Wraps one or more Sound objects and selects one with random weight for playback.
  38982. */
  38983. export class WeightedSound {
  38984. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38985. loop: boolean;
  38986. private _coneInnerAngle;
  38987. private _coneOuterAngle;
  38988. private _volume;
  38989. /** A Sound is currently playing. */
  38990. isPlaying: boolean;
  38991. /** A Sound is currently paused. */
  38992. isPaused: boolean;
  38993. private _sounds;
  38994. private _weights;
  38995. private _currentIndex?;
  38996. /**
  38997. * Creates a new WeightedSound from the list of sounds given.
  38998. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38999. * @param sounds Array of Sounds that will be selected from.
  39000. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39001. */
  39002. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39003. /**
  39004. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39005. */
  39006. get directionalConeInnerAngle(): number;
  39007. /**
  39008. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39009. */
  39010. set directionalConeInnerAngle(value: number);
  39011. /**
  39012. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39013. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39014. */
  39015. get directionalConeOuterAngle(): number;
  39016. /**
  39017. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39018. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39019. */
  39020. set directionalConeOuterAngle(value: number);
  39021. /**
  39022. * Playback volume.
  39023. */
  39024. get volume(): number;
  39025. /**
  39026. * Playback volume.
  39027. */
  39028. set volume(value: number);
  39029. private _onended;
  39030. /**
  39031. * Suspend playback
  39032. */
  39033. pause(): void;
  39034. /**
  39035. * Stop playback
  39036. */
  39037. stop(): void;
  39038. /**
  39039. * Start playback.
  39040. * @param startOffset Position the clip head at a specific time in seconds.
  39041. */
  39042. play(startOffset?: number): void;
  39043. }
  39044. }
  39045. declare module "babylonjs/Audio/index" {
  39046. export * from "babylonjs/Audio/analyser";
  39047. export * from "babylonjs/Audio/audioEngine";
  39048. export * from "babylonjs/Audio/audioSceneComponent";
  39049. export * from "babylonjs/Audio/sound";
  39050. export * from "babylonjs/Audio/soundTrack";
  39051. export * from "babylonjs/Audio/weightedsound";
  39052. }
  39053. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39054. import { Behavior } from "babylonjs/Behaviors/behavior";
  39055. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39056. import { BackEase } from "babylonjs/Animations/easing";
  39057. /**
  39058. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39059. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39060. */
  39061. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39062. /**
  39063. * Gets the name of the behavior.
  39064. */
  39065. get name(): string;
  39066. /**
  39067. * The easing function used by animations
  39068. */
  39069. static EasingFunction: BackEase;
  39070. /**
  39071. * The easing mode used by animations
  39072. */
  39073. static EasingMode: number;
  39074. /**
  39075. * The duration of the animation, in milliseconds
  39076. */
  39077. transitionDuration: number;
  39078. /**
  39079. * Length of the distance animated by the transition when lower radius is reached
  39080. */
  39081. lowerRadiusTransitionRange: number;
  39082. /**
  39083. * Length of the distance animated by the transition when upper radius is reached
  39084. */
  39085. upperRadiusTransitionRange: number;
  39086. private _autoTransitionRange;
  39087. /**
  39088. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39089. */
  39090. get autoTransitionRange(): boolean;
  39091. /**
  39092. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39093. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39094. */
  39095. set autoTransitionRange(value: boolean);
  39096. private _attachedCamera;
  39097. private _onAfterCheckInputsObserver;
  39098. private _onMeshTargetChangedObserver;
  39099. /**
  39100. * Initializes the behavior.
  39101. */
  39102. init(): void;
  39103. /**
  39104. * Attaches the behavior to its arc rotate camera.
  39105. * @param camera Defines the camera to attach the behavior to
  39106. */
  39107. attach(camera: ArcRotateCamera): void;
  39108. /**
  39109. * Detaches the behavior from its current arc rotate camera.
  39110. */
  39111. detach(): void;
  39112. private _radiusIsAnimating;
  39113. private _radiusBounceTransition;
  39114. private _animatables;
  39115. private _cachedWheelPrecision;
  39116. /**
  39117. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39118. * @param radiusLimit The limit to check against.
  39119. * @return Bool to indicate if at limit.
  39120. */
  39121. private _isRadiusAtLimit;
  39122. /**
  39123. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39124. * @param radiusDelta The delta by which to animate to. Can be negative.
  39125. */
  39126. private _applyBoundRadiusAnimation;
  39127. /**
  39128. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39129. */
  39130. protected _clearAnimationLocks(): void;
  39131. /**
  39132. * Stops and removes all animations that have been applied to the camera
  39133. */
  39134. stopAllAnimations(): void;
  39135. }
  39136. }
  39137. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39138. import { Behavior } from "babylonjs/Behaviors/behavior";
  39139. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39140. import { ExponentialEase } from "babylonjs/Animations/easing";
  39141. import { Nullable } from "babylonjs/types";
  39142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39143. import { Vector3 } from "babylonjs/Maths/math.vector";
  39144. /**
  39145. * 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.
  39146. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39147. */
  39148. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39149. /**
  39150. * Gets the name of the behavior.
  39151. */
  39152. get name(): string;
  39153. private _mode;
  39154. private _radiusScale;
  39155. private _positionScale;
  39156. private _defaultElevation;
  39157. private _elevationReturnTime;
  39158. private _elevationReturnWaitTime;
  39159. private _zoomStopsAnimation;
  39160. private _framingTime;
  39161. /**
  39162. * The easing function used by animations
  39163. */
  39164. static EasingFunction: ExponentialEase;
  39165. /**
  39166. * The easing mode used by animations
  39167. */
  39168. static EasingMode: number;
  39169. /**
  39170. * Sets the current mode used by the behavior
  39171. */
  39172. set mode(mode: number);
  39173. /**
  39174. * Gets current mode used by the behavior.
  39175. */
  39176. get mode(): number;
  39177. /**
  39178. * Sets the scale applied to the radius (1 by default)
  39179. */
  39180. set radiusScale(radius: number);
  39181. /**
  39182. * Gets the scale applied to the radius
  39183. */
  39184. get radiusScale(): number;
  39185. /**
  39186. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39187. */
  39188. set positionScale(scale: number);
  39189. /**
  39190. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39191. */
  39192. get positionScale(): number;
  39193. /**
  39194. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39195. * behaviour is triggered, in radians.
  39196. */
  39197. set defaultElevation(elevation: number);
  39198. /**
  39199. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39200. * behaviour is triggered, in radians.
  39201. */
  39202. get defaultElevation(): number;
  39203. /**
  39204. * Sets the time (in milliseconds) taken to return to the default beta position.
  39205. * Negative value indicates camera should not return to default.
  39206. */
  39207. set elevationReturnTime(speed: number);
  39208. /**
  39209. * Gets the time (in milliseconds) taken to return to the default beta position.
  39210. * Negative value indicates camera should not return to default.
  39211. */
  39212. get elevationReturnTime(): number;
  39213. /**
  39214. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39215. */
  39216. set elevationReturnWaitTime(time: number);
  39217. /**
  39218. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39219. */
  39220. get elevationReturnWaitTime(): number;
  39221. /**
  39222. * Sets the flag that indicates if user zooming should stop animation.
  39223. */
  39224. set zoomStopsAnimation(flag: boolean);
  39225. /**
  39226. * Gets the flag that indicates if user zooming should stop animation.
  39227. */
  39228. get zoomStopsAnimation(): boolean;
  39229. /**
  39230. * Sets the transition time when framing the mesh, in milliseconds
  39231. */
  39232. set framingTime(time: number);
  39233. /**
  39234. * Gets the transition time when framing the mesh, in milliseconds
  39235. */
  39236. get framingTime(): number;
  39237. /**
  39238. * Define if the behavior should automatically change the configured
  39239. * camera limits and sensibilities.
  39240. */
  39241. autoCorrectCameraLimitsAndSensibility: boolean;
  39242. private _onPrePointerObservableObserver;
  39243. private _onAfterCheckInputsObserver;
  39244. private _onMeshTargetChangedObserver;
  39245. private _attachedCamera;
  39246. private _isPointerDown;
  39247. private _lastInteractionTime;
  39248. /**
  39249. * Initializes the behavior.
  39250. */
  39251. init(): void;
  39252. /**
  39253. * Attaches the behavior to its arc rotate camera.
  39254. * @param camera Defines the camera to attach the behavior to
  39255. */
  39256. attach(camera: ArcRotateCamera): void;
  39257. /**
  39258. * Detaches the behavior from its current arc rotate camera.
  39259. */
  39260. detach(): void;
  39261. private _animatables;
  39262. private _betaIsAnimating;
  39263. private _betaTransition;
  39264. private _radiusTransition;
  39265. private _vectorTransition;
  39266. /**
  39267. * Targets the given mesh and updates zoom level accordingly.
  39268. * @param mesh The mesh to target.
  39269. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39270. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39271. */
  39272. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39273. /**
  39274. * Targets the given mesh with its children and updates zoom level accordingly.
  39275. * @param mesh The mesh to target.
  39276. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39277. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39278. */
  39279. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39280. /**
  39281. * Targets the given meshes with their children and updates zoom level accordingly.
  39282. * @param meshes The mesh to target.
  39283. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39284. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39285. */
  39286. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39287. /**
  39288. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39289. * @param minimumWorld Determines the smaller position of the bounding box extend
  39290. * @param maximumWorld Determines the bigger position of the bounding box extend
  39291. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39292. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39293. */
  39294. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39295. /**
  39296. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39297. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39298. * frustum width.
  39299. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39300. * to fully enclose the mesh in the viewing frustum.
  39301. */
  39302. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39303. /**
  39304. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39305. * is automatically returned to its default position (expected to be above ground plane).
  39306. */
  39307. private _maintainCameraAboveGround;
  39308. /**
  39309. * Returns the frustum slope based on the canvas ratio and camera FOV
  39310. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39311. */
  39312. private _getFrustumSlope;
  39313. /**
  39314. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39315. */
  39316. private _clearAnimationLocks;
  39317. /**
  39318. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39319. */
  39320. private _applyUserInteraction;
  39321. /**
  39322. * Stops and removes all animations that have been applied to the camera
  39323. */
  39324. stopAllAnimations(): void;
  39325. /**
  39326. * Gets a value indicating if the user is moving the camera
  39327. */
  39328. get isUserIsMoving(): boolean;
  39329. /**
  39330. * The camera can move all the way towards the mesh.
  39331. */
  39332. static IgnoreBoundsSizeMode: number;
  39333. /**
  39334. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39335. */
  39336. static FitFrustumSidesMode: number;
  39337. }
  39338. }
  39339. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39340. import { Nullable } from "babylonjs/types";
  39341. import { Camera } from "babylonjs/Cameras/camera";
  39342. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39343. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39344. /**
  39345. * Base class for Camera Pointer Inputs.
  39346. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39347. * for example usage.
  39348. */
  39349. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39350. /**
  39351. * Defines the camera the input is attached to.
  39352. */
  39353. abstract camera: Camera;
  39354. /**
  39355. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39356. */
  39357. protected _altKey: boolean;
  39358. protected _ctrlKey: boolean;
  39359. protected _metaKey: boolean;
  39360. protected _shiftKey: boolean;
  39361. /**
  39362. * Which mouse buttons were pressed at time of last mouse event.
  39363. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39364. */
  39365. protected _buttonsPressed: number;
  39366. /**
  39367. * Defines the buttons associated with the input to handle camera move.
  39368. */
  39369. buttons: number[];
  39370. /**
  39371. * Attach the input controls to a specific dom element to get the input from.
  39372. * @param element Defines the element the controls should be listened from
  39373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39374. */
  39375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39376. /**
  39377. * Detach the current controls from the specified dom element.
  39378. * @param element Defines the element to stop listening the inputs from
  39379. */
  39380. detachControl(element: Nullable<HTMLElement>): void;
  39381. /**
  39382. * Gets the class name of the current input.
  39383. * @returns the class name
  39384. */
  39385. getClassName(): string;
  39386. /**
  39387. * Get the friendly name associated with the input class.
  39388. * @returns the input friendly name
  39389. */
  39390. getSimpleName(): string;
  39391. /**
  39392. * Called on pointer POINTERDOUBLETAP event.
  39393. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39394. */
  39395. protected onDoubleTap(type: string): void;
  39396. /**
  39397. * Called on pointer POINTERMOVE event if only a single touch is active.
  39398. * Override this method to provide functionality.
  39399. */
  39400. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39401. /**
  39402. * Called on pointer POINTERMOVE event if multiple touches are active.
  39403. * Override this method to provide functionality.
  39404. */
  39405. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39406. /**
  39407. * Called on JS contextmenu event.
  39408. * Override this method to provide functionality.
  39409. */
  39410. protected onContextMenu(evt: PointerEvent): void;
  39411. /**
  39412. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39413. * press.
  39414. * Override this method to provide functionality.
  39415. */
  39416. protected onButtonDown(evt: PointerEvent): void;
  39417. /**
  39418. * Called each time a new POINTERUP event occurs. Ie, for each button
  39419. * release.
  39420. * Override this method to provide functionality.
  39421. */
  39422. protected onButtonUp(evt: PointerEvent): void;
  39423. /**
  39424. * Called when window becomes inactive.
  39425. * Override this method to provide functionality.
  39426. */
  39427. protected onLostFocus(): void;
  39428. private _pointerInput;
  39429. private _observer;
  39430. private _onLostFocus;
  39431. private pointA;
  39432. private pointB;
  39433. }
  39434. }
  39435. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39436. import { Nullable } from "babylonjs/types";
  39437. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39438. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39439. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39440. /**
  39441. * Manage the pointers inputs to control an arc rotate camera.
  39442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39443. */
  39444. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39445. /**
  39446. * Defines the camera the input is attached to.
  39447. */
  39448. camera: ArcRotateCamera;
  39449. /**
  39450. * Gets the class name of the current input.
  39451. * @returns the class name
  39452. */
  39453. getClassName(): string;
  39454. /**
  39455. * Defines the buttons associated with the input to handle camera move.
  39456. */
  39457. buttons: number[];
  39458. /**
  39459. * Defines the pointer angular sensibility along the X axis or how fast is
  39460. * the camera rotating.
  39461. */
  39462. angularSensibilityX: number;
  39463. /**
  39464. * Defines the pointer angular sensibility along the Y axis or how fast is
  39465. * the camera rotating.
  39466. */
  39467. angularSensibilityY: number;
  39468. /**
  39469. * Defines the pointer pinch precision or how fast is the camera zooming.
  39470. */
  39471. pinchPrecision: number;
  39472. /**
  39473. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39474. * from 0.
  39475. * It defines the percentage of current camera.radius to use as delta when
  39476. * pinch zoom is used.
  39477. */
  39478. pinchDeltaPercentage: number;
  39479. /**
  39480. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39481. * that any object in the plane at the camera's target point will scale
  39482. * perfectly with finger motion.
  39483. * Overrides pinchDeltaPercentage and pinchPrecision.
  39484. */
  39485. useNaturalPinchZoom: boolean;
  39486. /**
  39487. * Defines the pointer panning sensibility or how fast is the camera moving.
  39488. */
  39489. panningSensibility: number;
  39490. /**
  39491. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39492. */
  39493. multiTouchPanning: boolean;
  39494. /**
  39495. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39496. * zoom (pinch) through multitouch.
  39497. */
  39498. multiTouchPanAndZoom: boolean;
  39499. /**
  39500. * Revers pinch action direction.
  39501. */
  39502. pinchInwards: boolean;
  39503. private _isPanClick;
  39504. private _twoFingerActivityCount;
  39505. private _isPinching;
  39506. /**
  39507. * Called on pointer POINTERMOVE event if only a single touch is active.
  39508. */
  39509. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39510. /**
  39511. * Called on pointer POINTERDOUBLETAP event.
  39512. */
  39513. protected onDoubleTap(type: string): void;
  39514. /**
  39515. * Called on pointer POINTERMOVE event if multiple touches are active.
  39516. */
  39517. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39518. /**
  39519. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39520. * press.
  39521. */
  39522. protected onButtonDown(evt: PointerEvent): void;
  39523. /**
  39524. * Called each time a new POINTERUP event occurs. Ie, for each button
  39525. * release.
  39526. */
  39527. protected onButtonUp(evt: PointerEvent): void;
  39528. /**
  39529. * Called when window becomes inactive.
  39530. */
  39531. protected onLostFocus(): void;
  39532. }
  39533. }
  39534. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39535. import { Nullable } from "babylonjs/types";
  39536. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39537. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39538. /**
  39539. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39541. */
  39542. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39543. /**
  39544. * Defines the camera the input is attached to.
  39545. */
  39546. camera: ArcRotateCamera;
  39547. /**
  39548. * Defines the list of key codes associated with the up action (increase alpha)
  39549. */
  39550. keysUp: number[];
  39551. /**
  39552. * Defines the list of key codes associated with the down action (decrease alpha)
  39553. */
  39554. keysDown: number[];
  39555. /**
  39556. * Defines the list of key codes associated with the left action (increase beta)
  39557. */
  39558. keysLeft: number[];
  39559. /**
  39560. * Defines the list of key codes associated with the right action (decrease beta)
  39561. */
  39562. keysRight: number[];
  39563. /**
  39564. * Defines the list of key codes associated with the reset action.
  39565. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39566. */
  39567. keysReset: number[];
  39568. /**
  39569. * Defines the panning sensibility of the inputs.
  39570. * (How fast is the camera panning)
  39571. */
  39572. panningSensibility: number;
  39573. /**
  39574. * Defines the zooming sensibility of the inputs.
  39575. * (How fast is the camera zooming)
  39576. */
  39577. zoomingSensibility: number;
  39578. /**
  39579. * Defines whether maintaining the alt key down switch the movement mode from
  39580. * orientation to zoom.
  39581. */
  39582. useAltToZoom: boolean;
  39583. /**
  39584. * Rotation speed of the camera
  39585. */
  39586. angularSpeed: number;
  39587. private _keys;
  39588. private _ctrlPressed;
  39589. private _altPressed;
  39590. private _onCanvasBlurObserver;
  39591. private _onKeyboardObserver;
  39592. private _engine;
  39593. private _scene;
  39594. /**
  39595. * Attach the input controls to a specific dom element to get the input from.
  39596. * @param element Defines the element the controls should be listened from
  39597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39598. */
  39599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39600. /**
  39601. * Detach the current controls from the specified dom element.
  39602. * @param element Defines the element to stop listening the inputs from
  39603. */
  39604. detachControl(element: Nullable<HTMLElement>): void;
  39605. /**
  39606. * Update the current camera state depending on the inputs that have been used this frame.
  39607. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39608. */
  39609. checkInputs(): void;
  39610. /**
  39611. * Gets the class name of the current intput.
  39612. * @returns the class name
  39613. */
  39614. getClassName(): string;
  39615. /**
  39616. * Get the friendly name associated with the input class.
  39617. * @returns the input friendly name
  39618. */
  39619. getSimpleName(): string;
  39620. }
  39621. }
  39622. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39623. import { Nullable } from "babylonjs/types";
  39624. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39625. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39626. /**
  39627. * Manage the mouse wheel inputs to control an arc rotate camera.
  39628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39629. */
  39630. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39631. /**
  39632. * Defines the camera the input is attached to.
  39633. */
  39634. camera: ArcRotateCamera;
  39635. /**
  39636. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39637. */
  39638. wheelPrecision: number;
  39639. /**
  39640. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39641. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39642. */
  39643. wheelDeltaPercentage: number;
  39644. private _wheel;
  39645. private _observer;
  39646. private computeDeltaFromMouseWheelLegacyEvent;
  39647. /**
  39648. * Attach the input controls to a specific dom element to get the input from.
  39649. * @param element Defines the element the controls should be listened from
  39650. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39651. */
  39652. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39653. /**
  39654. * Detach the current controls from the specified dom element.
  39655. * @param element Defines the element to stop listening the inputs from
  39656. */
  39657. detachControl(element: Nullable<HTMLElement>): void;
  39658. /**
  39659. * Gets the class name of the current intput.
  39660. * @returns the class name
  39661. */
  39662. getClassName(): string;
  39663. /**
  39664. * Get the friendly name associated with the input class.
  39665. * @returns the input friendly name
  39666. */
  39667. getSimpleName(): string;
  39668. }
  39669. }
  39670. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39671. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39672. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39673. /**
  39674. * Default Inputs manager for the ArcRotateCamera.
  39675. * It groups all the default supported inputs for ease of use.
  39676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39677. */
  39678. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39679. /**
  39680. * Instantiates a new ArcRotateCameraInputsManager.
  39681. * @param camera Defines the camera the inputs belong to
  39682. */
  39683. constructor(camera: ArcRotateCamera);
  39684. /**
  39685. * Add mouse wheel input support to the input manager.
  39686. * @returns the current input manager
  39687. */
  39688. addMouseWheel(): ArcRotateCameraInputsManager;
  39689. /**
  39690. * Add pointers input support to the input manager.
  39691. * @returns the current input manager
  39692. */
  39693. addPointers(): ArcRotateCameraInputsManager;
  39694. /**
  39695. * Add keyboard input support to the input manager.
  39696. * @returns the current input manager
  39697. */
  39698. addKeyboard(): ArcRotateCameraInputsManager;
  39699. }
  39700. }
  39701. declare module "babylonjs/Cameras/arcRotateCamera" {
  39702. import { Observable } from "babylonjs/Misc/observable";
  39703. import { Nullable } from "babylonjs/types";
  39704. import { Scene } from "babylonjs/scene";
  39705. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39707. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39708. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39709. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39710. import { Camera } from "babylonjs/Cameras/camera";
  39711. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39712. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39713. import { Collider } from "babylonjs/Collisions/collider";
  39714. /**
  39715. * This represents an orbital type of camera.
  39716. *
  39717. * 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.
  39718. * 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.
  39719. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39720. */
  39721. export class ArcRotateCamera extends TargetCamera {
  39722. /**
  39723. * Defines the rotation angle of the camera along the longitudinal axis.
  39724. */
  39725. alpha: number;
  39726. /**
  39727. * Defines the rotation angle of the camera along the latitudinal axis.
  39728. */
  39729. beta: number;
  39730. /**
  39731. * Defines the radius of the camera from it s target point.
  39732. */
  39733. radius: number;
  39734. protected _target: Vector3;
  39735. protected _targetHost: Nullable<AbstractMesh>;
  39736. /**
  39737. * Defines the target point of the camera.
  39738. * The camera looks towards it form the radius distance.
  39739. */
  39740. get target(): Vector3;
  39741. set target(value: Vector3);
  39742. /**
  39743. * Define the current local position of the camera in the scene
  39744. */
  39745. get position(): Vector3;
  39746. set position(newPosition: Vector3);
  39747. protected _upVector: Vector3;
  39748. protected _upToYMatrix: Matrix;
  39749. protected _YToUpMatrix: Matrix;
  39750. /**
  39751. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39752. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39753. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39754. */
  39755. set upVector(vec: Vector3);
  39756. get upVector(): Vector3;
  39757. /**
  39758. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39759. */
  39760. setMatUp(): void;
  39761. /**
  39762. * Current inertia value on the longitudinal axis.
  39763. * The bigger this number the longer it will take for the camera to stop.
  39764. */
  39765. inertialAlphaOffset: number;
  39766. /**
  39767. * Current inertia value on the latitudinal axis.
  39768. * The bigger this number the longer it will take for the camera to stop.
  39769. */
  39770. inertialBetaOffset: number;
  39771. /**
  39772. * Current inertia value on the radius axis.
  39773. * The bigger this number the longer it will take for the camera to stop.
  39774. */
  39775. inertialRadiusOffset: number;
  39776. /**
  39777. * Minimum allowed angle on the longitudinal axis.
  39778. * This can help limiting how the Camera is able to move in the scene.
  39779. */
  39780. lowerAlphaLimit: Nullable<number>;
  39781. /**
  39782. * Maximum allowed angle on the longitudinal axis.
  39783. * This can help limiting how the Camera is able to move in the scene.
  39784. */
  39785. upperAlphaLimit: Nullable<number>;
  39786. /**
  39787. * Minimum allowed angle on the latitudinal axis.
  39788. * This can help limiting how the Camera is able to move in the scene.
  39789. */
  39790. lowerBetaLimit: number;
  39791. /**
  39792. * Maximum allowed angle on the latitudinal axis.
  39793. * This can help limiting how the Camera is able to move in the scene.
  39794. */
  39795. upperBetaLimit: number;
  39796. /**
  39797. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39798. * This can help limiting how the Camera is able to move in the scene.
  39799. */
  39800. lowerRadiusLimit: Nullable<number>;
  39801. /**
  39802. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39803. * This can help limiting how the Camera is able to move in the scene.
  39804. */
  39805. upperRadiusLimit: Nullable<number>;
  39806. /**
  39807. * Defines the current inertia value used during panning of the camera along the X axis.
  39808. */
  39809. inertialPanningX: number;
  39810. /**
  39811. * Defines the current inertia value used during panning of the camera along the Y axis.
  39812. */
  39813. inertialPanningY: number;
  39814. /**
  39815. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39816. * Basically if your fingers moves away from more than this distance you will be considered
  39817. * in pinch mode.
  39818. */
  39819. pinchToPanMaxDistance: number;
  39820. /**
  39821. * Defines the maximum distance the camera can pan.
  39822. * This could help keeping the cammera always in your scene.
  39823. */
  39824. panningDistanceLimit: Nullable<number>;
  39825. /**
  39826. * Defines the target of the camera before paning.
  39827. */
  39828. panningOriginTarget: Vector3;
  39829. /**
  39830. * Defines the value of the inertia used during panning.
  39831. * 0 would mean stop inertia and one would mean no decelleration at all.
  39832. */
  39833. panningInertia: number;
  39834. /**
  39835. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39836. */
  39837. get angularSensibilityX(): number;
  39838. set angularSensibilityX(value: number);
  39839. /**
  39840. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39841. */
  39842. get angularSensibilityY(): number;
  39843. set angularSensibilityY(value: number);
  39844. /**
  39845. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39846. */
  39847. get pinchPrecision(): number;
  39848. set pinchPrecision(value: number);
  39849. /**
  39850. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39851. * It will be used instead of pinchDeltaPrecision if different from 0.
  39852. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39853. */
  39854. get pinchDeltaPercentage(): number;
  39855. set pinchDeltaPercentage(value: number);
  39856. /**
  39857. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39858. * and pinch delta percentage.
  39859. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39860. * that any object in the plane at the camera's target point will scale
  39861. * perfectly with finger motion.
  39862. */
  39863. get useNaturalPinchZoom(): boolean;
  39864. set useNaturalPinchZoom(value: boolean);
  39865. /**
  39866. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39867. */
  39868. get panningSensibility(): number;
  39869. set panningSensibility(value: number);
  39870. /**
  39871. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39872. */
  39873. get keysUp(): number[];
  39874. set keysUp(value: number[]);
  39875. /**
  39876. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39877. */
  39878. get keysDown(): number[];
  39879. set keysDown(value: number[]);
  39880. /**
  39881. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39882. */
  39883. get keysLeft(): number[];
  39884. set keysLeft(value: number[]);
  39885. /**
  39886. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39887. */
  39888. get keysRight(): number[];
  39889. set keysRight(value: number[]);
  39890. /**
  39891. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39892. */
  39893. get wheelPrecision(): number;
  39894. set wheelPrecision(value: number);
  39895. /**
  39896. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39897. * It will be used instead of pinchDeltaPrecision if different from 0.
  39898. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39899. */
  39900. get wheelDeltaPercentage(): number;
  39901. set wheelDeltaPercentage(value: number);
  39902. /**
  39903. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39904. */
  39905. zoomOnFactor: number;
  39906. /**
  39907. * Defines a screen offset for the camera position.
  39908. */
  39909. targetScreenOffset: Vector2;
  39910. /**
  39911. * Allows the camera to be completely reversed.
  39912. * If false the camera can not arrive upside down.
  39913. */
  39914. allowUpsideDown: boolean;
  39915. /**
  39916. * Define if double tap/click is used to restore the previously saved state of the camera.
  39917. */
  39918. useInputToRestoreState: boolean;
  39919. /** @hidden */
  39920. _viewMatrix: Matrix;
  39921. /** @hidden */
  39922. _useCtrlForPanning: boolean;
  39923. /** @hidden */
  39924. _panningMouseButton: number;
  39925. /**
  39926. * Defines the input associated to the camera.
  39927. */
  39928. inputs: ArcRotateCameraInputsManager;
  39929. /** @hidden */
  39930. _reset: () => void;
  39931. /**
  39932. * Defines the allowed panning axis.
  39933. */
  39934. panningAxis: Vector3;
  39935. protected _localDirection: Vector3;
  39936. protected _transformedDirection: Vector3;
  39937. private _bouncingBehavior;
  39938. /**
  39939. * Gets the bouncing behavior of the camera if it has been enabled.
  39940. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39941. */
  39942. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39943. /**
  39944. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39945. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39946. */
  39947. get useBouncingBehavior(): boolean;
  39948. set useBouncingBehavior(value: boolean);
  39949. private _framingBehavior;
  39950. /**
  39951. * Gets the framing behavior of the camera if it has been enabled.
  39952. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39953. */
  39954. get framingBehavior(): Nullable<FramingBehavior>;
  39955. /**
  39956. * Defines if the framing behavior of the camera is enabled on the camera.
  39957. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39958. */
  39959. get useFramingBehavior(): boolean;
  39960. set useFramingBehavior(value: boolean);
  39961. private _autoRotationBehavior;
  39962. /**
  39963. * Gets the auto rotation behavior of the camera if it has been enabled.
  39964. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39965. */
  39966. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39967. /**
  39968. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39969. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39970. */
  39971. get useAutoRotationBehavior(): boolean;
  39972. set useAutoRotationBehavior(value: boolean);
  39973. /**
  39974. * Observable triggered when the mesh target has been changed on the camera.
  39975. */
  39976. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39977. /**
  39978. * Event raised when the camera is colliding with a mesh.
  39979. */
  39980. onCollide: (collidedMesh: AbstractMesh) => void;
  39981. /**
  39982. * Defines whether the camera should check collision with the objects oh the scene.
  39983. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39984. */
  39985. checkCollisions: boolean;
  39986. /**
  39987. * Defines the collision radius of the camera.
  39988. * This simulates a sphere around the camera.
  39989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39990. */
  39991. collisionRadius: Vector3;
  39992. protected _collider: Collider;
  39993. protected _previousPosition: Vector3;
  39994. protected _collisionVelocity: Vector3;
  39995. protected _newPosition: Vector3;
  39996. protected _previousAlpha: number;
  39997. protected _previousBeta: number;
  39998. protected _previousRadius: number;
  39999. protected _collisionTriggered: boolean;
  40000. protected _targetBoundingCenter: Nullable<Vector3>;
  40001. private _computationVector;
  40002. /**
  40003. * Instantiates a new ArcRotateCamera in a given scene
  40004. * @param name Defines the name of the camera
  40005. * @param alpha Defines the camera rotation along the logitudinal axis
  40006. * @param beta Defines the camera rotation along the latitudinal axis
  40007. * @param radius Defines the camera distance from its target
  40008. * @param target Defines the camera target
  40009. * @param scene Defines the scene the camera belongs to
  40010. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40011. */
  40012. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40013. /** @hidden */
  40014. _initCache(): void;
  40015. /** @hidden */
  40016. _updateCache(ignoreParentClass?: boolean): void;
  40017. protected _getTargetPosition(): Vector3;
  40018. private _storedAlpha;
  40019. private _storedBeta;
  40020. private _storedRadius;
  40021. private _storedTarget;
  40022. private _storedTargetScreenOffset;
  40023. /**
  40024. * Stores the current state of the camera (alpha, beta, radius and target)
  40025. * @returns the camera itself
  40026. */
  40027. storeState(): Camera;
  40028. /**
  40029. * @hidden
  40030. * Restored camera state. You must call storeState() first
  40031. */
  40032. _restoreStateValues(): boolean;
  40033. /** @hidden */
  40034. _isSynchronizedViewMatrix(): boolean;
  40035. /**
  40036. * Attached controls to the current camera.
  40037. * @param element Defines the element the controls should be listened from
  40038. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40039. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40040. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40041. */
  40042. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40043. /**
  40044. * Detach the current controls from the camera.
  40045. * The camera will stop reacting to inputs.
  40046. * @param element Defines the element to stop listening the inputs from
  40047. */
  40048. detachControl(element: HTMLElement): void;
  40049. /** @hidden */
  40050. _checkInputs(): void;
  40051. protected _checkLimits(): void;
  40052. /**
  40053. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40054. */
  40055. rebuildAnglesAndRadius(): void;
  40056. /**
  40057. * Use a position to define the current camera related information like alpha, beta and radius
  40058. * @param position Defines the position to set the camera at
  40059. */
  40060. setPosition(position: Vector3): void;
  40061. /**
  40062. * Defines the target the camera should look at.
  40063. * This will automatically adapt alpha beta and radius to fit within the new target.
  40064. * @param target Defines the new target as a Vector or a mesh
  40065. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40066. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40067. */
  40068. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40069. /** @hidden */
  40070. _getViewMatrix(): Matrix;
  40071. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40072. /**
  40073. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40074. * @param meshes Defines the mesh to zoom on
  40075. * @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)
  40076. */
  40077. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40078. /**
  40079. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40080. * The target will be changed but the radius
  40081. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40082. * @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)
  40083. */
  40084. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40085. min: Vector3;
  40086. max: Vector3;
  40087. distance: number;
  40088. }, doNotUpdateMaxZ?: boolean): void;
  40089. /**
  40090. * @override
  40091. * Override Camera.createRigCamera
  40092. */
  40093. createRigCamera(name: string, cameraIndex: number): Camera;
  40094. /**
  40095. * @hidden
  40096. * @override
  40097. * Override Camera._updateRigCameras
  40098. */
  40099. _updateRigCameras(): void;
  40100. /**
  40101. * Destroy the camera and release the current resources hold by it.
  40102. */
  40103. dispose(): void;
  40104. /**
  40105. * Gets the current object class name.
  40106. * @return the class name
  40107. */
  40108. getClassName(): string;
  40109. }
  40110. }
  40111. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40112. import { Behavior } from "babylonjs/Behaviors/behavior";
  40113. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40114. /**
  40115. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40117. */
  40118. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40119. /**
  40120. * Gets the name of the behavior.
  40121. */
  40122. get name(): string;
  40123. private _zoomStopsAnimation;
  40124. private _idleRotationSpeed;
  40125. private _idleRotationWaitTime;
  40126. private _idleRotationSpinupTime;
  40127. /**
  40128. * Sets the flag that indicates if user zooming should stop animation.
  40129. */
  40130. set zoomStopsAnimation(flag: boolean);
  40131. /**
  40132. * Gets the flag that indicates if user zooming should stop animation.
  40133. */
  40134. get zoomStopsAnimation(): boolean;
  40135. /**
  40136. * Sets the default speed at which the camera rotates around the model.
  40137. */
  40138. set idleRotationSpeed(speed: number);
  40139. /**
  40140. * Gets the default speed at which the camera rotates around the model.
  40141. */
  40142. get idleRotationSpeed(): number;
  40143. /**
  40144. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40145. */
  40146. set idleRotationWaitTime(time: number);
  40147. /**
  40148. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40149. */
  40150. get idleRotationWaitTime(): number;
  40151. /**
  40152. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40153. */
  40154. set idleRotationSpinupTime(time: number);
  40155. /**
  40156. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40157. */
  40158. get idleRotationSpinupTime(): number;
  40159. /**
  40160. * Gets a value indicating if the camera is currently rotating because of this behavior
  40161. */
  40162. get rotationInProgress(): boolean;
  40163. private _onPrePointerObservableObserver;
  40164. private _onAfterCheckInputsObserver;
  40165. private _attachedCamera;
  40166. private _isPointerDown;
  40167. private _lastFrameTime;
  40168. private _lastInteractionTime;
  40169. private _cameraRotationSpeed;
  40170. /**
  40171. * Initializes the behavior.
  40172. */
  40173. init(): void;
  40174. /**
  40175. * Attaches the behavior to its arc rotate camera.
  40176. * @param camera Defines the camera to attach the behavior to
  40177. */
  40178. attach(camera: ArcRotateCamera): void;
  40179. /**
  40180. * Detaches the behavior from its current arc rotate camera.
  40181. */
  40182. detach(): void;
  40183. /**
  40184. * Returns true if user is scrolling.
  40185. * @return true if user is scrolling.
  40186. */
  40187. private _userIsZooming;
  40188. private _lastFrameRadius;
  40189. private _shouldAnimationStopForInteraction;
  40190. /**
  40191. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40192. */
  40193. private _applyUserInteraction;
  40194. private _userIsMoving;
  40195. }
  40196. }
  40197. declare module "babylonjs/Behaviors/Cameras/index" {
  40198. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40199. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40200. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40201. }
  40202. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40203. import { Mesh } from "babylonjs/Meshes/mesh";
  40204. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40205. import { Behavior } from "babylonjs/Behaviors/behavior";
  40206. /**
  40207. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40208. */
  40209. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40210. private ui;
  40211. /**
  40212. * The name of the behavior
  40213. */
  40214. name: string;
  40215. /**
  40216. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40217. */
  40218. distanceAwayFromFace: number;
  40219. /**
  40220. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40221. */
  40222. distanceAwayFromBottomOfFace: number;
  40223. private _faceVectors;
  40224. private _target;
  40225. private _scene;
  40226. private _onRenderObserver;
  40227. private _tmpMatrix;
  40228. private _tmpVector;
  40229. /**
  40230. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40231. * @param ui The transform node that should be attched to the mesh
  40232. */
  40233. constructor(ui: TransformNode);
  40234. /**
  40235. * Initializes the behavior
  40236. */
  40237. init(): void;
  40238. private _closestFace;
  40239. private _zeroVector;
  40240. private _lookAtTmpMatrix;
  40241. private _lookAtToRef;
  40242. /**
  40243. * Attaches the AttachToBoxBehavior to the passed in mesh
  40244. * @param target The mesh that the specified node will be attached to
  40245. */
  40246. attach(target: Mesh): void;
  40247. /**
  40248. * Detaches the behavior from the mesh
  40249. */
  40250. detach(): void;
  40251. }
  40252. }
  40253. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40254. import { Behavior } from "babylonjs/Behaviors/behavior";
  40255. import { Mesh } from "babylonjs/Meshes/mesh";
  40256. /**
  40257. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40258. */
  40259. export class FadeInOutBehavior implements Behavior<Mesh> {
  40260. /**
  40261. * Time in milliseconds to delay before fading in (Default: 0)
  40262. */
  40263. delay: number;
  40264. /**
  40265. * Time in milliseconds for the mesh to fade in (Default: 300)
  40266. */
  40267. fadeInTime: number;
  40268. private _millisecondsPerFrame;
  40269. private _hovered;
  40270. private _hoverValue;
  40271. private _ownerNode;
  40272. /**
  40273. * Instatiates the FadeInOutBehavior
  40274. */
  40275. constructor();
  40276. /**
  40277. * The name of the behavior
  40278. */
  40279. get name(): string;
  40280. /**
  40281. * Initializes the behavior
  40282. */
  40283. init(): void;
  40284. /**
  40285. * Attaches the fade behavior on the passed in mesh
  40286. * @param ownerNode The mesh that will be faded in/out once attached
  40287. */
  40288. attach(ownerNode: Mesh): void;
  40289. /**
  40290. * Detaches the behavior from the mesh
  40291. */
  40292. detach(): void;
  40293. /**
  40294. * Triggers the mesh to begin fading in or out
  40295. * @param value if the object should fade in or out (true to fade in)
  40296. */
  40297. fadeIn(value: boolean): void;
  40298. private _update;
  40299. private _setAllVisibility;
  40300. }
  40301. }
  40302. declare module "babylonjs/Misc/pivotTools" {
  40303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40304. /**
  40305. * Class containing a set of static utilities functions for managing Pivots
  40306. * @hidden
  40307. */
  40308. export class PivotTools {
  40309. private static _PivotCached;
  40310. private static _OldPivotPoint;
  40311. private static _PivotTranslation;
  40312. private static _PivotTmpVector;
  40313. /** @hidden */
  40314. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40315. /** @hidden */
  40316. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40317. }
  40318. }
  40319. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40320. import { Scene } from "babylonjs/scene";
  40321. import { Vector4 } from "babylonjs/Maths/math.vector";
  40322. import { Mesh } from "babylonjs/Meshes/mesh";
  40323. import { Nullable } from "babylonjs/types";
  40324. import { Plane } from "babylonjs/Maths/math.plane";
  40325. /**
  40326. * Class containing static functions to help procedurally build meshes
  40327. */
  40328. export class PlaneBuilder {
  40329. /**
  40330. * Creates a plane mesh
  40331. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40332. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40333. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40337. * @param name defines the name of the mesh
  40338. * @param options defines the options used to create the mesh
  40339. * @param scene defines the hosting scene
  40340. * @returns the plane mesh
  40341. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40342. */
  40343. static CreatePlane(name: string, options: {
  40344. size?: number;
  40345. width?: number;
  40346. height?: number;
  40347. sideOrientation?: number;
  40348. frontUVs?: Vector4;
  40349. backUVs?: Vector4;
  40350. updatable?: boolean;
  40351. sourcePlane?: Plane;
  40352. }, scene?: Nullable<Scene>): Mesh;
  40353. }
  40354. }
  40355. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40356. import { Behavior } from "babylonjs/Behaviors/behavior";
  40357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40358. import { Observable } from "babylonjs/Misc/observable";
  40359. import { Vector3 } from "babylonjs/Maths/math.vector";
  40360. import { Ray } from "babylonjs/Culling/ray";
  40361. import "babylonjs/Meshes/Builders/planeBuilder";
  40362. /**
  40363. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40364. */
  40365. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40366. private static _AnyMouseID;
  40367. /**
  40368. * Abstract mesh the behavior is set on
  40369. */
  40370. attachedNode: AbstractMesh;
  40371. private _dragPlane;
  40372. private _scene;
  40373. private _pointerObserver;
  40374. private _beforeRenderObserver;
  40375. private static _planeScene;
  40376. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40377. /**
  40378. * 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)
  40379. */
  40380. maxDragAngle: number;
  40381. /**
  40382. * @hidden
  40383. */
  40384. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40385. /**
  40386. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40387. */
  40388. currentDraggingPointerID: number;
  40389. /**
  40390. * The last position where the pointer hit the drag plane in world space
  40391. */
  40392. lastDragPosition: Vector3;
  40393. /**
  40394. * If the behavior is currently in a dragging state
  40395. */
  40396. dragging: boolean;
  40397. /**
  40398. * 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)
  40399. */
  40400. dragDeltaRatio: number;
  40401. /**
  40402. * If the drag plane orientation should be updated during the dragging (Default: true)
  40403. */
  40404. updateDragPlane: boolean;
  40405. private _debugMode;
  40406. private _moving;
  40407. /**
  40408. * Fires each time the attached mesh is dragged with the pointer
  40409. * * delta between last drag position and current drag position in world space
  40410. * * dragDistance along the drag axis
  40411. * * dragPlaneNormal normal of the current drag plane used during the drag
  40412. * * dragPlanePoint in world space where the drag intersects the drag plane
  40413. */
  40414. onDragObservable: Observable<{
  40415. delta: Vector3;
  40416. dragPlanePoint: Vector3;
  40417. dragPlaneNormal: Vector3;
  40418. dragDistance: number;
  40419. pointerId: number;
  40420. }>;
  40421. /**
  40422. * Fires each time a drag begins (eg. mouse down on mesh)
  40423. */
  40424. onDragStartObservable: Observable<{
  40425. dragPlanePoint: Vector3;
  40426. pointerId: number;
  40427. }>;
  40428. /**
  40429. * Fires each time a drag ends (eg. mouse release after drag)
  40430. */
  40431. onDragEndObservable: Observable<{
  40432. dragPlanePoint: Vector3;
  40433. pointerId: number;
  40434. }>;
  40435. /**
  40436. * If the attached mesh should be moved when dragged
  40437. */
  40438. moveAttached: boolean;
  40439. /**
  40440. * If the drag behavior will react to drag events (Default: true)
  40441. */
  40442. enabled: boolean;
  40443. /**
  40444. * If pointer events should start and release the drag (Default: true)
  40445. */
  40446. startAndReleaseDragOnPointerEvents: boolean;
  40447. /**
  40448. * If camera controls should be detached during the drag
  40449. */
  40450. detachCameraControls: boolean;
  40451. /**
  40452. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40453. */
  40454. useObjectOrientationForDragging: boolean;
  40455. private _options;
  40456. /**
  40457. * Gets the options used by the behavior
  40458. */
  40459. get options(): {
  40460. dragAxis?: Vector3;
  40461. dragPlaneNormal?: Vector3;
  40462. };
  40463. /**
  40464. * Sets the options used by the behavior
  40465. */
  40466. set options(options: {
  40467. dragAxis?: Vector3;
  40468. dragPlaneNormal?: Vector3;
  40469. });
  40470. /**
  40471. * Creates a pointer drag behavior that can be attached to a mesh
  40472. * @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)
  40473. */
  40474. constructor(options?: {
  40475. dragAxis?: Vector3;
  40476. dragPlaneNormal?: Vector3;
  40477. });
  40478. /**
  40479. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40480. */
  40481. validateDrag: (targetPosition: Vector3) => boolean;
  40482. /**
  40483. * The name of the behavior
  40484. */
  40485. get name(): string;
  40486. /**
  40487. * Initializes the behavior
  40488. */
  40489. init(): void;
  40490. private _tmpVector;
  40491. private _alternatePickedPoint;
  40492. private _worldDragAxis;
  40493. private _targetPosition;
  40494. private _attachedElement;
  40495. /**
  40496. * Attaches the drag behavior the passed in mesh
  40497. * @param ownerNode The mesh that will be dragged around once attached
  40498. * @param predicate Predicate to use for pick filtering
  40499. */
  40500. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40501. /**
  40502. * Force relase the drag action by code.
  40503. */
  40504. releaseDrag(): void;
  40505. private _startDragRay;
  40506. private _lastPointerRay;
  40507. /**
  40508. * Simulates the start of a pointer drag event on the behavior
  40509. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40510. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40511. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40512. */
  40513. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40514. private _startDrag;
  40515. private _dragDelta;
  40516. private _moveDrag;
  40517. private _pickWithRayOnDragPlane;
  40518. private _pointA;
  40519. private _pointB;
  40520. private _pointC;
  40521. private _lineA;
  40522. private _lineB;
  40523. private _localAxis;
  40524. private _lookAt;
  40525. private _updateDragPlanePosition;
  40526. /**
  40527. * Detaches the behavior from the mesh
  40528. */
  40529. detach(): void;
  40530. }
  40531. }
  40532. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40533. import { Mesh } from "babylonjs/Meshes/mesh";
  40534. import { Behavior } from "babylonjs/Behaviors/behavior";
  40535. /**
  40536. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40537. */
  40538. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40539. private _dragBehaviorA;
  40540. private _dragBehaviorB;
  40541. private _startDistance;
  40542. private _initialScale;
  40543. private _targetScale;
  40544. private _ownerNode;
  40545. private _sceneRenderObserver;
  40546. /**
  40547. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40548. */
  40549. constructor();
  40550. /**
  40551. * The name of the behavior
  40552. */
  40553. get name(): string;
  40554. /**
  40555. * Initializes the behavior
  40556. */
  40557. init(): void;
  40558. private _getCurrentDistance;
  40559. /**
  40560. * Attaches the scale behavior the passed in mesh
  40561. * @param ownerNode The mesh that will be scaled around once attached
  40562. */
  40563. attach(ownerNode: Mesh): void;
  40564. /**
  40565. * Detaches the behavior from the mesh
  40566. */
  40567. detach(): void;
  40568. }
  40569. }
  40570. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40571. import { Behavior } from "babylonjs/Behaviors/behavior";
  40572. import { Mesh } from "babylonjs/Meshes/mesh";
  40573. import { Observable } from "babylonjs/Misc/observable";
  40574. /**
  40575. * 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
  40576. */
  40577. export class SixDofDragBehavior implements Behavior<Mesh> {
  40578. private static _virtualScene;
  40579. private _ownerNode;
  40580. private _sceneRenderObserver;
  40581. private _scene;
  40582. private _targetPosition;
  40583. private _virtualOriginMesh;
  40584. private _virtualDragMesh;
  40585. private _pointerObserver;
  40586. private _moving;
  40587. private _startingOrientation;
  40588. /**
  40589. * 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)
  40590. */
  40591. private zDragFactor;
  40592. /**
  40593. * If the object should rotate to face the drag origin
  40594. */
  40595. rotateDraggedObject: boolean;
  40596. /**
  40597. * If the behavior is currently in a dragging state
  40598. */
  40599. dragging: boolean;
  40600. /**
  40601. * 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)
  40602. */
  40603. dragDeltaRatio: number;
  40604. /**
  40605. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40606. */
  40607. currentDraggingPointerID: number;
  40608. /**
  40609. * If camera controls should be detached during the drag
  40610. */
  40611. detachCameraControls: boolean;
  40612. /**
  40613. * Fires each time a drag starts
  40614. */
  40615. onDragStartObservable: Observable<{}>;
  40616. /**
  40617. * Fires each time a drag ends (eg. mouse release after drag)
  40618. */
  40619. onDragEndObservable: Observable<{}>;
  40620. /**
  40621. * 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
  40622. */
  40623. constructor();
  40624. /**
  40625. * The name of the behavior
  40626. */
  40627. get name(): string;
  40628. /**
  40629. * Initializes the behavior
  40630. */
  40631. init(): void;
  40632. /**
  40633. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40634. */
  40635. private get _pointerCamera();
  40636. /**
  40637. * Attaches the scale behavior the passed in mesh
  40638. * @param ownerNode The mesh that will be scaled around once attached
  40639. */
  40640. attach(ownerNode: Mesh): void;
  40641. /**
  40642. * Detaches the behavior from the mesh
  40643. */
  40644. detach(): void;
  40645. }
  40646. }
  40647. declare module "babylonjs/Behaviors/Meshes/index" {
  40648. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40649. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40650. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40651. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40652. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40653. }
  40654. declare module "babylonjs/Behaviors/index" {
  40655. export * from "babylonjs/Behaviors/behavior";
  40656. export * from "babylonjs/Behaviors/Cameras/index";
  40657. export * from "babylonjs/Behaviors/Meshes/index";
  40658. }
  40659. declare module "babylonjs/Bones/boneIKController" {
  40660. import { Bone } from "babylonjs/Bones/bone";
  40661. import { Vector3 } from "babylonjs/Maths/math.vector";
  40662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40663. import { Nullable } from "babylonjs/types";
  40664. /**
  40665. * Class used to apply inverse kinematics to bones
  40666. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40667. */
  40668. export class BoneIKController {
  40669. private static _tmpVecs;
  40670. private static _tmpQuat;
  40671. private static _tmpMats;
  40672. /**
  40673. * Gets or sets the target mesh
  40674. */
  40675. targetMesh: AbstractMesh;
  40676. /** Gets or sets the mesh used as pole */
  40677. poleTargetMesh: AbstractMesh;
  40678. /**
  40679. * Gets or sets the bone used as pole
  40680. */
  40681. poleTargetBone: Nullable<Bone>;
  40682. /**
  40683. * Gets or sets the target position
  40684. */
  40685. targetPosition: Vector3;
  40686. /**
  40687. * Gets or sets the pole target position
  40688. */
  40689. poleTargetPosition: Vector3;
  40690. /**
  40691. * Gets or sets the pole target local offset
  40692. */
  40693. poleTargetLocalOffset: Vector3;
  40694. /**
  40695. * Gets or sets the pole angle
  40696. */
  40697. poleAngle: number;
  40698. /**
  40699. * Gets or sets the mesh associated with the controller
  40700. */
  40701. mesh: AbstractMesh;
  40702. /**
  40703. * 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)
  40704. */
  40705. slerpAmount: number;
  40706. private _bone1Quat;
  40707. private _bone1Mat;
  40708. private _bone2Ang;
  40709. private _bone1;
  40710. private _bone2;
  40711. private _bone1Length;
  40712. private _bone2Length;
  40713. private _maxAngle;
  40714. private _maxReach;
  40715. private _rightHandedSystem;
  40716. private _bendAxis;
  40717. private _slerping;
  40718. private _adjustRoll;
  40719. /**
  40720. * Gets or sets maximum allowed angle
  40721. */
  40722. get maxAngle(): number;
  40723. set maxAngle(value: number);
  40724. /**
  40725. * Creates a new BoneIKController
  40726. * @param mesh defines the mesh to control
  40727. * @param bone defines the bone to control
  40728. * @param options defines options to set up the controller
  40729. */
  40730. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40731. targetMesh?: AbstractMesh;
  40732. poleTargetMesh?: AbstractMesh;
  40733. poleTargetBone?: Bone;
  40734. poleTargetLocalOffset?: Vector3;
  40735. poleAngle?: number;
  40736. bendAxis?: Vector3;
  40737. maxAngle?: number;
  40738. slerpAmount?: number;
  40739. });
  40740. private _setMaxAngle;
  40741. /**
  40742. * Force the controller to update the bones
  40743. */
  40744. update(): void;
  40745. }
  40746. }
  40747. declare module "babylonjs/Bones/boneLookController" {
  40748. import { Vector3 } from "babylonjs/Maths/math.vector";
  40749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40750. import { Bone } from "babylonjs/Bones/bone";
  40751. import { Space } from "babylonjs/Maths/math.axis";
  40752. /**
  40753. * Class used to make a bone look toward a point in space
  40754. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40755. */
  40756. export class BoneLookController {
  40757. private static _tmpVecs;
  40758. private static _tmpQuat;
  40759. private static _tmpMats;
  40760. /**
  40761. * The target Vector3 that the bone will look at
  40762. */
  40763. target: Vector3;
  40764. /**
  40765. * The mesh that the bone is attached to
  40766. */
  40767. mesh: AbstractMesh;
  40768. /**
  40769. * The bone that will be looking to the target
  40770. */
  40771. bone: Bone;
  40772. /**
  40773. * The up axis of the coordinate system that is used when the bone is rotated
  40774. */
  40775. upAxis: Vector3;
  40776. /**
  40777. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40778. */
  40779. upAxisSpace: Space;
  40780. /**
  40781. * Used to make an adjustment to the yaw of the bone
  40782. */
  40783. adjustYaw: number;
  40784. /**
  40785. * Used to make an adjustment to the pitch of the bone
  40786. */
  40787. adjustPitch: number;
  40788. /**
  40789. * Used to make an adjustment to the roll of the bone
  40790. */
  40791. adjustRoll: number;
  40792. /**
  40793. * 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)
  40794. */
  40795. slerpAmount: number;
  40796. private _minYaw;
  40797. private _maxYaw;
  40798. private _minPitch;
  40799. private _maxPitch;
  40800. private _minYawSin;
  40801. private _minYawCos;
  40802. private _maxYawSin;
  40803. private _maxYawCos;
  40804. private _midYawConstraint;
  40805. private _minPitchTan;
  40806. private _maxPitchTan;
  40807. private _boneQuat;
  40808. private _slerping;
  40809. private _transformYawPitch;
  40810. private _transformYawPitchInv;
  40811. private _firstFrameSkipped;
  40812. private _yawRange;
  40813. private _fowardAxis;
  40814. /**
  40815. * Gets or sets the minimum yaw angle that the bone can look to
  40816. */
  40817. get minYaw(): number;
  40818. set minYaw(value: number);
  40819. /**
  40820. * Gets or sets the maximum yaw angle that the bone can look to
  40821. */
  40822. get maxYaw(): number;
  40823. set maxYaw(value: number);
  40824. /**
  40825. * Gets or sets the minimum pitch angle that the bone can look to
  40826. */
  40827. get minPitch(): number;
  40828. set minPitch(value: number);
  40829. /**
  40830. * Gets or sets the maximum pitch angle that the bone can look to
  40831. */
  40832. get maxPitch(): number;
  40833. set maxPitch(value: number);
  40834. /**
  40835. * Create a BoneLookController
  40836. * @param mesh the mesh that the bone belongs to
  40837. * @param bone the bone that will be looking to the target
  40838. * @param target the target Vector3 to look at
  40839. * @param options optional settings:
  40840. * * maxYaw: the maximum angle the bone will yaw to
  40841. * * minYaw: the minimum angle the bone will yaw to
  40842. * * maxPitch: the maximum angle the bone will pitch to
  40843. * * minPitch: the minimum angle the bone will yaw to
  40844. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40845. * * upAxis: the up axis of the coordinate system
  40846. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40847. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40848. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40849. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40850. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40851. * * adjustRoll: used to make an adjustment to the roll of the bone
  40852. **/
  40853. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40854. maxYaw?: number;
  40855. minYaw?: number;
  40856. maxPitch?: number;
  40857. minPitch?: number;
  40858. slerpAmount?: number;
  40859. upAxis?: Vector3;
  40860. upAxisSpace?: Space;
  40861. yawAxis?: Vector3;
  40862. pitchAxis?: Vector3;
  40863. adjustYaw?: number;
  40864. adjustPitch?: number;
  40865. adjustRoll?: number;
  40866. });
  40867. /**
  40868. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40869. */
  40870. update(): void;
  40871. private _getAngleDiff;
  40872. private _getAngleBetween;
  40873. private _isAngleBetween;
  40874. }
  40875. }
  40876. declare module "babylonjs/Bones/index" {
  40877. export * from "babylonjs/Bones/bone";
  40878. export * from "babylonjs/Bones/boneIKController";
  40879. export * from "babylonjs/Bones/boneLookController";
  40880. export * from "babylonjs/Bones/skeleton";
  40881. }
  40882. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40883. import { Nullable } from "babylonjs/types";
  40884. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40885. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40886. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40887. /**
  40888. * Manage the gamepad inputs to control an arc rotate camera.
  40889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40890. */
  40891. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40892. /**
  40893. * Defines the camera the input is attached to.
  40894. */
  40895. camera: ArcRotateCamera;
  40896. /**
  40897. * Defines the gamepad the input is gathering event from.
  40898. */
  40899. gamepad: Nullable<Gamepad>;
  40900. /**
  40901. * Defines the gamepad rotation sensiblity.
  40902. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40903. */
  40904. gamepadRotationSensibility: number;
  40905. /**
  40906. * Defines the gamepad move sensiblity.
  40907. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40908. */
  40909. gamepadMoveSensibility: number;
  40910. private _yAxisScale;
  40911. /**
  40912. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40913. */
  40914. get invertYAxis(): boolean;
  40915. set invertYAxis(value: boolean);
  40916. private _onGamepadConnectedObserver;
  40917. private _onGamepadDisconnectedObserver;
  40918. /**
  40919. * Attach the input controls to a specific dom element to get the input from.
  40920. * @param element Defines the element the controls should be listened from
  40921. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40922. */
  40923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40924. /**
  40925. * Detach the current controls from the specified dom element.
  40926. * @param element Defines the element to stop listening the inputs from
  40927. */
  40928. detachControl(element: Nullable<HTMLElement>): void;
  40929. /**
  40930. * Update the current camera state depending on the inputs that have been used this frame.
  40931. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40932. */
  40933. checkInputs(): void;
  40934. /**
  40935. * Gets the class name of the current intput.
  40936. * @returns the class name
  40937. */
  40938. getClassName(): string;
  40939. /**
  40940. * Get the friendly name associated with the input class.
  40941. * @returns the input friendly name
  40942. */
  40943. getSimpleName(): string;
  40944. }
  40945. }
  40946. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40947. import { Nullable } from "babylonjs/types";
  40948. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40949. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40950. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40951. interface ArcRotateCameraInputsManager {
  40952. /**
  40953. * Add orientation input support to the input manager.
  40954. * @returns the current input manager
  40955. */
  40956. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40957. }
  40958. }
  40959. /**
  40960. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40961. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40962. */
  40963. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40964. /**
  40965. * Defines the camera the input is attached to.
  40966. */
  40967. camera: ArcRotateCamera;
  40968. /**
  40969. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40970. */
  40971. alphaCorrection: number;
  40972. /**
  40973. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40974. */
  40975. gammaCorrection: number;
  40976. private _alpha;
  40977. private _gamma;
  40978. private _dirty;
  40979. private _deviceOrientationHandler;
  40980. /**
  40981. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40982. */
  40983. constructor();
  40984. /**
  40985. * Attach the input controls to a specific dom element to get the input from.
  40986. * @param element Defines the element the controls should be listened from
  40987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40988. */
  40989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40990. /** @hidden */
  40991. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40992. /**
  40993. * Update the current camera state depending on the inputs that have been used this frame.
  40994. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40995. */
  40996. checkInputs(): void;
  40997. /**
  40998. * Detach the current controls from the specified dom element.
  40999. * @param element Defines the element to stop listening the inputs from
  41000. */
  41001. detachControl(element: Nullable<HTMLElement>): void;
  41002. /**
  41003. * Gets the class name of the current intput.
  41004. * @returns the class name
  41005. */
  41006. getClassName(): string;
  41007. /**
  41008. * Get the friendly name associated with the input class.
  41009. * @returns the input friendly name
  41010. */
  41011. getSimpleName(): string;
  41012. }
  41013. }
  41014. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41015. import { Nullable } from "babylonjs/types";
  41016. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41017. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41018. /**
  41019. * Listen to mouse events to control the camera.
  41020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41021. */
  41022. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41023. /**
  41024. * Defines the camera the input is attached to.
  41025. */
  41026. camera: FlyCamera;
  41027. /**
  41028. * Defines if touch is enabled. (Default is true.)
  41029. */
  41030. touchEnabled: boolean;
  41031. /**
  41032. * Defines the buttons associated with the input to handle camera rotation.
  41033. */
  41034. buttons: number[];
  41035. /**
  41036. * Assign buttons for Yaw control.
  41037. */
  41038. buttonsYaw: number[];
  41039. /**
  41040. * Assign buttons for Pitch control.
  41041. */
  41042. buttonsPitch: number[];
  41043. /**
  41044. * Assign buttons for Roll control.
  41045. */
  41046. buttonsRoll: number[];
  41047. /**
  41048. * Detect if any button is being pressed while mouse is moved.
  41049. * -1 = Mouse locked.
  41050. * 0 = Left button.
  41051. * 1 = Middle Button.
  41052. * 2 = Right Button.
  41053. */
  41054. activeButton: number;
  41055. /**
  41056. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41057. * Higher values reduce its sensitivity.
  41058. */
  41059. angularSensibility: number;
  41060. private _mousemoveCallback;
  41061. private _observer;
  41062. private _rollObserver;
  41063. private previousPosition;
  41064. private noPreventDefault;
  41065. private element;
  41066. /**
  41067. * Listen to mouse events to control the camera.
  41068. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41070. */
  41071. constructor(touchEnabled?: boolean);
  41072. /**
  41073. * Attach the mouse control to the HTML DOM element.
  41074. * @param element Defines the element that listens to the input events.
  41075. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41076. */
  41077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41078. /**
  41079. * Detach the current controls from the specified dom element.
  41080. * @param element Defines the element to stop listening the inputs from
  41081. */
  41082. detachControl(element: Nullable<HTMLElement>): void;
  41083. /**
  41084. * Gets the class name of the current input.
  41085. * @returns the class name.
  41086. */
  41087. getClassName(): string;
  41088. /**
  41089. * Get the friendly name associated with the input class.
  41090. * @returns the input's friendly name.
  41091. */
  41092. getSimpleName(): string;
  41093. private _pointerInput;
  41094. private _onMouseMove;
  41095. /**
  41096. * Rotate camera by mouse offset.
  41097. */
  41098. private rotateCamera;
  41099. }
  41100. }
  41101. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41102. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41103. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41104. /**
  41105. * Default Inputs manager for the FlyCamera.
  41106. * It groups all the default supported inputs for ease of use.
  41107. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41108. */
  41109. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41110. /**
  41111. * Instantiates a new FlyCameraInputsManager.
  41112. * @param camera Defines the camera the inputs belong to.
  41113. */
  41114. constructor(camera: FlyCamera);
  41115. /**
  41116. * Add keyboard input support to the input manager.
  41117. * @returns the new FlyCameraKeyboardMoveInput().
  41118. */
  41119. addKeyboard(): FlyCameraInputsManager;
  41120. /**
  41121. * Add mouse input support to the input manager.
  41122. * @param touchEnabled Enable touch screen support.
  41123. * @returns the new FlyCameraMouseInput().
  41124. */
  41125. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41126. }
  41127. }
  41128. declare module "babylonjs/Cameras/flyCamera" {
  41129. import { Scene } from "babylonjs/scene";
  41130. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41132. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41133. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41134. /**
  41135. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41136. * such as in a 3D Space Shooter or a Flight Simulator.
  41137. */
  41138. export class FlyCamera extends TargetCamera {
  41139. /**
  41140. * Define the collision ellipsoid of the camera.
  41141. * This is helpful for simulating a camera body, like a player's body.
  41142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41143. */
  41144. ellipsoid: Vector3;
  41145. /**
  41146. * Define an offset for the position of the ellipsoid around the camera.
  41147. * This can be helpful if the camera is attached away from the player's body center,
  41148. * such as at its head.
  41149. */
  41150. ellipsoidOffset: Vector3;
  41151. /**
  41152. * Enable or disable collisions of the camera with the rest of the scene objects.
  41153. */
  41154. checkCollisions: boolean;
  41155. /**
  41156. * Enable or disable gravity on the camera.
  41157. */
  41158. applyGravity: boolean;
  41159. /**
  41160. * Define the current direction the camera is moving to.
  41161. */
  41162. cameraDirection: Vector3;
  41163. /**
  41164. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41165. * This overrides and empties cameraRotation.
  41166. */
  41167. rotationQuaternion: Quaternion;
  41168. /**
  41169. * Track Roll to maintain the wanted Rolling when looking around.
  41170. */
  41171. _trackRoll: number;
  41172. /**
  41173. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41174. */
  41175. rollCorrect: number;
  41176. /**
  41177. * Mimic a banked turn, Rolling the camera when Yawing.
  41178. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41179. */
  41180. bankedTurn: boolean;
  41181. /**
  41182. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41183. */
  41184. bankedTurnLimit: number;
  41185. /**
  41186. * Value of 0 disables the banked Roll.
  41187. * Value of 1 is equal to the Yaw angle in radians.
  41188. */
  41189. bankedTurnMultiplier: number;
  41190. /**
  41191. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41192. */
  41193. inputs: FlyCameraInputsManager;
  41194. /**
  41195. * Gets the input sensibility for mouse input.
  41196. * Higher values reduce sensitivity.
  41197. */
  41198. get angularSensibility(): number;
  41199. /**
  41200. * Sets the input sensibility for a mouse input.
  41201. * Higher values reduce sensitivity.
  41202. */
  41203. set angularSensibility(value: number);
  41204. /**
  41205. * Get the keys for camera movement forward.
  41206. */
  41207. get keysForward(): number[];
  41208. /**
  41209. * Set the keys for camera movement forward.
  41210. */
  41211. set keysForward(value: number[]);
  41212. /**
  41213. * Get the keys for camera movement backward.
  41214. */
  41215. get keysBackward(): number[];
  41216. set keysBackward(value: number[]);
  41217. /**
  41218. * Get the keys for camera movement up.
  41219. */
  41220. get keysUp(): number[];
  41221. /**
  41222. * Set the keys for camera movement up.
  41223. */
  41224. set keysUp(value: number[]);
  41225. /**
  41226. * Get the keys for camera movement down.
  41227. */
  41228. get keysDown(): number[];
  41229. /**
  41230. * Set the keys for camera movement down.
  41231. */
  41232. set keysDown(value: number[]);
  41233. /**
  41234. * Get the keys for camera movement left.
  41235. */
  41236. get keysLeft(): number[];
  41237. /**
  41238. * Set the keys for camera movement left.
  41239. */
  41240. set keysLeft(value: number[]);
  41241. /**
  41242. * Set the keys for camera movement right.
  41243. */
  41244. get keysRight(): number[];
  41245. /**
  41246. * Set the keys for camera movement right.
  41247. */
  41248. set keysRight(value: number[]);
  41249. /**
  41250. * Event raised when the camera collides with a mesh in the scene.
  41251. */
  41252. onCollide: (collidedMesh: AbstractMesh) => void;
  41253. private _collider;
  41254. private _needMoveForGravity;
  41255. private _oldPosition;
  41256. private _diffPosition;
  41257. private _newPosition;
  41258. /** @hidden */
  41259. _localDirection: Vector3;
  41260. /** @hidden */
  41261. _transformedDirection: Vector3;
  41262. /**
  41263. * Instantiates a FlyCamera.
  41264. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41265. * such as in a 3D Space Shooter or a Flight Simulator.
  41266. * @param name Define the name of the camera in the scene.
  41267. * @param position Define the starting position of the camera in the scene.
  41268. * @param scene Define the scene the camera belongs to.
  41269. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41270. */
  41271. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41272. /**
  41273. * Attach a control to the HTML DOM element.
  41274. * @param element Defines the element that listens to the input events.
  41275. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41276. */
  41277. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41278. /**
  41279. * Detach a control from the HTML DOM element.
  41280. * The camera will stop reacting to that input.
  41281. * @param element Defines the element that listens to the input events.
  41282. */
  41283. detachControl(element: HTMLElement): void;
  41284. private _collisionMask;
  41285. /**
  41286. * Get the mask that the camera ignores in collision events.
  41287. */
  41288. get collisionMask(): number;
  41289. /**
  41290. * Set the mask that the camera ignores in collision events.
  41291. */
  41292. set collisionMask(mask: number);
  41293. /** @hidden */
  41294. _collideWithWorld(displacement: Vector3): void;
  41295. /** @hidden */
  41296. private _onCollisionPositionChange;
  41297. /** @hidden */
  41298. _checkInputs(): void;
  41299. /** @hidden */
  41300. _decideIfNeedsToMove(): boolean;
  41301. /** @hidden */
  41302. _updatePosition(): void;
  41303. /**
  41304. * Restore the Roll to its target value at the rate specified.
  41305. * @param rate - Higher means slower restoring.
  41306. * @hidden
  41307. */
  41308. restoreRoll(rate: number): void;
  41309. /**
  41310. * Destroy the camera and release the current resources held by it.
  41311. */
  41312. dispose(): void;
  41313. /**
  41314. * Get the current object class name.
  41315. * @returns the class name.
  41316. */
  41317. getClassName(): string;
  41318. }
  41319. }
  41320. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41321. import { Nullable } from "babylonjs/types";
  41322. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41323. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41324. /**
  41325. * Listen to keyboard events to control the camera.
  41326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41327. */
  41328. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41329. /**
  41330. * Defines the camera the input is attached to.
  41331. */
  41332. camera: FlyCamera;
  41333. /**
  41334. * The list of keyboard keys used to control the forward move of the camera.
  41335. */
  41336. keysForward: number[];
  41337. /**
  41338. * The list of keyboard keys used to control the backward move of the camera.
  41339. */
  41340. keysBackward: number[];
  41341. /**
  41342. * The list of keyboard keys used to control the forward move of the camera.
  41343. */
  41344. keysUp: number[];
  41345. /**
  41346. * The list of keyboard keys used to control the backward move of the camera.
  41347. */
  41348. keysDown: number[];
  41349. /**
  41350. * The list of keyboard keys used to control the right strafe move of the camera.
  41351. */
  41352. keysRight: number[];
  41353. /**
  41354. * The list of keyboard keys used to control the left strafe move of the camera.
  41355. */
  41356. keysLeft: number[];
  41357. private _keys;
  41358. private _onCanvasBlurObserver;
  41359. private _onKeyboardObserver;
  41360. private _engine;
  41361. private _scene;
  41362. /**
  41363. * Attach the input controls to a specific dom element to get the input from.
  41364. * @param element Defines the element the controls should be listened from
  41365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41366. */
  41367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41368. /**
  41369. * Detach the current controls from the specified dom element.
  41370. * @param element Defines the element to stop listening the inputs from
  41371. */
  41372. detachControl(element: Nullable<HTMLElement>): void;
  41373. /**
  41374. * Gets the class name of the current intput.
  41375. * @returns the class name
  41376. */
  41377. getClassName(): string;
  41378. /** @hidden */
  41379. _onLostFocus(e: FocusEvent): void;
  41380. /**
  41381. * Get the friendly name associated with the input class.
  41382. * @returns the input friendly name
  41383. */
  41384. getSimpleName(): string;
  41385. /**
  41386. * Update the current camera state depending on the inputs that have been used this frame.
  41387. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41388. */
  41389. checkInputs(): void;
  41390. }
  41391. }
  41392. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41393. import { Nullable } from "babylonjs/types";
  41394. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41395. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41396. /**
  41397. * Manage the mouse wheel inputs to control a follow camera.
  41398. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41399. */
  41400. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41401. /**
  41402. * Defines the camera the input is attached to.
  41403. */
  41404. camera: FollowCamera;
  41405. /**
  41406. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41407. */
  41408. axisControlRadius: boolean;
  41409. /**
  41410. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41411. */
  41412. axisControlHeight: boolean;
  41413. /**
  41414. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41415. */
  41416. axisControlRotation: boolean;
  41417. /**
  41418. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41419. * relation to mouseWheel events.
  41420. */
  41421. wheelPrecision: number;
  41422. /**
  41423. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41424. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41425. */
  41426. wheelDeltaPercentage: number;
  41427. private _wheel;
  41428. private _observer;
  41429. /**
  41430. * Attach the input controls to a specific dom element to get the input from.
  41431. * @param element Defines the element the controls should be listened from
  41432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41433. */
  41434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41435. /**
  41436. * Detach the current controls from the specified dom element.
  41437. * @param element Defines the element to stop listening the inputs from
  41438. */
  41439. detachControl(element: Nullable<HTMLElement>): void;
  41440. /**
  41441. * Gets the class name of the current intput.
  41442. * @returns the class name
  41443. */
  41444. getClassName(): string;
  41445. /**
  41446. * Get the friendly name associated with the input class.
  41447. * @returns the input friendly name
  41448. */
  41449. getSimpleName(): string;
  41450. }
  41451. }
  41452. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41453. import { Nullable } from "babylonjs/types";
  41454. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41455. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41456. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41457. /**
  41458. * Manage the pointers inputs to control an follow camera.
  41459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41460. */
  41461. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41462. /**
  41463. * Defines the camera the input is attached to.
  41464. */
  41465. camera: FollowCamera;
  41466. /**
  41467. * Gets the class name of the current input.
  41468. * @returns the class name
  41469. */
  41470. getClassName(): string;
  41471. /**
  41472. * Defines the pointer angular sensibility along the X axis or how fast is
  41473. * the camera rotating.
  41474. * A negative number will reverse the axis direction.
  41475. */
  41476. angularSensibilityX: number;
  41477. /**
  41478. * Defines the pointer angular sensibility along the Y axis or how fast is
  41479. * the camera rotating.
  41480. * A negative number will reverse the axis direction.
  41481. */
  41482. angularSensibilityY: number;
  41483. /**
  41484. * Defines the pointer pinch precision or how fast is the camera zooming.
  41485. * A negative number will reverse the axis direction.
  41486. */
  41487. pinchPrecision: number;
  41488. /**
  41489. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41490. * from 0.
  41491. * It defines the percentage of current camera.radius to use as delta when
  41492. * pinch zoom is used.
  41493. */
  41494. pinchDeltaPercentage: number;
  41495. /**
  41496. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41497. */
  41498. axisXControlRadius: boolean;
  41499. /**
  41500. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41501. */
  41502. axisXControlHeight: boolean;
  41503. /**
  41504. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41505. */
  41506. axisXControlRotation: boolean;
  41507. /**
  41508. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41509. */
  41510. axisYControlRadius: boolean;
  41511. /**
  41512. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41513. */
  41514. axisYControlHeight: boolean;
  41515. /**
  41516. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41517. */
  41518. axisYControlRotation: boolean;
  41519. /**
  41520. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41521. */
  41522. axisPinchControlRadius: boolean;
  41523. /**
  41524. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41525. */
  41526. axisPinchControlHeight: boolean;
  41527. /**
  41528. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41529. */
  41530. axisPinchControlRotation: boolean;
  41531. /**
  41532. * Log error messages if basic misconfiguration has occurred.
  41533. */
  41534. warningEnable: boolean;
  41535. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41536. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41537. private _warningCounter;
  41538. private _warning;
  41539. }
  41540. }
  41541. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41542. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41543. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41544. /**
  41545. * Default Inputs manager for the FollowCamera.
  41546. * It groups all the default supported inputs for ease of use.
  41547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41548. */
  41549. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41550. /**
  41551. * Instantiates a new FollowCameraInputsManager.
  41552. * @param camera Defines the camera the inputs belong to
  41553. */
  41554. constructor(camera: FollowCamera);
  41555. /**
  41556. * Add keyboard input support to the input manager.
  41557. * @returns the current input manager
  41558. */
  41559. addKeyboard(): FollowCameraInputsManager;
  41560. /**
  41561. * Add mouse wheel input support to the input manager.
  41562. * @returns the current input manager
  41563. */
  41564. addMouseWheel(): FollowCameraInputsManager;
  41565. /**
  41566. * Add pointers input support to the input manager.
  41567. * @returns the current input manager
  41568. */
  41569. addPointers(): FollowCameraInputsManager;
  41570. /**
  41571. * Add orientation input support to the input manager.
  41572. * @returns the current input manager
  41573. */
  41574. addVRDeviceOrientation(): FollowCameraInputsManager;
  41575. }
  41576. }
  41577. declare module "babylonjs/Cameras/followCamera" {
  41578. import { Nullable } from "babylonjs/types";
  41579. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41580. import { Scene } from "babylonjs/scene";
  41581. import { Vector3 } from "babylonjs/Maths/math.vector";
  41582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41583. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41584. /**
  41585. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41586. * an arc rotate version arcFollowCamera are available.
  41587. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41588. */
  41589. export class FollowCamera extends TargetCamera {
  41590. /**
  41591. * Distance the follow camera should follow an object at
  41592. */
  41593. radius: number;
  41594. /**
  41595. * Minimum allowed distance of the camera to the axis of rotation
  41596. * (The camera can not get closer).
  41597. * This can help limiting how the Camera is able to move in the scene.
  41598. */
  41599. lowerRadiusLimit: Nullable<number>;
  41600. /**
  41601. * Maximum allowed distance of the camera to the axis of rotation
  41602. * (The camera can not get further).
  41603. * This can help limiting how the Camera is able to move in the scene.
  41604. */
  41605. upperRadiusLimit: Nullable<number>;
  41606. /**
  41607. * Define a rotation offset between the camera and the object it follows
  41608. */
  41609. rotationOffset: number;
  41610. /**
  41611. * Minimum allowed angle to camera position relative to target object.
  41612. * This can help limiting how the Camera is able to move in the scene.
  41613. */
  41614. lowerRotationOffsetLimit: Nullable<number>;
  41615. /**
  41616. * Maximum allowed angle to camera position relative to target object.
  41617. * This can help limiting how the Camera is able to move in the scene.
  41618. */
  41619. upperRotationOffsetLimit: Nullable<number>;
  41620. /**
  41621. * Define a height offset between the camera and the object it follows.
  41622. * It can help following an object from the top (like a car chaing a plane)
  41623. */
  41624. heightOffset: number;
  41625. /**
  41626. * Minimum allowed height of camera position relative to target object.
  41627. * This can help limiting how the Camera is able to move in the scene.
  41628. */
  41629. lowerHeightOffsetLimit: Nullable<number>;
  41630. /**
  41631. * Maximum allowed height of camera position relative to target object.
  41632. * This can help limiting how the Camera is able to move in the scene.
  41633. */
  41634. upperHeightOffsetLimit: Nullable<number>;
  41635. /**
  41636. * Define how fast the camera can accelerate to follow it s target.
  41637. */
  41638. cameraAcceleration: number;
  41639. /**
  41640. * Define the speed limit of the camera following an object.
  41641. */
  41642. maxCameraSpeed: number;
  41643. /**
  41644. * Define the target of the camera.
  41645. */
  41646. lockedTarget: Nullable<AbstractMesh>;
  41647. /**
  41648. * Defines the input associated with the camera.
  41649. */
  41650. inputs: FollowCameraInputsManager;
  41651. /**
  41652. * Instantiates the follow camera.
  41653. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41654. * @param name Define the name of the camera in the scene
  41655. * @param position Define the position of the camera
  41656. * @param scene Define the scene the camera belong to
  41657. * @param lockedTarget Define the target of the camera
  41658. */
  41659. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41660. private _follow;
  41661. /**
  41662. * Attached controls to the current camera.
  41663. * @param element Defines the element the controls should be listened from
  41664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41665. */
  41666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41667. /**
  41668. * Detach the current controls from the camera.
  41669. * The camera will stop reacting to inputs.
  41670. * @param element Defines the element to stop listening the inputs from
  41671. */
  41672. detachControl(element: HTMLElement): void;
  41673. /** @hidden */
  41674. _checkInputs(): void;
  41675. private _checkLimits;
  41676. /**
  41677. * Gets the camera class name.
  41678. * @returns the class name
  41679. */
  41680. getClassName(): string;
  41681. }
  41682. /**
  41683. * Arc Rotate version of the follow camera.
  41684. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41685. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41686. */
  41687. export class ArcFollowCamera extends TargetCamera {
  41688. /** The longitudinal angle of the camera */
  41689. alpha: number;
  41690. /** The latitudinal angle of the camera */
  41691. beta: number;
  41692. /** The radius of the camera from its target */
  41693. radius: number;
  41694. /** Define the camera target (the messh it should follow) */
  41695. target: Nullable<AbstractMesh>;
  41696. private _cartesianCoordinates;
  41697. /**
  41698. * Instantiates a new ArcFollowCamera
  41699. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41700. * @param name Define the name of the camera
  41701. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41702. * @param beta Define the rotation angle of the camera around the elevation axis
  41703. * @param radius Define the radius of the camera from its target point
  41704. * @param target Define the target of the camera
  41705. * @param scene Define the scene the camera belongs to
  41706. */
  41707. constructor(name: string,
  41708. /** The longitudinal angle of the camera */
  41709. alpha: number,
  41710. /** The latitudinal angle of the camera */
  41711. beta: number,
  41712. /** The radius of the camera from its target */
  41713. radius: number,
  41714. /** Define the camera target (the messh it should follow) */
  41715. target: Nullable<AbstractMesh>, scene: Scene);
  41716. private _follow;
  41717. /** @hidden */
  41718. _checkInputs(): void;
  41719. /**
  41720. * Returns the class name of the object.
  41721. * It is mostly used internally for serialization purposes.
  41722. */
  41723. getClassName(): string;
  41724. }
  41725. }
  41726. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41727. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41728. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41729. import { Nullable } from "babylonjs/types";
  41730. /**
  41731. * Manage the keyboard inputs to control the movement of a follow camera.
  41732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41733. */
  41734. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41735. /**
  41736. * Defines the camera the input is attached to.
  41737. */
  41738. camera: FollowCamera;
  41739. /**
  41740. * Defines the list of key codes associated with the up action (increase heightOffset)
  41741. */
  41742. keysHeightOffsetIncr: number[];
  41743. /**
  41744. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41745. */
  41746. keysHeightOffsetDecr: number[];
  41747. /**
  41748. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41749. */
  41750. keysHeightOffsetModifierAlt: boolean;
  41751. /**
  41752. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41753. */
  41754. keysHeightOffsetModifierCtrl: boolean;
  41755. /**
  41756. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41757. */
  41758. keysHeightOffsetModifierShift: boolean;
  41759. /**
  41760. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41761. */
  41762. keysRotationOffsetIncr: number[];
  41763. /**
  41764. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41765. */
  41766. keysRotationOffsetDecr: number[];
  41767. /**
  41768. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41769. */
  41770. keysRotationOffsetModifierAlt: boolean;
  41771. /**
  41772. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41773. */
  41774. keysRotationOffsetModifierCtrl: boolean;
  41775. /**
  41776. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41777. */
  41778. keysRotationOffsetModifierShift: boolean;
  41779. /**
  41780. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41781. */
  41782. keysRadiusIncr: number[];
  41783. /**
  41784. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41785. */
  41786. keysRadiusDecr: number[];
  41787. /**
  41788. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41789. */
  41790. keysRadiusModifierAlt: boolean;
  41791. /**
  41792. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41793. */
  41794. keysRadiusModifierCtrl: boolean;
  41795. /**
  41796. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41797. */
  41798. keysRadiusModifierShift: boolean;
  41799. /**
  41800. * Defines the rate of change of heightOffset.
  41801. */
  41802. heightSensibility: number;
  41803. /**
  41804. * Defines the rate of change of rotationOffset.
  41805. */
  41806. rotationSensibility: number;
  41807. /**
  41808. * Defines the rate of change of radius.
  41809. */
  41810. radiusSensibility: number;
  41811. private _keys;
  41812. private _ctrlPressed;
  41813. private _altPressed;
  41814. private _shiftPressed;
  41815. private _onCanvasBlurObserver;
  41816. private _onKeyboardObserver;
  41817. private _engine;
  41818. private _scene;
  41819. /**
  41820. * Attach the input controls to a specific dom element to get the input from.
  41821. * @param element Defines the element the controls should be listened from
  41822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41823. */
  41824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41825. /**
  41826. * Detach the current controls from the specified dom element.
  41827. * @param element Defines the element to stop listening the inputs from
  41828. */
  41829. detachControl(element: Nullable<HTMLElement>): void;
  41830. /**
  41831. * Update the current camera state depending on the inputs that have been used this frame.
  41832. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41833. */
  41834. checkInputs(): void;
  41835. /**
  41836. * Gets the class name of the current input.
  41837. * @returns the class name
  41838. */
  41839. getClassName(): string;
  41840. /**
  41841. * Get the friendly name associated with the input class.
  41842. * @returns the input friendly name
  41843. */
  41844. getSimpleName(): string;
  41845. /**
  41846. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41847. * allow modification of the heightOffset value.
  41848. */
  41849. private _modifierHeightOffset;
  41850. /**
  41851. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41852. * allow modification of the rotationOffset value.
  41853. */
  41854. private _modifierRotationOffset;
  41855. /**
  41856. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41857. * allow modification of the radius value.
  41858. */
  41859. private _modifierRadius;
  41860. }
  41861. }
  41862. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41863. import { Nullable } from "babylonjs/types";
  41864. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41865. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41866. import { Observable } from "babylonjs/Misc/observable";
  41867. module "babylonjs/Cameras/freeCameraInputsManager" {
  41868. interface FreeCameraInputsManager {
  41869. /**
  41870. * @hidden
  41871. */
  41872. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41873. /**
  41874. * Add orientation input support to the input manager.
  41875. * @returns the current input manager
  41876. */
  41877. addDeviceOrientation(): FreeCameraInputsManager;
  41878. }
  41879. }
  41880. /**
  41881. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41882. * Screen rotation is taken into account.
  41883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41884. */
  41885. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41886. private _camera;
  41887. private _screenOrientationAngle;
  41888. private _constantTranform;
  41889. private _screenQuaternion;
  41890. private _alpha;
  41891. private _beta;
  41892. private _gamma;
  41893. /**
  41894. * Can be used to detect if a device orientation sensor is available on a device
  41895. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41896. * @returns a promise that will resolve on orientation change
  41897. */
  41898. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41899. /**
  41900. * @hidden
  41901. */
  41902. _onDeviceOrientationChangedObservable: Observable<void>;
  41903. /**
  41904. * Instantiates a new input
  41905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41906. */
  41907. constructor();
  41908. /**
  41909. * Define the camera controlled by the input.
  41910. */
  41911. get camera(): FreeCamera;
  41912. set camera(camera: FreeCamera);
  41913. /**
  41914. * Attach the input controls to a specific dom element to get the input from.
  41915. * @param element Defines the element the controls should be listened from
  41916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41917. */
  41918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41919. private _orientationChanged;
  41920. private _deviceOrientation;
  41921. /**
  41922. * Detach the current controls from the specified dom element.
  41923. * @param element Defines the element to stop listening the inputs from
  41924. */
  41925. detachControl(element: Nullable<HTMLElement>): void;
  41926. /**
  41927. * Update the current camera state depending on the inputs that have been used this frame.
  41928. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41929. */
  41930. checkInputs(): void;
  41931. /**
  41932. * Gets the class name of the current intput.
  41933. * @returns the class name
  41934. */
  41935. getClassName(): string;
  41936. /**
  41937. * Get the friendly name associated with the input class.
  41938. * @returns the input friendly name
  41939. */
  41940. getSimpleName(): string;
  41941. }
  41942. }
  41943. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41944. import { Nullable } from "babylonjs/types";
  41945. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41946. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41947. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41948. /**
  41949. * Manage the gamepad inputs to control a free camera.
  41950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41951. */
  41952. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41953. /**
  41954. * Define the camera the input is attached to.
  41955. */
  41956. camera: FreeCamera;
  41957. /**
  41958. * Define the Gamepad controlling the input
  41959. */
  41960. gamepad: Nullable<Gamepad>;
  41961. /**
  41962. * Defines the gamepad rotation sensiblity.
  41963. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41964. */
  41965. gamepadAngularSensibility: number;
  41966. /**
  41967. * Defines the gamepad move sensiblity.
  41968. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41969. */
  41970. gamepadMoveSensibility: number;
  41971. private _yAxisScale;
  41972. /**
  41973. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41974. */
  41975. get invertYAxis(): boolean;
  41976. set invertYAxis(value: boolean);
  41977. private _onGamepadConnectedObserver;
  41978. private _onGamepadDisconnectedObserver;
  41979. private _cameraTransform;
  41980. private _deltaTransform;
  41981. private _vector3;
  41982. private _vector2;
  41983. /**
  41984. * Attach the input controls to a specific dom element to get the input from.
  41985. * @param element Defines the element the controls should be listened from
  41986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41987. */
  41988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41989. /**
  41990. * Detach the current controls from the specified dom element.
  41991. * @param element Defines the element to stop listening the inputs from
  41992. */
  41993. detachControl(element: Nullable<HTMLElement>): void;
  41994. /**
  41995. * Update the current camera state depending on the inputs that have been used this frame.
  41996. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41997. */
  41998. checkInputs(): void;
  41999. /**
  42000. * Gets the class name of the current intput.
  42001. * @returns the class name
  42002. */
  42003. getClassName(): string;
  42004. /**
  42005. * Get the friendly name associated with the input class.
  42006. * @returns the input friendly name
  42007. */
  42008. getSimpleName(): string;
  42009. }
  42010. }
  42011. declare module "babylonjs/Misc/virtualJoystick" {
  42012. import { Nullable } from "babylonjs/types";
  42013. import { Vector3 } from "babylonjs/Maths/math.vector";
  42014. /**
  42015. * Defines the potential axis of a Joystick
  42016. */
  42017. export enum JoystickAxis {
  42018. /** X axis */
  42019. X = 0,
  42020. /** Y axis */
  42021. Y = 1,
  42022. /** Z axis */
  42023. Z = 2
  42024. }
  42025. /**
  42026. * Class used to define virtual joystick (used in touch mode)
  42027. */
  42028. export class VirtualJoystick {
  42029. /**
  42030. * Gets or sets a boolean indicating that left and right values must be inverted
  42031. */
  42032. reverseLeftRight: boolean;
  42033. /**
  42034. * Gets or sets a boolean indicating that up and down values must be inverted
  42035. */
  42036. reverseUpDown: boolean;
  42037. /**
  42038. * Gets the offset value for the position (ie. the change of the position value)
  42039. */
  42040. deltaPosition: Vector3;
  42041. /**
  42042. * Gets a boolean indicating if the virtual joystick was pressed
  42043. */
  42044. pressed: boolean;
  42045. /**
  42046. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42047. */
  42048. static Canvas: Nullable<HTMLCanvasElement>;
  42049. private static _globalJoystickIndex;
  42050. private static vjCanvasContext;
  42051. private static vjCanvasWidth;
  42052. private static vjCanvasHeight;
  42053. private static halfWidth;
  42054. private _action;
  42055. private _axisTargetedByLeftAndRight;
  42056. private _axisTargetedByUpAndDown;
  42057. private _joystickSensibility;
  42058. private _inversedSensibility;
  42059. private _joystickPointerID;
  42060. private _joystickColor;
  42061. private _joystickPointerPos;
  42062. private _joystickPreviousPointerPos;
  42063. private _joystickPointerStartPos;
  42064. private _deltaJoystickVector;
  42065. private _leftJoystick;
  42066. private _touches;
  42067. private _onPointerDownHandlerRef;
  42068. private _onPointerMoveHandlerRef;
  42069. private _onPointerUpHandlerRef;
  42070. private _onResize;
  42071. /**
  42072. * Creates a new virtual joystick
  42073. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42074. */
  42075. constructor(leftJoystick?: boolean);
  42076. /**
  42077. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42078. * @param newJoystickSensibility defines the new sensibility
  42079. */
  42080. setJoystickSensibility(newJoystickSensibility: number): void;
  42081. private _onPointerDown;
  42082. private _onPointerMove;
  42083. private _onPointerUp;
  42084. /**
  42085. * Change the color of the virtual joystick
  42086. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42087. */
  42088. setJoystickColor(newColor: string): void;
  42089. /**
  42090. * Defines a callback to call when the joystick is touched
  42091. * @param action defines the callback
  42092. */
  42093. setActionOnTouch(action: () => any): void;
  42094. /**
  42095. * Defines which axis you'd like to control for left & right
  42096. * @param axis defines the axis to use
  42097. */
  42098. setAxisForLeftRight(axis: JoystickAxis): void;
  42099. /**
  42100. * Defines which axis you'd like to control for up & down
  42101. * @param axis defines the axis to use
  42102. */
  42103. setAxisForUpDown(axis: JoystickAxis): void;
  42104. private _drawVirtualJoystick;
  42105. /**
  42106. * Release internal HTML canvas
  42107. */
  42108. releaseCanvas(): void;
  42109. }
  42110. }
  42111. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42112. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42113. import { Nullable } from "babylonjs/types";
  42114. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42115. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42116. module "babylonjs/Cameras/freeCameraInputsManager" {
  42117. interface FreeCameraInputsManager {
  42118. /**
  42119. * Add virtual joystick input support to the input manager.
  42120. * @returns the current input manager
  42121. */
  42122. addVirtualJoystick(): FreeCameraInputsManager;
  42123. }
  42124. }
  42125. /**
  42126. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42128. */
  42129. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42130. /**
  42131. * Defines the camera the input is attached to.
  42132. */
  42133. camera: FreeCamera;
  42134. private _leftjoystick;
  42135. private _rightjoystick;
  42136. /**
  42137. * Gets the left stick of the virtual joystick.
  42138. * @returns The virtual Joystick
  42139. */
  42140. getLeftJoystick(): VirtualJoystick;
  42141. /**
  42142. * Gets the right stick of the virtual joystick.
  42143. * @returns The virtual Joystick
  42144. */
  42145. getRightJoystick(): VirtualJoystick;
  42146. /**
  42147. * Update the current camera state depending on the inputs that have been used this frame.
  42148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42149. */
  42150. checkInputs(): void;
  42151. /**
  42152. * Attach the input controls to a specific dom element to get the input from.
  42153. * @param element Defines the element the controls should be listened from
  42154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42155. */
  42156. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42157. /**
  42158. * Detach the current controls from the specified dom element.
  42159. * @param element Defines the element to stop listening the inputs from
  42160. */
  42161. detachControl(element: Nullable<HTMLElement>): void;
  42162. /**
  42163. * Gets the class name of the current intput.
  42164. * @returns the class name
  42165. */
  42166. getClassName(): string;
  42167. /**
  42168. * Get the friendly name associated with the input class.
  42169. * @returns the input friendly name
  42170. */
  42171. getSimpleName(): string;
  42172. }
  42173. }
  42174. declare module "babylonjs/Cameras/Inputs/index" {
  42175. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42176. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42177. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42178. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42179. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42180. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42181. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42182. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42183. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42184. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42185. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42186. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42187. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42188. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42189. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42190. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42191. }
  42192. declare module "babylonjs/Cameras/touchCamera" {
  42193. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42194. import { Scene } from "babylonjs/scene";
  42195. import { Vector3 } from "babylonjs/Maths/math.vector";
  42196. /**
  42197. * This represents a FPS type of camera controlled by touch.
  42198. * This is like a universal camera minus the Gamepad controls.
  42199. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42200. */
  42201. export class TouchCamera extends FreeCamera {
  42202. /**
  42203. * Defines the touch sensibility for rotation.
  42204. * The higher the faster.
  42205. */
  42206. get touchAngularSensibility(): number;
  42207. set touchAngularSensibility(value: number);
  42208. /**
  42209. * Defines the touch sensibility for move.
  42210. * The higher the faster.
  42211. */
  42212. get touchMoveSensibility(): number;
  42213. set touchMoveSensibility(value: number);
  42214. /**
  42215. * Instantiates a new touch camera.
  42216. * This represents a FPS type of camera controlled by touch.
  42217. * This is like a universal camera minus the Gamepad controls.
  42218. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42219. * @param name Define the name of the camera in the scene
  42220. * @param position Define the start position of the camera in the scene
  42221. * @param scene Define the scene the camera belongs to
  42222. */
  42223. constructor(name: string, position: Vector3, scene: Scene);
  42224. /**
  42225. * Gets the current object class name.
  42226. * @return the class name
  42227. */
  42228. getClassName(): string;
  42229. /** @hidden */
  42230. _setupInputs(): void;
  42231. }
  42232. }
  42233. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42234. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42235. import { Scene } from "babylonjs/scene";
  42236. import { Vector3 } from "babylonjs/Maths/math.vector";
  42237. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42238. import { Axis } from "babylonjs/Maths/math.axis";
  42239. /**
  42240. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42241. * being tilted forward or back and left or right.
  42242. */
  42243. export class DeviceOrientationCamera extends FreeCamera {
  42244. private _initialQuaternion;
  42245. private _quaternionCache;
  42246. private _tmpDragQuaternion;
  42247. private _disablePointerInputWhenUsingDeviceOrientation;
  42248. /**
  42249. * Creates a new device orientation camera
  42250. * @param name The name of the camera
  42251. * @param position The start position camera
  42252. * @param scene The scene the camera belongs to
  42253. */
  42254. constructor(name: string, position: Vector3, scene: Scene);
  42255. /**
  42256. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42257. */
  42258. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42259. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42260. private _dragFactor;
  42261. /**
  42262. * Enabled turning on the y axis when the orientation sensor is active
  42263. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42264. */
  42265. enableHorizontalDragging(dragFactor?: number): void;
  42266. /**
  42267. * Gets the current instance class name ("DeviceOrientationCamera").
  42268. * This helps avoiding instanceof at run time.
  42269. * @returns the class name
  42270. */
  42271. getClassName(): string;
  42272. /**
  42273. * @hidden
  42274. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42275. */
  42276. _checkInputs(): void;
  42277. /**
  42278. * Reset the camera to its default orientation on the specified axis only.
  42279. * @param axis The axis to reset
  42280. */
  42281. resetToCurrentRotation(axis?: Axis): void;
  42282. }
  42283. }
  42284. declare module "babylonjs/Gamepads/xboxGamepad" {
  42285. import { Observable } from "babylonjs/Misc/observable";
  42286. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42287. /**
  42288. * Defines supported buttons for XBox360 compatible gamepads
  42289. */
  42290. export enum Xbox360Button {
  42291. /** A */
  42292. A = 0,
  42293. /** B */
  42294. B = 1,
  42295. /** X */
  42296. X = 2,
  42297. /** Y */
  42298. Y = 3,
  42299. /** Left button */
  42300. LB = 4,
  42301. /** Right button */
  42302. RB = 5,
  42303. /** Back */
  42304. Back = 8,
  42305. /** Start */
  42306. Start = 9,
  42307. /** Left stick */
  42308. LeftStick = 10,
  42309. /** Right stick */
  42310. RightStick = 11
  42311. }
  42312. /** Defines values for XBox360 DPad */
  42313. export enum Xbox360Dpad {
  42314. /** Up */
  42315. Up = 12,
  42316. /** Down */
  42317. Down = 13,
  42318. /** Left */
  42319. Left = 14,
  42320. /** Right */
  42321. Right = 15
  42322. }
  42323. /**
  42324. * Defines a XBox360 gamepad
  42325. */
  42326. export class Xbox360Pad extends Gamepad {
  42327. private _leftTrigger;
  42328. private _rightTrigger;
  42329. private _onlefttriggerchanged;
  42330. private _onrighttriggerchanged;
  42331. private _onbuttondown;
  42332. private _onbuttonup;
  42333. private _ondpaddown;
  42334. private _ondpadup;
  42335. /** Observable raised when a button is pressed */
  42336. onButtonDownObservable: Observable<Xbox360Button>;
  42337. /** Observable raised when a button is released */
  42338. onButtonUpObservable: Observable<Xbox360Button>;
  42339. /** Observable raised when a pad is pressed */
  42340. onPadDownObservable: Observable<Xbox360Dpad>;
  42341. /** Observable raised when a pad is released */
  42342. onPadUpObservable: Observable<Xbox360Dpad>;
  42343. private _buttonA;
  42344. private _buttonB;
  42345. private _buttonX;
  42346. private _buttonY;
  42347. private _buttonBack;
  42348. private _buttonStart;
  42349. private _buttonLB;
  42350. private _buttonRB;
  42351. private _buttonLeftStick;
  42352. private _buttonRightStick;
  42353. private _dPadUp;
  42354. private _dPadDown;
  42355. private _dPadLeft;
  42356. private _dPadRight;
  42357. private _isXboxOnePad;
  42358. /**
  42359. * Creates a new XBox360 gamepad object
  42360. * @param id defines the id of this gamepad
  42361. * @param index defines its index
  42362. * @param gamepad defines the internal HTML gamepad object
  42363. * @param xboxOne defines if it is a XBox One gamepad
  42364. */
  42365. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42366. /**
  42367. * Defines the callback to call when left trigger is pressed
  42368. * @param callback defines the callback to use
  42369. */
  42370. onlefttriggerchanged(callback: (value: number) => void): void;
  42371. /**
  42372. * Defines the callback to call when right trigger is pressed
  42373. * @param callback defines the callback to use
  42374. */
  42375. onrighttriggerchanged(callback: (value: number) => void): void;
  42376. /**
  42377. * Gets the left trigger value
  42378. */
  42379. get leftTrigger(): number;
  42380. /**
  42381. * Sets the left trigger value
  42382. */
  42383. set leftTrigger(newValue: number);
  42384. /**
  42385. * Gets the right trigger value
  42386. */
  42387. get rightTrigger(): number;
  42388. /**
  42389. * Sets the right trigger value
  42390. */
  42391. set rightTrigger(newValue: number);
  42392. /**
  42393. * Defines the callback to call when a button is pressed
  42394. * @param callback defines the callback to use
  42395. */
  42396. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42397. /**
  42398. * Defines the callback to call when a button is released
  42399. * @param callback defines the callback to use
  42400. */
  42401. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42402. /**
  42403. * Defines the callback to call when a pad is pressed
  42404. * @param callback defines the callback to use
  42405. */
  42406. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42407. /**
  42408. * Defines the callback to call when a pad is released
  42409. * @param callback defines the callback to use
  42410. */
  42411. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42412. private _setButtonValue;
  42413. private _setDPadValue;
  42414. /**
  42415. * Gets the value of the `A` button
  42416. */
  42417. get buttonA(): number;
  42418. /**
  42419. * Sets the value of the `A` button
  42420. */
  42421. set buttonA(value: number);
  42422. /**
  42423. * Gets the value of the `B` button
  42424. */
  42425. get buttonB(): number;
  42426. /**
  42427. * Sets the value of the `B` button
  42428. */
  42429. set buttonB(value: number);
  42430. /**
  42431. * Gets the value of the `X` button
  42432. */
  42433. get buttonX(): number;
  42434. /**
  42435. * Sets the value of the `X` button
  42436. */
  42437. set buttonX(value: number);
  42438. /**
  42439. * Gets the value of the `Y` button
  42440. */
  42441. get buttonY(): number;
  42442. /**
  42443. * Sets the value of the `Y` button
  42444. */
  42445. set buttonY(value: number);
  42446. /**
  42447. * Gets the value of the `Start` button
  42448. */
  42449. get buttonStart(): number;
  42450. /**
  42451. * Sets the value of the `Start` button
  42452. */
  42453. set buttonStart(value: number);
  42454. /**
  42455. * Gets the value of the `Back` button
  42456. */
  42457. get buttonBack(): number;
  42458. /**
  42459. * Sets the value of the `Back` button
  42460. */
  42461. set buttonBack(value: number);
  42462. /**
  42463. * Gets the value of the `Left` button
  42464. */
  42465. get buttonLB(): number;
  42466. /**
  42467. * Sets the value of the `Left` button
  42468. */
  42469. set buttonLB(value: number);
  42470. /**
  42471. * Gets the value of the `Right` button
  42472. */
  42473. get buttonRB(): number;
  42474. /**
  42475. * Sets the value of the `Right` button
  42476. */
  42477. set buttonRB(value: number);
  42478. /**
  42479. * Gets the value of the Left joystick
  42480. */
  42481. get buttonLeftStick(): number;
  42482. /**
  42483. * Sets the value of the Left joystick
  42484. */
  42485. set buttonLeftStick(value: number);
  42486. /**
  42487. * Gets the value of the Right joystick
  42488. */
  42489. get buttonRightStick(): number;
  42490. /**
  42491. * Sets the value of the Right joystick
  42492. */
  42493. set buttonRightStick(value: number);
  42494. /**
  42495. * Gets the value of D-pad up
  42496. */
  42497. get dPadUp(): number;
  42498. /**
  42499. * Sets the value of D-pad up
  42500. */
  42501. set dPadUp(value: number);
  42502. /**
  42503. * Gets the value of D-pad down
  42504. */
  42505. get dPadDown(): number;
  42506. /**
  42507. * Sets the value of D-pad down
  42508. */
  42509. set dPadDown(value: number);
  42510. /**
  42511. * Gets the value of D-pad left
  42512. */
  42513. get dPadLeft(): number;
  42514. /**
  42515. * Sets the value of D-pad left
  42516. */
  42517. set dPadLeft(value: number);
  42518. /**
  42519. * Gets the value of D-pad right
  42520. */
  42521. get dPadRight(): number;
  42522. /**
  42523. * Sets the value of D-pad right
  42524. */
  42525. set dPadRight(value: number);
  42526. /**
  42527. * Force the gamepad to synchronize with device values
  42528. */
  42529. update(): void;
  42530. /**
  42531. * Disposes the gamepad
  42532. */
  42533. dispose(): void;
  42534. }
  42535. }
  42536. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42537. import { Observable } from "babylonjs/Misc/observable";
  42538. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42539. /**
  42540. * Defines supported buttons for DualShock compatible gamepads
  42541. */
  42542. export enum DualShockButton {
  42543. /** Cross */
  42544. Cross = 0,
  42545. /** Circle */
  42546. Circle = 1,
  42547. /** Square */
  42548. Square = 2,
  42549. /** Triangle */
  42550. Triangle = 3,
  42551. /** L1 */
  42552. L1 = 4,
  42553. /** R1 */
  42554. R1 = 5,
  42555. /** Share */
  42556. Share = 8,
  42557. /** Options */
  42558. Options = 9,
  42559. /** Left stick */
  42560. LeftStick = 10,
  42561. /** Right stick */
  42562. RightStick = 11
  42563. }
  42564. /** Defines values for DualShock DPad */
  42565. export enum DualShockDpad {
  42566. /** Up */
  42567. Up = 12,
  42568. /** Down */
  42569. Down = 13,
  42570. /** Left */
  42571. Left = 14,
  42572. /** Right */
  42573. Right = 15
  42574. }
  42575. /**
  42576. * Defines a DualShock gamepad
  42577. */
  42578. export class DualShockPad extends Gamepad {
  42579. private _leftTrigger;
  42580. private _rightTrigger;
  42581. private _onlefttriggerchanged;
  42582. private _onrighttriggerchanged;
  42583. private _onbuttondown;
  42584. private _onbuttonup;
  42585. private _ondpaddown;
  42586. private _ondpadup;
  42587. /** Observable raised when a button is pressed */
  42588. onButtonDownObservable: Observable<DualShockButton>;
  42589. /** Observable raised when a button is released */
  42590. onButtonUpObservable: Observable<DualShockButton>;
  42591. /** Observable raised when a pad is pressed */
  42592. onPadDownObservable: Observable<DualShockDpad>;
  42593. /** Observable raised when a pad is released */
  42594. onPadUpObservable: Observable<DualShockDpad>;
  42595. private _buttonCross;
  42596. private _buttonCircle;
  42597. private _buttonSquare;
  42598. private _buttonTriangle;
  42599. private _buttonShare;
  42600. private _buttonOptions;
  42601. private _buttonL1;
  42602. private _buttonR1;
  42603. private _buttonLeftStick;
  42604. private _buttonRightStick;
  42605. private _dPadUp;
  42606. private _dPadDown;
  42607. private _dPadLeft;
  42608. private _dPadRight;
  42609. /**
  42610. * Creates a new DualShock gamepad object
  42611. * @param id defines the id of this gamepad
  42612. * @param index defines its index
  42613. * @param gamepad defines the internal HTML gamepad object
  42614. */
  42615. constructor(id: string, index: number, gamepad: any);
  42616. /**
  42617. * Defines the callback to call when left trigger is pressed
  42618. * @param callback defines the callback to use
  42619. */
  42620. onlefttriggerchanged(callback: (value: number) => void): void;
  42621. /**
  42622. * Defines the callback to call when right trigger is pressed
  42623. * @param callback defines the callback to use
  42624. */
  42625. onrighttriggerchanged(callback: (value: number) => void): void;
  42626. /**
  42627. * Gets the left trigger value
  42628. */
  42629. get leftTrigger(): number;
  42630. /**
  42631. * Sets the left trigger value
  42632. */
  42633. set leftTrigger(newValue: number);
  42634. /**
  42635. * Gets the right trigger value
  42636. */
  42637. get rightTrigger(): number;
  42638. /**
  42639. * Sets the right trigger value
  42640. */
  42641. set rightTrigger(newValue: number);
  42642. /**
  42643. * Defines the callback to call when a button is pressed
  42644. * @param callback defines the callback to use
  42645. */
  42646. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42647. /**
  42648. * Defines the callback to call when a button is released
  42649. * @param callback defines the callback to use
  42650. */
  42651. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42652. /**
  42653. * Defines the callback to call when a pad is pressed
  42654. * @param callback defines the callback to use
  42655. */
  42656. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42657. /**
  42658. * Defines the callback to call when a pad is released
  42659. * @param callback defines the callback to use
  42660. */
  42661. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42662. private _setButtonValue;
  42663. private _setDPadValue;
  42664. /**
  42665. * Gets the value of the `Cross` button
  42666. */
  42667. get buttonCross(): number;
  42668. /**
  42669. * Sets the value of the `Cross` button
  42670. */
  42671. set buttonCross(value: number);
  42672. /**
  42673. * Gets the value of the `Circle` button
  42674. */
  42675. get buttonCircle(): number;
  42676. /**
  42677. * Sets the value of the `Circle` button
  42678. */
  42679. set buttonCircle(value: number);
  42680. /**
  42681. * Gets the value of the `Square` button
  42682. */
  42683. get buttonSquare(): number;
  42684. /**
  42685. * Sets the value of the `Square` button
  42686. */
  42687. set buttonSquare(value: number);
  42688. /**
  42689. * Gets the value of the `Triangle` button
  42690. */
  42691. get buttonTriangle(): number;
  42692. /**
  42693. * Sets the value of the `Triangle` button
  42694. */
  42695. set buttonTriangle(value: number);
  42696. /**
  42697. * Gets the value of the `Options` button
  42698. */
  42699. get buttonOptions(): number;
  42700. /**
  42701. * Sets the value of the `Options` button
  42702. */
  42703. set buttonOptions(value: number);
  42704. /**
  42705. * Gets the value of the `Share` button
  42706. */
  42707. get buttonShare(): number;
  42708. /**
  42709. * Sets the value of the `Share` button
  42710. */
  42711. set buttonShare(value: number);
  42712. /**
  42713. * Gets the value of the `L1` button
  42714. */
  42715. get buttonL1(): number;
  42716. /**
  42717. * Sets the value of the `L1` button
  42718. */
  42719. set buttonL1(value: number);
  42720. /**
  42721. * Gets the value of the `R1` button
  42722. */
  42723. get buttonR1(): number;
  42724. /**
  42725. * Sets the value of the `R1` button
  42726. */
  42727. set buttonR1(value: number);
  42728. /**
  42729. * Gets the value of the Left joystick
  42730. */
  42731. get buttonLeftStick(): number;
  42732. /**
  42733. * Sets the value of the Left joystick
  42734. */
  42735. set buttonLeftStick(value: number);
  42736. /**
  42737. * Gets the value of the Right joystick
  42738. */
  42739. get buttonRightStick(): number;
  42740. /**
  42741. * Sets the value of the Right joystick
  42742. */
  42743. set buttonRightStick(value: number);
  42744. /**
  42745. * Gets the value of D-pad up
  42746. */
  42747. get dPadUp(): number;
  42748. /**
  42749. * Sets the value of D-pad up
  42750. */
  42751. set dPadUp(value: number);
  42752. /**
  42753. * Gets the value of D-pad down
  42754. */
  42755. get dPadDown(): number;
  42756. /**
  42757. * Sets the value of D-pad down
  42758. */
  42759. set dPadDown(value: number);
  42760. /**
  42761. * Gets the value of D-pad left
  42762. */
  42763. get dPadLeft(): number;
  42764. /**
  42765. * Sets the value of D-pad left
  42766. */
  42767. set dPadLeft(value: number);
  42768. /**
  42769. * Gets the value of D-pad right
  42770. */
  42771. get dPadRight(): number;
  42772. /**
  42773. * Sets the value of D-pad right
  42774. */
  42775. set dPadRight(value: number);
  42776. /**
  42777. * Force the gamepad to synchronize with device values
  42778. */
  42779. update(): void;
  42780. /**
  42781. * Disposes the gamepad
  42782. */
  42783. dispose(): void;
  42784. }
  42785. }
  42786. declare module "babylonjs/Gamepads/gamepadManager" {
  42787. import { Observable } from "babylonjs/Misc/observable";
  42788. import { Nullable } from "babylonjs/types";
  42789. import { Scene } from "babylonjs/scene";
  42790. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42791. /**
  42792. * Manager for handling gamepads
  42793. */
  42794. export class GamepadManager {
  42795. private _scene?;
  42796. private _babylonGamepads;
  42797. private _oneGamepadConnected;
  42798. /** @hidden */
  42799. _isMonitoring: boolean;
  42800. private _gamepadEventSupported;
  42801. private _gamepadSupport?;
  42802. /**
  42803. * observable to be triggered when the gamepad controller has been connected
  42804. */
  42805. onGamepadConnectedObservable: Observable<Gamepad>;
  42806. /**
  42807. * observable to be triggered when the gamepad controller has been disconnected
  42808. */
  42809. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42810. private _onGamepadConnectedEvent;
  42811. private _onGamepadDisconnectedEvent;
  42812. /**
  42813. * Initializes the gamepad manager
  42814. * @param _scene BabylonJS scene
  42815. */
  42816. constructor(_scene?: Scene | undefined);
  42817. /**
  42818. * The gamepads in the game pad manager
  42819. */
  42820. get gamepads(): Gamepad[];
  42821. /**
  42822. * Get the gamepad controllers based on type
  42823. * @param type The type of gamepad controller
  42824. * @returns Nullable gamepad
  42825. */
  42826. getGamepadByType(type?: number): Nullable<Gamepad>;
  42827. /**
  42828. * Disposes the gamepad manager
  42829. */
  42830. dispose(): void;
  42831. private _addNewGamepad;
  42832. private _startMonitoringGamepads;
  42833. private _stopMonitoringGamepads;
  42834. /** @hidden */
  42835. _checkGamepadsStatus(): void;
  42836. private _updateGamepadObjects;
  42837. }
  42838. }
  42839. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42840. import { Nullable } from "babylonjs/types";
  42841. import { Scene } from "babylonjs/scene";
  42842. import { ISceneComponent } from "babylonjs/sceneComponent";
  42843. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42844. module "babylonjs/scene" {
  42845. interface Scene {
  42846. /** @hidden */
  42847. _gamepadManager: Nullable<GamepadManager>;
  42848. /**
  42849. * Gets the gamepad manager associated with the scene
  42850. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42851. */
  42852. gamepadManager: GamepadManager;
  42853. }
  42854. }
  42855. module "babylonjs/Cameras/freeCameraInputsManager" {
  42856. /**
  42857. * Interface representing a free camera inputs manager
  42858. */
  42859. interface FreeCameraInputsManager {
  42860. /**
  42861. * Adds gamepad input support to the FreeCameraInputsManager.
  42862. * @returns the FreeCameraInputsManager
  42863. */
  42864. addGamepad(): FreeCameraInputsManager;
  42865. }
  42866. }
  42867. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42868. /**
  42869. * Interface representing an arc rotate camera inputs manager
  42870. */
  42871. interface ArcRotateCameraInputsManager {
  42872. /**
  42873. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42874. * @returns the camera inputs manager
  42875. */
  42876. addGamepad(): ArcRotateCameraInputsManager;
  42877. }
  42878. }
  42879. /**
  42880. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42881. */
  42882. export class GamepadSystemSceneComponent implements ISceneComponent {
  42883. /**
  42884. * The component name helpfull to identify the component in the list of scene components.
  42885. */
  42886. readonly name: string;
  42887. /**
  42888. * The scene the component belongs to.
  42889. */
  42890. scene: Scene;
  42891. /**
  42892. * Creates a new instance of the component for the given scene
  42893. * @param scene Defines the scene to register the component in
  42894. */
  42895. constructor(scene: Scene);
  42896. /**
  42897. * Registers the component in a given scene
  42898. */
  42899. register(): void;
  42900. /**
  42901. * Rebuilds the elements related to this component in case of
  42902. * context lost for instance.
  42903. */
  42904. rebuild(): void;
  42905. /**
  42906. * Disposes the component and the associated ressources
  42907. */
  42908. dispose(): void;
  42909. private _beforeCameraUpdate;
  42910. }
  42911. }
  42912. declare module "babylonjs/Cameras/universalCamera" {
  42913. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42914. import { Scene } from "babylonjs/scene";
  42915. import { Vector3 } from "babylonjs/Maths/math.vector";
  42916. import "babylonjs/Gamepads/gamepadSceneComponent";
  42917. /**
  42918. * 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,
  42919. * which still works and will still be found in many Playgrounds.
  42920. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42921. */
  42922. export class UniversalCamera extends TouchCamera {
  42923. /**
  42924. * Defines the gamepad rotation sensiblity.
  42925. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42926. */
  42927. get gamepadAngularSensibility(): number;
  42928. set gamepadAngularSensibility(value: number);
  42929. /**
  42930. * Defines the gamepad move sensiblity.
  42931. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42932. */
  42933. get gamepadMoveSensibility(): number;
  42934. set gamepadMoveSensibility(value: number);
  42935. /**
  42936. * 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,
  42937. * which still works and will still be found in many Playgrounds.
  42938. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42939. * @param name Define the name of the camera in the scene
  42940. * @param position Define the start position of the camera in the scene
  42941. * @param scene Define the scene the camera belongs to
  42942. */
  42943. constructor(name: string, position: Vector3, scene: Scene);
  42944. /**
  42945. * Gets the current object class name.
  42946. * @return the class name
  42947. */
  42948. getClassName(): string;
  42949. }
  42950. }
  42951. declare module "babylonjs/Cameras/gamepadCamera" {
  42952. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42953. import { Scene } from "babylonjs/scene";
  42954. import { Vector3 } from "babylonjs/Maths/math.vector";
  42955. /**
  42956. * This represents a FPS type of camera. This is only here for back compat purpose.
  42957. * Please use the UniversalCamera instead as both are identical.
  42958. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42959. */
  42960. export class GamepadCamera extends UniversalCamera {
  42961. /**
  42962. * Instantiates a new Gamepad Camera
  42963. * This represents a FPS type of camera. This is only here for back compat purpose.
  42964. * Please use the UniversalCamera instead as both are identical.
  42965. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42966. * @param name Define the name of the camera in the scene
  42967. * @param position Define the start position of the camera in the scene
  42968. * @param scene Define the scene the camera belongs to
  42969. */
  42970. constructor(name: string, position: Vector3, scene: Scene);
  42971. /**
  42972. * Gets the current object class name.
  42973. * @return the class name
  42974. */
  42975. getClassName(): string;
  42976. }
  42977. }
  42978. declare module "babylonjs/Shaders/pass.fragment" {
  42979. /** @hidden */
  42980. export var passPixelShader: {
  42981. name: string;
  42982. shader: string;
  42983. };
  42984. }
  42985. declare module "babylonjs/Shaders/passCube.fragment" {
  42986. /** @hidden */
  42987. export var passCubePixelShader: {
  42988. name: string;
  42989. shader: string;
  42990. };
  42991. }
  42992. declare module "babylonjs/PostProcesses/passPostProcess" {
  42993. import { Nullable } from "babylonjs/types";
  42994. import { Camera } from "babylonjs/Cameras/camera";
  42995. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42996. import { Engine } from "babylonjs/Engines/engine";
  42997. import "babylonjs/Shaders/pass.fragment";
  42998. import "babylonjs/Shaders/passCube.fragment";
  42999. /**
  43000. * PassPostProcess which produces an output the same as it's input
  43001. */
  43002. export class PassPostProcess extends PostProcess {
  43003. /**
  43004. * Creates the PassPostProcess
  43005. * @param name The name of the effect.
  43006. * @param options The required width/height ratio to downsize to before computing the render pass.
  43007. * @param camera The camera to apply the render pass to.
  43008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43009. * @param engine The engine which the post process will be applied. (default: current engine)
  43010. * @param reusable If the post process can be reused on the same frame. (default: false)
  43011. * @param textureType The type of texture to be used when performing the post processing.
  43012. * @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)
  43013. */
  43014. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43015. }
  43016. /**
  43017. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43018. */
  43019. export class PassCubePostProcess extends PostProcess {
  43020. private _face;
  43021. /**
  43022. * Gets or sets the cube face to display.
  43023. * * 0 is +X
  43024. * * 1 is -X
  43025. * * 2 is +Y
  43026. * * 3 is -Y
  43027. * * 4 is +Z
  43028. * * 5 is -Z
  43029. */
  43030. get face(): number;
  43031. set face(value: number);
  43032. /**
  43033. * Creates the PassCubePostProcess
  43034. * @param name The name of the effect.
  43035. * @param options The required width/height ratio to downsize to before computing the render pass.
  43036. * @param camera The camera to apply the render pass to.
  43037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43038. * @param engine The engine which the post process will be applied. (default: current engine)
  43039. * @param reusable If the post process can be reused on the same frame. (default: false)
  43040. * @param textureType The type of texture to be used when performing the post processing.
  43041. * @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)
  43042. */
  43043. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43044. }
  43045. }
  43046. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43047. /** @hidden */
  43048. export var anaglyphPixelShader: {
  43049. name: string;
  43050. shader: string;
  43051. };
  43052. }
  43053. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43054. import { Engine } from "babylonjs/Engines/engine";
  43055. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43056. import { Camera } from "babylonjs/Cameras/camera";
  43057. import "babylonjs/Shaders/anaglyph.fragment";
  43058. /**
  43059. * Postprocess used to generate anaglyphic rendering
  43060. */
  43061. export class AnaglyphPostProcess extends PostProcess {
  43062. private _passedProcess;
  43063. /**
  43064. * Creates a new AnaglyphPostProcess
  43065. * @param name defines postprocess name
  43066. * @param options defines creation options or target ratio scale
  43067. * @param rigCameras defines cameras using this postprocess
  43068. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43069. * @param engine defines hosting engine
  43070. * @param reusable defines if the postprocess will be reused multiple times per frame
  43071. */
  43072. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43073. }
  43074. }
  43075. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43076. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43077. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43078. import { Scene } from "babylonjs/scene";
  43079. import { Vector3 } from "babylonjs/Maths/math.vector";
  43080. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43081. /**
  43082. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43083. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43084. */
  43085. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43086. /**
  43087. * Creates a new AnaglyphArcRotateCamera
  43088. * @param name defines camera name
  43089. * @param alpha defines alpha angle (in radians)
  43090. * @param beta defines beta angle (in radians)
  43091. * @param radius defines radius
  43092. * @param target defines camera target
  43093. * @param interaxialDistance defines distance between each color axis
  43094. * @param scene defines the hosting scene
  43095. */
  43096. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43097. /**
  43098. * Gets camera class name
  43099. * @returns AnaglyphArcRotateCamera
  43100. */
  43101. getClassName(): string;
  43102. }
  43103. }
  43104. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43105. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43106. import { Scene } from "babylonjs/scene";
  43107. import { Vector3 } from "babylonjs/Maths/math.vector";
  43108. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43109. /**
  43110. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43111. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43112. */
  43113. export class AnaglyphFreeCamera extends FreeCamera {
  43114. /**
  43115. * Creates a new AnaglyphFreeCamera
  43116. * @param name defines camera name
  43117. * @param position defines initial position
  43118. * @param interaxialDistance defines distance between each color axis
  43119. * @param scene defines the hosting scene
  43120. */
  43121. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43122. /**
  43123. * Gets camera class name
  43124. * @returns AnaglyphFreeCamera
  43125. */
  43126. getClassName(): string;
  43127. }
  43128. }
  43129. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43130. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43131. import { Scene } from "babylonjs/scene";
  43132. import { Vector3 } from "babylonjs/Maths/math.vector";
  43133. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43134. /**
  43135. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43136. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43137. */
  43138. export class AnaglyphGamepadCamera extends GamepadCamera {
  43139. /**
  43140. * Creates a new AnaglyphGamepadCamera
  43141. * @param name defines camera name
  43142. * @param position defines initial position
  43143. * @param interaxialDistance defines distance between each color axis
  43144. * @param scene defines the hosting scene
  43145. */
  43146. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43147. /**
  43148. * Gets camera class name
  43149. * @returns AnaglyphGamepadCamera
  43150. */
  43151. getClassName(): string;
  43152. }
  43153. }
  43154. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43155. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43156. import { Scene } from "babylonjs/scene";
  43157. import { Vector3 } from "babylonjs/Maths/math.vector";
  43158. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43159. /**
  43160. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43161. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43162. */
  43163. export class AnaglyphUniversalCamera extends UniversalCamera {
  43164. /**
  43165. * Creates a new AnaglyphUniversalCamera
  43166. * @param name defines camera name
  43167. * @param position defines initial position
  43168. * @param interaxialDistance defines distance between each color axis
  43169. * @param scene defines the hosting scene
  43170. */
  43171. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43172. /**
  43173. * Gets camera class name
  43174. * @returns AnaglyphUniversalCamera
  43175. */
  43176. getClassName(): string;
  43177. }
  43178. }
  43179. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43180. /** @hidden */
  43181. export var stereoscopicInterlacePixelShader: {
  43182. name: string;
  43183. shader: string;
  43184. };
  43185. }
  43186. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43187. import { Camera } from "babylonjs/Cameras/camera";
  43188. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43189. import { Engine } from "babylonjs/Engines/engine";
  43190. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43191. /**
  43192. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43193. */
  43194. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43195. private _stepSize;
  43196. private _passedProcess;
  43197. /**
  43198. * Initializes a StereoscopicInterlacePostProcessI
  43199. * @param name The name of the effect.
  43200. * @param rigCameras The rig cameras to be appled to the post process
  43201. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43202. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43204. * @param engine The engine which the post process will be applied. (default: current engine)
  43205. * @param reusable If the post process can be reused on the same frame. (default: false)
  43206. */
  43207. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43208. }
  43209. /**
  43210. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43211. */
  43212. export class StereoscopicInterlacePostProcess extends PostProcess {
  43213. private _stepSize;
  43214. private _passedProcess;
  43215. /**
  43216. * Initializes a StereoscopicInterlacePostProcess
  43217. * @param name The name of the effect.
  43218. * @param rigCameras The rig cameras to be appled to the post process
  43219. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43221. * @param engine The engine which the post process will be applied. (default: current engine)
  43222. * @param reusable If the post process can be reused on the same frame. (default: false)
  43223. */
  43224. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43225. }
  43226. }
  43227. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43228. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43229. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43230. import { Scene } from "babylonjs/scene";
  43231. import { Vector3 } from "babylonjs/Maths/math.vector";
  43232. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43233. /**
  43234. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43235. * @see http://doc.babylonjs.com/features/cameras
  43236. */
  43237. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43238. /**
  43239. * Creates a new StereoscopicArcRotateCamera
  43240. * @param name defines camera name
  43241. * @param alpha defines alpha angle (in radians)
  43242. * @param beta defines beta angle (in radians)
  43243. * @param radius defines radius
  43244. * @param target defines camera target
  43245. * @param interaxialDistance defines distance between each color axis
  43246. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43247. * @param scene defines the hosting scene
  43248. */
  43249. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43250. /**
  43251. * Gets camera class name
  43252. * @returns StereoscopicArcRotateCamera
  43253. */
  43254. getClassName(): string;
  43255. }
  43256. }
  43257. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43258. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43259. import { Scene } from "babylonjs/scene";
  43260. import { Vector3 } from "babylonjs/Maths/math.vector";
  43261. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43262. /**
  43263. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43264. * @see http://doc.babylonjs.com/features/cameras
  43265. */
  43266. export class StereoscopicFreeCamera extends FreeCamera {
  43267. /**
  43268. * Creates a new StereoscopicFreeCamera
  43269. * @param name defines camera name
  43270. * @param position defines initial position
  43271. * @param interaxialDistance defines distance between each color axis
  43272. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43273. * @param scene defines the hosting scene
  43274. */
  43275. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43276. /**
  43277. * Gets camera class name
  43278. * @returns StereoscopicFreeCamera
  43279. */
  43280. getClassName(): string;
  43281. }
  43282. }
  43283. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43284. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43285. import { Scene } from "babylonjs/scene";
  43286. import { Vector3 } from "babylonjs/Maths/math.vector";
  43287. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43288. /**
  43289. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43290. * @see http://doc.babylonjs.com/features/cameras
  43291. */
  43292. export class StereoscopicGamepadCamera extends GamepadCamera {
  43293. /**
  43294. * Creates a new StereoscopicGamepadCamera
  43295. * @param name defines camera name
  43296. * @param position defines initial position
  43297. * @param interaxialDistance defines distance between each color axis
  43298. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43299. * @param scene defines the hosting scene
  43300. */
  43301. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43302. /**
  43303. * Gets camera class name
  43304. * @returns StereoscopicGamepadCamera
  43305. */
  43306. getClassName(): string;
  43307. }
  43308. }
  43309. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43310. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43311. import { Scene } from "babylonjs/scene";
  43312. import { Vector3 } from "babylonjs/Maths/math.vector";
  43313. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43314. /**
  43315. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43316. * @see http://doc.babylonjs.com/features/cameras
  43317. */
  43318. export class StereoscopicUniversalCamera extends UniversalCamera {
  43319. /**
  43320. * Creates a new StereoscopicUniversalCamera
  43321. * @param name defines camera name
  43322. * @param position defines initial position
  43323. * @param interaxialDistance defines distance between each color axis
  43324. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43325. * @param scene defines the hosting scene
  43326. */
  43327. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43328. /**
  43329. * Gets camera class name
  43330. * @returns StereoscopicUniversalCamera
  43331. */
  43332. getClassName(): string;
  43333. }
  43334. }
  43335. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43336. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43337. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43338. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43339. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43340. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43341. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43342. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43343. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43344. }
  43345. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43346. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43347. import { Scene } from "babylonjs/scene";
  43348. import { Vector3 } from "babylonjs/Maths/math.vector";
  43349. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43350. /**
  43351. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43352. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43353. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43354. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43355. */
  43356. export class VirtualJoysticksCamera extends FreeCamera {
  43357. /**
  43358. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43359. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43360. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43361. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43362. * @param name Define the name of the camera in the scene
  43363. * @param position Define the start position of the camera in the scene
  43364. * @param scene Define the scene the camera belongs to
  43365. */
  43366. constructor(name: string, position: Vector3, scene: Scene);
  43367. /**
  43368. * Gets the current object class name.
  43369. * @return the class name
  43370. */
  43371. getClassName(): string;
  43372. }
  43373. }
  43374. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43375. import { Matrix } from "babylonjs/Maths/math.vector";
  43376. /**
  43377. * This represents all the required metrics to create a VR camera.
  43378. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43379. */
  43380. export class VRCameraMetrics {
  43381. /**
  43382. * Define the horizontal resolution off the screen.
  43383. */
  43384. hResolution: number;
  43385. /**
  43386. * Define the vertical resolution off the screen.
  43387. */
  43388. vResolution: number;
  43389. /**
  43390. * Define the horizontal screen size.
  43391. */
  43392. hScreenSize: number;
  43393. /**
  43394. * Define the vertical screen size.
  43395. */
  43396. vScreenSize: number;
  43397. /**
  43398. * Define the vertical screen center position.
  43399. */
  43400. vScreenCenter: number;
  43401. /**
  43402. * Define the distance of the eyes to the screen.
  43403. */
  43404. eyeToScreenDistance: number;
  43405. /**
  43406. * Define the distance between both lenses
  43407. */
  43408. lensSeparationDistance: number;
  43409. /**
  43410. * Define the distance between both viewer's eyes.
  43411. */
  43412. interpupillaryDistance: number;
  43413. /**
  43414. * Define the distortion factor of the VR postprocess.
  43415. * Please, touch with care.
  43416. */
  43417. distortionK: number[];
  43418. /**
  43419. * Define the chromatic aberration correction factors for the VR post process.
  43420. */
  43421. chromaAbCorrection: number[];
  43422. /**
  43423. * Define the scale factor of the post process.
  43424. * The smaller the better but the slower.
  43425. */
  43426. postProcessScaleFactor: number;
  43427. /**
  43428. * Define an offset for the lens center.
  43429. */
  43430. lensCenterOffset: number;
  43431. /**
  43432. * Define if the current vr camera should compensate the distortion of the lense or not.
  43433. */
  43434. compensateDistortion: boolean;
  43435. /**
  43436. * Defines if multiview should be enabled when rendering (Default: false)
  43437. */
  43438. multiviewEnabled: boolean;
  43439. /**
  43440. * Gets the rendering aspect ratio based on the provided resolutions.
  43441. */
  43442. get aspectRatio(): number;
  43443. /**
  43444. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43445. */
  43446. get aspectRatioFov(): number;
  43447. /**
  43448. * @hidden
  43449. */
  43450. get leftHMatrix(): Matrix;
  43451. /**
  43452. * @hidden
  43453. */
  43454. get rightHMatrix(): Matrix;
  43455. /**
  43456. * @hidden
  43457. */
  43458. get leftPreViewMatrix(): Matrix;
  43459. /**
  43460. * @hidden
  43461. */
  43462. get rightPreViewMatrix(): Matrix;
  43463. /**
  43464. * Get the default VRMetrics based on the most generic setup.
  43465. * @returns the default vr metrics
  43466. */
  43467. static GetDefault(): VRCameraMetrics;
  43468. }
  43469. }
  43470. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43471. /** @hidden */
  43472. export var vrDistortionCorrectionPixelShader: {
  43473. name: string;
  43474. shader: string;
  43475. };
  43476. }
  43477. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43478. import { Camera } from "babylonjs/Cameras/camera";
  43479. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43480. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43481. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43482. /**
  43483. * VRDistortionCorrectionPostProcess used for mobile VR
  43484. */
  43485. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43486. private _isRightEye;
  43487. private _distortionFactors;
  43488. private _postProcessScaleFactor;
  43489. private _lensCenterOffset;
  43490. private _scaleIn;
  43491. private _scaleFactor;
  43492. private _lensCenter;
  43493. /**
  43494. * Initializes the VRDistortionCorrectionPostProcess
  43495. * @param name The name of the effect.
  43496. * @param camera The camera to apply the render pass to.
  43497. * @param isRightEye If this is for the right eye distortion
  43498. * @param vrMetrics All the required metrics for the VR camera
  43499. */
  43500. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43501. }
  43502. }
  43503. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43504. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43505. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43506. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43507. import { Scene } from "babylonjs/scene";
  43508. import { Vector3 } from "babylonjs/Maths/math.vector";
  43509. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43510. import "babylonjs/Cameras/RigModes/vrRigMode";
  43511. /**
  43512. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43513. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43514. */
  43515. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43516. /**
  43517. * Creates a new VRDeviceOrientationArcRotateCamera
  43518. * @param name defines camera name
  43519. * @param alpha defines the camera rotation along the logitudinal axis
  43520. * @param beta defines the camera rotation along the latitudinal axis
  43521. * @param radius defines the camera distance from its target
  43522. * @param target defines the camera target
  43523. * @param scene defines the scene the camera belongs to
  43524. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43525. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43526. */
  43527. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43528. /**
  43529. * Gets camera class name
  43530. * @returns VRDeviceOrientationArcRotateCamera
  43531. */
  43532. getClassName(): string;
  43533. }
  43534. }
  43535. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43536. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43537. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43538. import { Scene } from "babylonjs/scene";
  43539. import { Vector3 } from "babylonjs/Maths/math.vector";
  43540. import "babylonjs/Cameras/RigModes/vrRigMode";
  43541. /**
  43542. * Camera used to simulate VR rendering (based on FreeCamera)
  43543. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43544. */
  43545. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43546. /**
  43547. * Creates a new VRDeviceOrientationFreeCamera
  43548. * @param name defines camera name
  43549. * @param position defines the start position of the camera
  43550. * @param scene defines the scene the camera belongs to
  43551. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43552. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43553. */
  43554. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43555. /**
  43556. * Gets camera class name
  43557. * @returns VRDeviceOrientationFreeCamera
  43558. */
  43559. getClassName(): string;
  43560. }
  43561. }
  43562. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43563. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43564. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43565. import { Scene } from "babylonjs/scene";
  43566. import { Vector3 } from "babylonjs/Maths/math.vector";
  43567. import "babylonjs/Gamepads/gamepadSceneComponent";
  43568. /**
  43569. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43570. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43571. */
  43572. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43573. /**
  43574. * Creates a new VRDeviceOrientationGamepadCamera
  43575. * @param name defines camera name
  43576. * @param position defines the start position of the camera
  43577. * @param scene defines the scene the camera belongs to
  43578. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43579. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43580. */
  43581. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43582. /**
  43583. * Gets camera class name
  43584. * @returns VRDeviceOrientationGamepadCamera
  43585. */
  43586. getClassName(): string;
  43587. }
  43588. }
  43589. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43590. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43591. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43592. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43593. /** @hidden */
  43594. export var imageProcessingPixelShader: {
  43595. name: string;
  43596. shader: string;
  43597. };
  43598. }
  43599. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43600. import { Nullable } from "babylonjs/types";
  43601. import { Color4 } from "babylonjs/Maths/math.color";
  43602. import { Camera } from "babylonjs/Cameras/camera";
  43603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43604. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43605. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43606. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43607. import { Engine } from "babylonjs/Engines/engine";
  43608. import "babylonjs/Shaders/imageProcessing.fragment";
  43609. import "babylonjs/Shaders/postprocess.vertex";
  43610. /**
  43611. * ImageProcessingPostProcess
  43612. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43613. */
  43614. export class ImageProcessingPostProcess extends PostProcess {
  43615. /**
  43616. * Default configuration related to image processing available in the PBR Material.
  43617. */
  43618. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43619. /**
  43620. * Gets the image processing configuration used either in this material.
  43621. */
  43622. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43623. /**
  43624. * Sets the Default image processing configuration used either in the this material.
  43625. *
  43626. * If sets to null, the scene one is in use.
  43627. */
  43628. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43629. /**
  43630. * Keep track of the image processing observer to allow dispose and replace.
  43631. */
  43632. private _imageProcessingObserver;
  43633. /**
  43634. * Attaches a new image processing configuration to the PBR Material.
  43635. * @param configuration
  43636. */
  43637. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43638. /**
  43639. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43640. */
  43641. get colorCurves(): Nullable<ColorCurves>;
  43642. /**
  43643. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43644. */
  43645. set colorCurves(value: Nullable<ColorCurves>);
  43646. /**
  43647. * Gets wether the color curves effect is enabled.
  43648. */
  43649. get colorCurvesEnabled(): boolean;
  43650. /**
  43651. * Sets wether the color curves effect is enabled.
  43652. */
  43653. set colorCurvesEnabled(value: boolean);
  43654. /**
  43655. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43656. */
  43657. get colorGradingTexture(): Nullable<BaseTexture>;
  43658. /**
  43659. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43660. */
  43661. set colorGradingTexture(value: Nullable<BaseTexture>);
  43662. /**
  43663. * Gets wether the color grading effect is enabled.
  43664. */
  43665. get colorGradingEnabled(): boolean;
  43666. /**
  43667. * Gets wether the color grading effect is enabled.
  43668. */
  43669. set colorGradingEnabled(value: boolean);
  43670. /**
  43671. * Gets exposure used in the effect.
  43672. */
  43673. get exposure(): number;
  43674. /**
  43675. * Sets exposure used in the effect.
  43676. */
  43677. set exposure(value: number);
  43678. /**
  43679. * Gets wether tonemapping is enabled or not.
  43680. */
  43681. get toneMappingEnabled(): boolean;
  43682. /**
  43683. * Sets wether tonemapping is enabled or not
  43684. */
  43685. set toneMappingEnabled(value: boolean);
  43686. /**
  43687. * Gets the type of tone mapping effect.
  43688. */
  43689. get toneMappingType(): number;
  43690. /**
  43691. * Sets the type of tone mapping effect.
  43692. */
  43693. set toneMappingType(value: number);
  43694. /**
  43695. * Gets contrast used in the effect.
  43696. */
  43697. get contrast(): number;
  43698. /**
  43699. * Sets contrast used in the effect.
  43700. */
  43701. set contrast(value: number);
  43702. /**
  43703. * Gets Vignette stretch size.
  43704. */
  43705. get vignetteStretch(): number;
  43706. /**
  43707. * Sets Vignette stretch size.
  43708. */
  43709. set vignetteStretch(value: number);
  43710. /**
  43711. * Gets Vignette centre X Offset.
  43712. */
  43713. get vignetteCentreX(): number;
  43714. /**
  43715. * Sets Vignette centre X Offset.
  43716. */
  43717. set vignetteCentreX(value: number);
  43718. /**
  43719. * Gets Vignette centre Y Offset.
  43720. */
  43721. get vignetteCentreY(): number;
  43722. /**
  43723. * Sets Vignette centre Y Offset.
  43724. */
  43725. set vignetteCentreY(value: number);
  43726. /**
  43727. * Gets Vignette weight or intensity of the vignette effect.
  43728. */
  43729. get vignetteWeight(): number;
  43730. /**
  43731. * Sets Vignette weight or intensity of the vignette effect.
  43732. */
  43733. set vignetteWeight(value: number);
  43734. /**
  43735. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43736. * if vignetteEnabled is set to true.
  43737. */
  43738. get vignetteColor(): Color4;
  43739. /**
  43740. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43741. * if vignetteEnabled is set to true.
  43742. */
  43743. set vignetteColor(value: Color4);
  43744. /**
  43745. * Gets Camera field of view used by the Vignette effect.
  43746. */
  43747. get vignetteCameraFov(): number;
  43748. /**
  43749. * Sets Camera field of view used by the Vignette effect.
  43750. */
  43751. set vignetteCameraFov(value: number);
  43752. /**
  43753. * Gets the vignette blend mode allowing different kind of effect.
  43754. */
  43755. get vignetteBlendMode(): number;
  43756. /**
  43757. * Sets the vignette blend mode allowing different kind of effect.
  43758. */
  43759. set vignetteBlendMode(value: number);
  43760. /**
  43761. * Gets wether the vignette effect is enabled.
  43762. */
  43763. get vignetteEnabled(): boolean;
  43764. /**
  43765. * Sets wether the vignette effect is enabled.
  43766. */
  43767. set vignetteEnabled(value: boolean);
  43768. private _fromLinearSpace;
  43769. /**
  43770. * Gets wether the input of the processing is in Gamma or Linear Space.
  43771. */
  43772. get fromLinearSpace(): boolean;
  43773. /**
  43774. * Sets wether the input of the processing is in Gamma or Linear Space.
  43775. */
  43776. set fromLinearSpace(value: boolean);
  43777. /**
  43778. * Defines cache preventing GC.
  43779. */
  43780. private _defines;
  43781. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43782. /**
  43783. * "ImageProcessingPostProcess"
  43784. * @returns "ImageProcessingPostProcess"
  43785. */
  43786. getClassName(): string;
  43787. protected _updateParameters(): void;
  43788. dispose(camera?: Camera): void;
  43789. }
  43790. }
  43791. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43792. import { Scene } from "babylonjs/scene";
  43793. import { Color3 } from "babylonjs/Maths/math.color";
  43794. import { Mesh } from "babylonjs/Meshes/mesh";
  43795. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43796. import { Nullable } from "babylonjs/types";
  43797. /**
  43798. * Class containing static functions to help procedurally build meshes
  43799. */
  43800. export class GroundBuilder {
  43801. /**
  43802. * Creates a ground mesh
  43803. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43804. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43806. * @param name defines the name of the mesh
  43807. * @param options defines the options used to create the mesh
  43808. * @param scene defines the hosting scene
  43809. * @returns the ground mesh
  43810. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43811. */
  43812. static CreateGround(name: string, options: {
  43813. width?: number;
  43814. height?: number;
  43815. subdivisions?: number;
  43816. subdivisionsX?: number;
  43817. subdivisionsY?: number;
  43818. updatable?: boolean;
  43819. }, scene: any): Mesh;
  43820. /**
  43821. * Creates a tiled ground mesh
  43822. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43823. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43824. * * 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
  43825. * * 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
  43826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43827. * @param name defines the name of the mesh
  43828. * @param options defines the options used to create the mesh
  43829. * @param scene defines the hosting scene
  43830. * @returns the tiled ground mesh
  43831. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43832. */
  43833. static CreateTiledGround(name: string, options: {
  43834. xmin: number;
  43835. zmin: number;
  43836. xmax: number;
  43837. zmax: number;
  43838. subdivisions?: {
  43839. w: number;
  43840. h: number;
  43841. };
  43842. precision?: {
  43843. w: number;
  43844. h: number;
  43845. };
  43846. updatable?: boolean;
  43847. }, scene?: Nullable<Scene>): Mesh;
  43848. /**
  43849. * Creates a ground mesh from a height map
  43850. * * The parameter `url` sets the URL of the height map image resource.
  43851. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43852. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43853. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43854. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43855. * * 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.
  43856. * * 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).
  43857. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43859. * @param name defines the name of the mesh
  43860. * @param url defines the url to the height map
  43861. * @param options defines the options used to create the mesh
  43862. * @param scene defines the hosting scene
  43863. * @returns the ground mesh
  43864. * @see https://doc.babylonjs.com/babylon101/height_map
  43865. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43866. */
  43867. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43868. width?: number;
  43869. height?: number;
  43870. subdivisions?: number;
  43871. minHeight?: number;
  43872. maxHeight?: number;
  43873. colorFilter?: Color3;
  43874. alphaFilter?: number;
  43875. updatable?: boolean;
  43876. onReady?: (mesh: GroundMesh) => void;
  43877. }, scene?: Nullable<Scene>): GroundMesh;
  43878. }
  43879. }
  43880. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43881. import { Vector4 } from "babylonjs/Maths/math.vector";
  43882. import { Mesh } from "babylonjs/Meshes/mesh";
  43883. /**
  43884. * Class containing static functions to help procedurally build meshes
  43885. */
  43886. export class TorusBuilder {
  43887. /**
  43888. * Creates a torus mesh
  43889. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43890. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43891. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43895. * @param name defines the name of the mesh
  43896. * @param options defines the options used to create the mesh
  43897. * @param scene defines the hosting scene
  43898. * @returns the torus mesh
  43899. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43900. */
  43901. static CreateTorus(name: string, options: {
  43902. diameter?: number;
  43903. thickness?: number;
  43904. tessellation?: number;
  43905. updatable?: boolean;
  43906. sideOrientation?: number;
  43907. frontUVs?: Vector4;
  43908. backUVs?: Vector4;
  43909. }, scene: any): Mesh;
  43910. }
  43911. }
  43912. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43913. import { Vector4 } from "babylonjs/Maths/math.vector";
  43914. import { Color4 } from "babylonjs/Maths/math.color";
  43915. import { Mesh } from "babylonjs/Meshes/mesh";
  43916. /**
  43917. * Class containing static functions to help procedurally build meshes
  43918. */
  43919. export class CylinderBuilder {
  43920. /**
  43921. * Creates a cylinder or a cone mesh
  43922. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43923. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43924. * * 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.
  43925. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43926. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43927. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43928. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43929. * * 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).
  43930. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43931. * * 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).
  43932. * * 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
  43933. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43934. * * 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
  43935. * * 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.
  43936. * * If `enclose` is false, a ring surface is one element.
  43937. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43938. * * 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
  43939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43942. * @param name defines the name of the mesh
  43943. * @param options defines the options used to create the mesh
  43944. * @param scene defines the hosting scene
  43945. * @returns the cylinder mesh
  43946. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43947. */
  43948. static CreateCylinder(name: string, options: {
  43949. height?: number;
  43950. diameterTop?: number;
  43951. diameterBottom?: number;
  43952. diameter?: number;
  43953. tessellation?: number;
  43954. subdivisions?: number;
  43955. arc?: number;
  43956. faceColors?: Color4[];
  43957. faceUV?: Vector4[];
  43958. updatable?: boolean;
  43959. hasRings?: boolean;
  43960. enclose?: boolean;
  43961. cap?: number;
  43962. sideOrientation?: number;
  43963. frontUVs?: Vector4;
  43964. backUVs?: Vector4;
  43965. }, scene: any): Mesh;
  43966. }
  43967. }
  43968. declare module "babylonjs/XR/webXRTypes" {
  43969. import { Nullable } from "babylonjs/types";
  43970. import { IDisposable } from "babylonjs/scene";
  43971. /**
  43972. * States of the webXR experience
  43973. */
  43974. export enum WebXRState {
  43975. /**
  43976. * Transitioning to being in XR mode
  43977. */
  43978. ENTERING_XR = 0,
  43979. /**
  43980. * Transitioning to non XR mode
  43981. */
  43982. EXITING_XR = 1,
  43983. /**
  43984. * In XR mode and presenting
  43985. */
  43986. IN_XR = 2,
  43987. /**
  43988. * Not entered XR mode
  43989. */
  43990. NOT_IN_XR = 3
  43991. }
  43992. /**
  43993. * Abstraction of the XR render target
  43994. */
  43995. export interface WebXRRenderTarget extends IDisposable {
  43996. /**
  43997. * xrpresent context of the canvas which can be used to display/mirror xr content
  43998. */
  43999. canvasContext: WebGLRenderingContext;
  44000. /**
  44001. * xr layer for the canvas
  44002. */
  44003. xrLayer: Nullable<XRWebGLLayer>;
  44004. /**
  44005. * Initializes the xr layer for the session
  44006. * @param xrSession xr session
  44007. * @returns a promise that will resolve once the XR Layer has been created
  44008. */
  44009. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44010. }
  44011. }
  44012. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44013. import { Nullable } from "babylonjs/types";
  44014. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44015. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44016. /**
  44017. * COnfiguration object for WebXR output canvas
  44018. */
  44019. export class WebXRManagedOutputCanvasOptions {
  44020. /**
  44021. * An optional canvas in case you wish to create it yourself and provide it here.
  44022. * If not provided, a new canvas will be created
  44023. */
  44024. canvasElement?: HTMLCanvasElement;
  44025. /**
  44026. * Options for this XR Layer output
  44027. */
  44028. canvasOptions?: XRWebGLLayerOptions;
  44029. /**
  44030. * CSS styling for a newly created canvas (if not provided)
  44031. */
  44032. newCanvasCssStyle?: string;
  44033. /**
  44034. * Get the default values of the configuration object
  44035. * @returns default values of this configuration object
  44036. */
  44037. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44038. }
  44039. /**
  44040. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44041. */
  44042. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44043. private _options;
  44044. private _canvas;
  44045. private _engine;
  44046. /**
  44047. * Rendering context of the canvas which can be used to display/mirror xr content
  44048. */
  44049. canvasContext: WebGLRenderingContext;
  44050. /**
  44051. * xr layer for the canvas
  44052. */
  44053. xrLayer: Nullable<XRWebGLLayer>;
  44054. /**
  44055. * Initializes the canvas to be added/removed upon entering/exiting xr
  44056. * @param _xrSessionManager The XR Session manager
  44057. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44058. */
  44059. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44060. /**
  44061. * Disposes of the object
  44062. */
  44063. dispose(): void;
  44064. /**
  44065. * Initializes the xr layer for the session
  44066. * @param xrSession xr session
  44067. * @returns a promise that will resolve once the XR Layer has been created
  44068. */
  44069. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44070. private _addCanvas;
  44071. private _removeCanvas;
  44072. private _setManagedOutputCanvas;
  44073. }
  44074. }
  44075. declare module "babylonjs/XR/webXRSessionManager" {
  44076. import { Observable } from "babylonjs/Misc/observable";
  44077. import { Nullable } from "babylonjs/types";
  44078. import { IDisposable, Scene } from "babylonjs/scene";
  44079. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44080. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44081. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44082. /**
  44083. * Manages an XRSession to work with Babylon's engine
  44084. * @see https://doc.babylonjs.com/how_to/webxr
  44085. */
  44086. export class WebXRSessionManager implements IDisposable {
  44087. /** The scene which the session should be created for */
  44088. scene: Scene;
  44089. private _referenceSpace;
  44090. private _rttProvider;
  44091. private _sessionEnded;
  44092. private _xrNavigator;
  44093. private baseLayer;
  44094. /**
  44095. * The base reference space from which the session started. good if you want to reset your
  44096. * reference space
  44097. */
  44098. baseReferenceSpace: XRReferenceSpace;
  44099. /**
  44100. * Current XR frame
  44101. */
  44102. currentFrame: Nullable<XRFrame>;
  44103. /** WebXR timestamp updated every frame */
  44104. currentTimestamp: number;
  44105. /**
  44106. * Used just in case of a failure to initialize an immersive session.
  44107. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44108. */
  44109. defaultHeightCompensation: number;
  44110. /**
  44111. * Fires every time a new xrFrame arrives which can be used to update the camera
  44112. */
  44113. onXRFrameObservable: Observable<XRFrame>;
  44114. /**
  44115. * Fires when the reference space changed
  44116. */
  44117. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44118. /**
  44119. * Fires when the xr session is ended either by the device or manually done
  44120. */
  44121. onXRSessionEnded: Observable<any>;
  44122. /**
  44123. * Fires when the xr session is ended either by the device or manually done
  44124. */
  44125. onXRSessionInit: Observable<XRSession>;
  44126. /**
  44127. * Underlying xr session
  44128. */
  44129. session: XRSession;
  44130. /**
  44131. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44132. * or get the offset the player is currently at.
  44133. */
  44134. viewerReferenceSpace: XRReferenceSpace;
  44135. /**
  44136. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44137. * @param scene The scene which the session should be created for
  44138. */
  44139. constructor(
  44140. /** The scene which the session should be created for */
  44141. scene: Scene);
  44142. /**
  44143. * The current reference space used in this session. This reference space can constantly change!
  44144. * It is mainly used to offset the camera's position.
  44145. */
  44146. get referenceSpace(): XRReferenceSpace;
  44147. /**
  44148. * Set a new reference space and triggers the observable
  44149. */
  44150. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44151. /**
  44152. * Disposes of the session manager
  44153. */
  44154. dispose(): void;
  44155. /**
  44156. * Stops the xrSession and restores the render loop
  44157. * @returns Promise which resolves after it exits XR
  44158. */
  44159. exitXRAsync(): Promise<void>;
  44160. /**
  44161. * Gets the correct render target texture to be rendered this frame for this eye
  44162. * @param eye the eye for which to get the render target
  44163. * @returns the render target for the specified eye
  44164. */
  44165. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44166. /**
  44167. * Creates a WebXRRenderTarget object for the XR session
  44168. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44169. * @param options optional options to provide when creating a new render target
  44170. * @returns a WebXR render target to which the session can render
  44171. */
  44172. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44173. /**
  44174. * Initializes the manager
  44175. * After initialization enterXR can be called to start an XR session
  44176. * @returns Promise which resolves after it is initialized
  44177. */
  44178. initializeAsync(): Promise<void>;
  44179. /**
  44180. * Initializes an xr session
  44181. * @param xrSessionMode mode to initialize
  44182. * @param xrSessionInit defines optional and required values to pass to the session builder
  44183. * @returns a promise which will resolve once the session has been initialized
  44184. */
  44185. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44186. /**
  44187. * Checks if a session would be supported for the creation options specified
  44188. * @param sessionMode session mode to check if supported eg. immersive-vr
  44189. * @returns A Promise that resolves to true if supported and false if not
  44190. */
  44191. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44192. /**
  44193. * Resets the reference space to the one started the session
  44194. */
  44195. resetReferenceSpace(): void;
  44196. /**
  44197. * Starts rendering to the xr layer
  44198. */
  44199. runXRRenderLoop(): void;
  44200. /**
  44201. * Sets the reference space on the xr session
  44202. * @param referenceSpaceType space to set
  44203. * @returns a promise that will resolve once the reference space has been set
  44204. */
  44205. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44206. /**
  44207. * Updates the render state of the session
  44208. * @param state state to set
  44209. * @returns a promise that resolves once the render state has been updated
  44210. */
  44211. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44212. /**
  44213. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44214. * @param sessionMode defines the session to test
  44215. * @returns a promise with boolean as final value
  44216. */
  44217. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44218. private _createRenderTargetTexture;
  44219. }
  44220. }
  44221. declare module "babylonjs/XR/webXRCamera" {
  44222. import { Scene } from "babylonjs/scene";
  44223. import { Camera } from "babylonjs/Cameras/camera";
  44224. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44225. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44226. /**
  44227. * WebXR Camera which holds the views for the xrSession
  44228. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44229. */
  44230. export class WebXRCamera extends FreeCamera {
  44231. private _xrSessionManager;
  44232. private _firstFrame;
  44233. private _referenceQuaternion;
  44234. private _referencedPosition;
  44235. private _xrInvPositionCache;
  44236. private _xrInvQuaternionCache;
  44237. /**
  44238. * Should position compensation execute on first frame.
  44239. * This is used when copying the position from a native (non XR) camera
  44240. */
  44241. compensateOnFirstFrame: boolean;
  44242. /**
  44243. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44244. * @param name the name of the camera
  44245. * @param scene the scene to add the camera to
  44246. * @param _xrSessionManager a constructed xr session manager
  44247. */
  44248. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44249. /**
  44250. * Return the user's height, unrelated to the current ground.
  44251. * This will be the y position of this camera, when ground level is 0.
  44252. */
  44253. get realWorldHeight(): number;
  44254. /** @hidden */
  44255. _updateForDualEyeDebugging(): void;
  44256. /**
  44257. * Sets this camera's transformation based on a non-vr camera
  44258. * @param otherCamera the non-vr camera to copy the transformation from
  44259. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44260. */
  44261. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44262. /**
  44263. * Gets the current instance class name ("WebXRCamera").
  44264. * @returns the class name
  44265. */
  44266. getClassName(): string;
  44267. private _updateFromXRSession;
  44268. private _updateNumberOfRigCameras;
  44269. private _updateReferenceSpace;
  44270. private _updateReferenceSpaceOffset;
  44271. }
  44272. }
  44273. declare module "babylonjs/XR/webXRFeaturesManager" {
  44274. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44275. import { IDisposable } from "babylonjs/scene";
  44276. /**
  44277. * Defining the interface required for a (webxr) feature
  44278. */
  44279. export interface IWebXRFeature extends IDisposable {
  44280. /**
  44281. * Is this feature attached
  44282. */
  44283. attached: boolean;
  44284. /**
  44285. * Should auto-attach be disabled?
  44286. */
  44287. disableAutoAttach: boolean;
  44288. /**
  44289. * Attach the feature to the session
  44290. * Will usually be called by the features manager
  44291. *
  44292. * @param force should attachment be forced (even when already attached)
  44293. * @returns true if successful.
  44294. */
  44295. attach(force?: boolean): boolean;
  44296. /**
  44297. * Detach the feature from the session
  44298. * Will usually be called by the features manager
  44299. *
  44300. * @returns true if successful.
  44301. */
  44302. detach(): boolean;
  44303. }
  44304. /**
  44305. * A list of the currently available features without referencing them
  44306. */
  44307. export class WebXRFeatureName {
  44308. /**
  44309. * The name of the anchor system feature
  44310. */
  44311. static ANCHOR_SYSTEM: string;
  44312. /**
  44313. * The name of the background remover feature
  44314. */
  44315. static BACKGROUND_REMOVER: string;
  44316. /**
  44317. * The name of the hit test feature
  44318. */
  44319. static HIT_TEST: string;
  44320. /**
  44321. * physics impostors for xr controllers feature
  44322. */
  44323. static PHYSICS_CONTROLLERS: string;
  44324. /**
  44325. * The name of the plane detection feature
  44326. */
  44327. static PLANE_DETECTION: string;
  44328. /**
  44329. * The name of the pointer selection feature
  44330. */
  44331. static POINTER_SELECTION: string;
  44332. /**
  44333. * The name of the teleportation feature
  44334. */
  44335. static TELEPORTATION: string;
  44336. }
  44337. /**
  44338. * Defining the constructor of a feature. Used to register the modules.
  44339. */
  44340. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44341. /**
  44342. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44343. * It is mainly used in AR sessions.
  44344. *
  44345. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44346. */
  44347. export class WebXRFeaturesManager implements IDisposable {
  44348. private _xrSessionManager;
  44349. private static readonly _AvailableFeatures;
  44350. private _features;
  44351. /**
  44352. * constructs a new features manages.
  44353. *
  44354. * @param _xrSessionManager an instance of WebXRSessionManager
  44355. */
  44356. constructor(_xrSessionManager: WebXRSessionManager);
  44357. /**
  44358. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44359. * Mainly used internally.
  44360. *
  44361. * @param featureName the name of the feature to register
  44362. * @param constructorFunction the function used to construct the module
  44363. * @param version the (babylon) version of the module
  44364. * @param stable is that a stable version of this module
  44365. */
  44366. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44367. /**
  44368. * Returns a constructor of a specific feature.
  44369. *
  44370. * @param featureName the name of the feature to construct
  44371. * @param version the version of the feature to load
  44372. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44373. * @param options optional options provided to the module.
  44374. * @returns a function that, when called, will return a new instance of this feature
  44375. */
  44376. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44377. /**
  44378. * Can be used to return the list of features currently registered
  44379. *
  44380. * @returns an Array of available features
  44381. */
  44382. static GetAvailableFeatures(): string[];
  44383. /**
  44384. * Gets the versions available for a specific feature
  44385. * @param featureName the name of the feature
  44386. * @returns an array with the available versions
  44387. */
  44388. static GetAvailableVersions(featureName: string): string[];
  44389. /**
  44390. * Return the latest unstable version of this feature
  44391. * @param featureName the name of the feature to search
  44392. * @returns the version number. if not found will return -1
  44393. */
  44394. static GetLatestVersionOfFeature(featureName: string): number;
  44395. /**
  44396. * Return the latest stable version of this feature
  44397. * @param featureName the name of the feature to search
  44398. * @returns the version number. if not found will return -1
  44399. */
  44400. static GetStableVersionOfFeature(featureName: string): number;
  44401. /**
  44402. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44403. * Can be used during a session to start a feature
  44404. * @param featureName the name of feature to attach
  44405. */
  44406. attachFeature(featureName: string): void;
  44407. /**
  44408. * Can be used inside a session or when the session ends to detach a specific feature
  44409. * @param featureName the name of the feature to detach
  44410. */
  44411. detachFeature(featureName: string): void;
  44412. /**
  44413. * Used to disable an already-enabled feature
  44414. * The feature will be disposed and will be recreated once enabled.
  44415. * @param featureName the feature to disable
  44416. * @returns true if disable was successful
  44417. */
  44418. disableFeature(featureName: string | {
  44419. Name: string;
  44420. }): boolean;
  44421. /**
  44422. * dispose this features manager
  44423. */
  44424. dispose(): void;
  44425. /**
  44426. * 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.
  44427. * 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.
  44428. *
  44429. * @param featureName the name of the feature to load or the class of the feature
  44430. * @param version optional version to load. if not provided the latest version will be enabled
  44431. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44432. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44433. * @returns a new constructed feature or throws an error if feature not found.
  44434. */
  44435. enableFeature(featureName: string | {
  44436. Name: string;
  44437. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44438. /**
  44439. * get the implementation of an enabled feature.
  44440. * @param featureName the name of the feature to load
  44441. * @returns the feature class, if found
  44442. */
  44443. getEnabledFeature(featureName: string): IWebXRFeature;
  44444. /**
  44445. * Get the list of enabled features
  44446. * @returns an array of enabled features
  44447. */
  44448. getEnabledFeatures(): string[];
  44449. }
  44450. }
  44451. declare module "babylonjs/XR/webXRExperienceHelper" {
  44452. import { Observable } from "babylonjs/Misc/observable";
  44453. import { IDisposable, Scene } from "babylonjs/scene";
  44454. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44455. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44456. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44457. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44458. /**
  44459. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44460. * @see https://doc.babylonjs.com/how_to/webxr
  44461. */
  44462. export class WebXRExperienceHelper implements IDisposable {
  44463. private scene;
  44464. private _nonVRCamera;
  44465. private _originalSceneAutoClear;
  44466. private _supported;
  44467. /**
  44468. * Camera used to render xr content
  44469. */
  44470. camera: WebXRCamera;
  44471. /** A features manager for this xr session */
  44472. featuresManager: WebXRFeaturesManager;
  44473. /**
  44474. * Observers registered here will be triggered after the camera's initial transformation is set
  44475. * This can be used to set a different ground level or an extra rotation.
  44476. *
  44477. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44478. * to the position set after this observable is done executing.
  44479. */
  44480. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44481. /**
  44482. * Fires when the state of the experience helper has changed
  44483. */
  44484. onStateChangedObservable: Observable<WebXRState>;
  44485. /** Session manager used to keep track of xr session */
  44486. sessionManager: WebXRSessionManager;
  44487. /**
  44488. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44489. */
  44490. state: WebXRState;
  44491. /**
  44492. * Creates a WebXRExperienceHelper
  44493. * @param scene The scene the helper should be created in
  44494. */
  44495. private constructor();
  44496. /**
  44497. * Creates the experience helper
  44498. * @param scene the scene to attach the experience helper to
  44499. * @returns a promise for the experience helper
  44500. */
  44501. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44502. /**
  44503. * Disposes of the experience helper
  44504. */
  44505. dispose(): void;
  44506. /**
  44507. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44508. * @param sessionMode options for the XR session
  44509. * @param referenceSpaceType frame of reference of the XR session
  44510. * @param renderTarget the output canvas that will be used to enter XR mode
  44511. * @returns promise that resolves after xr mode has entered
  44512. */
  44513. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44514. /**
  44515. * Exits XR mode and returns the scene to its original state
  44516. * @returns promise that resolves after xr mode has exited
  44517. */
  44518. exitXRAsync(): Promise<void>;
  44519. private _nonXRToXRCamera;
  44520. private _setState;
  44521. }
  44522. }
  44523. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44524. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44525. import { Observable } from "babylonjs/Misc/observable";
  44526. import { IDisposable } from "babylonjs/scene";
  44527. /**
  44528. * X-Y values for axes in WebXR
  44529. */
  44530. export interface IWebXRMotionControllerAxesValue {
  44531. /**
  44532. * The value of the x axis
  44533. */
  44534. x: number;
  44535. /**
  44536. * The value of the y-axis
  44537. */
  44538. y: number;
  44539. }
  44540. /**
  44541. * changed / previous values for the values of this component
  44542. */
  44543. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44544. /**
  44545. * current (this frame) value
  44546. */
  44547. current: T;
  44548. /**
  44549. * previous (last change) value
  44550. */
  44551. previous: T;
  44552. }
  44553. /**
  44554. * Represents changes in the component between current frame and last values recorded
  44555. */
  44556. export interface IWebXRMotionControllerComponentChanges {
  44557. /**
  44558. * will be populated with previous and current values if axes changed
  44559. */
  44560. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44561. /**
  44562. * will be populated with previous and current values if pressed changed
  44563. */
  44564. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44565. /**
  44566. * will be populated with previous and current values if touched changed
  44567. */
  44568. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44569. /**
  44570. * will be populated with previous and current values if value changed
  44571. */
  44572. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44573. }
  44574. /**
  44575. * This class represents a single component (for example button or thumbstick) of a motion controller
  44576. */
  44577. export class WebXRControllerComponent implements IDisposable {
  44578. /**
  44579. * the id of this component
  44580. */
  44581. id: string;
  44582. /**
  44583. * the type of the component
  44584. */
  44585. type: MotionControllerComponentType;
  44586. private _buttonIndex;
  44587. private _axesIndices;
  44588. private _axes;
  44589. private _changes;
  44590. private _currentValue;
  44591. private _hasChanges;
  44592. private _pressed;
  44593. private _touched;
  44594. /**
  44595. * button component type
  44596. */
  44597. static BUTTON_TYPE: MotionControllerComponentType;
  44598. /**
  44599. * squeeze component type
  44600. */
  44601. static SQUEEZE_TYPE: MotionControllerComponentType;
  44602. /**
  44603. * Thumbstick component type
  44604. */
  44605. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44606. /**
  44607. * Touchpad component type
  44608. */
  44609. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44610. /**
  44611. * trigger component type
  44612. */
  44613. static TRIGGER_TYPE: MotionControllerComponentType;
  44614. /**
  44615. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44616. * the axes data changes
  44617. */
  44618. onAxisValueChangedObservable: Observable<{
  44619. x: number;
  44620. y: number;
  44621. }>;
  44622. /**
  44623. * Observers registered here will be triggered when the state of a button changes
  44624. * State change is either pressed / touched / value
  44625. */
  44626. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44627. /**
  44628. * Creates a new component for a motion controller.
  44629. * It is created by the motion controller itself
  44630. *
  44631. * @param id the id of this component
  44632. * @param type the type of the component
  44633. * @param _buttonIndex index in the buttons array of the gamepad
  44634. * @param _axesIndices indices of the values in the axes array of the gamepad
  44635. */
  44636. constructor(
  44637. /**
  44638. * the id of this component
  44639. */
  44640. id: string,
  44641. /**
  44642. * the type of the component
  44643. */
  44644. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44645. /**
  44646. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44647. */
  44648. get axes(): IWebXRMotionControllerAxesValue;
  44649. /**
  44650. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44651. */
  44652. get changes(): IWebXRMotionControllerComponentChanges;
  44653. /**
  44654. * Return whether or not the component changed the last frame
  44655. */
  44656. get hasChanges(): boolean;
  44657. /**
  44658. * is the button currently pressed
  44659. */
  44660. get pressed(): boolean;
  44661. /**
  44662. * is the button currently touched
  44663. */
  44664. get touched(): boolean;
  44665. /**
  44666. * Get the current value of this component
  44667. */
  44668. get value(): number;
  44669. /**
  44670. * Dispose this component
  44671. */
  44672. dispose(): void;
  44673. /**
  44674. * Are there axes correlating to this component
  44675. * @return true is axes data is available
  44676. */
  44677. isAxes(): boolean;
  44678. /**
  44679. * Is this component a button (hence - pressable)
  44680. * @returns true if can be pressed
  44681. */
  44682. isButton(): boolean;
  44683. /**
  44684. * update this component using the gamepad object it is in. Called on every frame
  44685. * @param nativeController the native gamepad controller object
  44686. */
  44687. update(nativeController: IMinimalMotionControllerObject): void;
  44688. }
  44689. }
  44690. declare module "babylonjs/Loading/sceneLoader" {
  44691. import { Observable } from "babylonjs/Misc/observable";
  44692. import { Nullable } from "babylonjs/types";
  44693. import { Scene } from "babylonjs/scene";
  44694. import { Engine } from "babylonjs/Engines/engine";
  44695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44696. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44697. import { AssetContainer } from "babylonjs/assetContainer";
  44698. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44699. import { Skeleton } from "babylonjs/Bones/skeleton";
  44700. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44701. import { WebRequest } from "babylonjs/Misc/webRequest";
  44702. /**
  44703. * Class used to represent data loading progression
  44704. */
  44705. export class SceneLoaderProgressEvent {
  44706. /** defines if data length to load can be evaluated */
  44707. readonly lengthComputable: boolean;
  44708. /** defines the loaded data length */
  44709. readonly loaded: number;
  44710. /** defines the data length to load */
  44711. readonly total: number;
  44712. /**
  44713. * Create a new progress event
  44714. * @param lengthComputable defines if data length to load can be evaluated
  44715. * @param loaded defines the loaded data length
  44716. * @param total defines the data length to load
  44717. */
  44718. constructor(
  44719. /** defines if data length to load can be evaluated */
  44720. lengthComputable: boolean,
  44721. /** defines the loaded data length */
  44722. loaded: number,
  44723. /** defines the data length to load */
  44724. total: number);
  44725. /**
  44726. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44727. * @param event defines the source event
  44728. * @returns a new SceneLoaderProgressEvent
  44729. */
  44730. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44731. }
  44732. /**
  44733. * Interface used by SceneLoader plugins to define supported file extensions
  44734. */
  44735. export interface ISceneLoaderPluginExtensions {
  44736. /**
  44737. * Defines the list of supported extensions
  44738. */
  44739. [extension: string]: {
  44740. isBinary: boolean;
  44741. };
  44742. }
  44743. /**
  44744. * Interface used by SceneLoader plugin factory
  44745. */
  44746. export interface ISceneLoaderPluginFactory {
  44747. /**
  44748. * Defines the name of the factory
  44749. */
  44750. name: string;
  44751. /**
  44752. * Function called to create a new plugin
  44753. * @return the new plugin
  44754. */
  44755. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44756. /**
  44757. * The callback that returns true if the data can be directly loaded.
  44758. * @param data string containing the file data
  44759. * @returns if the data can be loaded directly
  44760. */
  44761. canDirectLoad?(data: string): boolean;
  44762. }
  44763. /**
  44764. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44765. */
  44766. export interface ISceneLoaderPluginBase {
  44767. /**
  44768. * The friendly name of this plugin.
  44769. */
  44770. name: string;
  44771. /**
  44772. * The file extensions supported by this plugin.
  44773. */
  44774. extensions: string | ISceneLoaderPluginExtensions;
  44775. /**
  44776. * The callback called when loading from a url.
  44777. * @param scene scene loading this url
  44778. * @param url url to load
  44779. * @param onSuccess callback called when the file successfully loads
  44780. * @param onProgress callback called while file is loading (if the server supports this mode)
  44781. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44782. * @param onError callback called when the file fails to load
  44783. * @returns a file request object
  44784. */
  44785. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44786. /**
  44787. * The callback called when loading from a file object.
  44788. * @param scene scene loading this file
  44789. * @param file defines the file to load
  44790. * @param onSuccess defines the callback to call when data is loaded
  44791. * @param onProgress defines the callback to call during loading process
  44792. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44793. * @param onError defines the callback to call when an error occurs
  44794. * @returns a file request object
  44795. */
  44796. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44797. /**
  44798. * The callback that returns true if the data can be directly loaded.
  44799. * @param data string containing the file data
  44800. * @returns if the data can be loaded directly
  44801. */
  44802. canDirectLoad?(data: string): boolean;
  44803. /**
  44804. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44805. * @param scene scene loading this data
  44806. * @param data string containing the data
  44807. * @returns data to pass to the plugin
  44808. */
  44809. directLoad?(scene: Scene, data: string): any;
  44810. /**
  44811. * The callback that allows custom handling of the root url based on the response url.
  44812. * @param rootUrl the original root url
  44813. * @param responseURL the response url if available
  44814. * @returns the new root url
  44815. */
  44816. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44817. }
  44818. /**
  44819. * Interface used to define a SceneLoader plugin
  44820. */
  44821. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44822. /**
  44823. * Import meshes into a scene.
  44824. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44825. * @param scene The scene to import into
  44826. * @param data The data to import
  44827. * @param rootUrl The root url for scene and resources
  44828. * @param meshes The meshes array to import into
  44829. * @param particleSystems The particle systems array to import into
  44830. * @param skeletons The skeletons array to import into
  44831. * @param onError The callback when import fails
  44832. * @returns True if successful or false otherwise
  44833. */
  44834. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44835. /**
  44836. * Load into a scene.
  44837. * @param scene The scene to load into
  44838. * @param data The data to import
  44839. * @param rootUrl The root url for scene and resources
  44840. * @param onError The callback when import fails
  44841. * @returns True if successful or false otherwise
  44842. */
  44843. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44844. /**
  44845. * Load into an asset container.
  44846. * @param scene The scene to load into
  44847. * @param data The data to import
  44848. * @param rootUrl The root url for scene and resources
  44849. * @param onError The callback when import fails
  44850. * @returns The loaded asset container
  44851. */
  44852. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44853. }
  44854. /**
  44855. * Interface used to define an async SceneLoader plugin
  44856. */
  44857. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44858. /**
  44859. * Import meshes into a scene.
  44860. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44861. * @param scene The scene to import into
  44862. * @param data The data to import
  44863. * @param rootUrl The root url for scene and resources
  44864. * @param onProgress The callback when the load progresses
  44865. * @param fileName Defines the name of the file to load
  44866. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44867. */
  44868. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44869. meshes: AbstractMesh[];
  44870. particleSystems: IParticleSystem[];
  44871. skeletons: Skeleton[];
  44872. animationGroups: AnimationGroup[];
  44873. }>;
  44874. /**
  44875. * Load into a scene.
  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 Nothing
  44882. */
  44883. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44884. /**
  44885. * Load into an asset container.
  44886. * @param scene The scene to load into
  44887. * @param data The data to import
  44888. * @param rootUrl The root url for scene and resources
  44889. * @param onProgress The callback when the load progresses
  44890. * @param fileName Defines the name of the file to load
  44891. * @returns The loaded asset container
  44892. */
  44893. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44894. }
  44895. /**
  44896. * Mode that determines how to handle old animation groups before loading new ones.
  44897. */
  44898. export enum SceneLoaderAnimationGroupLoadingMode {
  44899. /**
  44900. * Reset all old animations to initial state then dispose them.
  44901. */
  44902. Clean = 0,
  44903. /**
  44904. * Stop all old animations.
  44905. */
  44906. Stop = 1,
  44907. /**
  44908. * Restart old animations from first frame.
  44909. */
  44910. Sync = 2,
  44911. /**
  44912. * Old animations remains untouched.
  44913. */
  44914. NoSync = 3
  44915. }
  44916. /**
  44917. * Class used to load scene from various file formats using registered plugins
  44918. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44919. */
  44920. export class SceneLoader {
  44921. /**
  44922. * No logging while loading
  44923. */
  44924. static readonly NO_LOGGING: number;
  44925. /**
  44926. * Minimal logging while loading
  44927. */
  44928. static readonly MINIMAL_LOGGING: number;
  44929. /**
  44930. * Summary logging while loading
  44931. */
  44932. static readonly SUMMARY_LOGGING: number;
  44933. /**
  44934. * Detailled logging while loading
  44935. */
  44936. static readonly DETAILED_LOGGING: number;
  44937. /**
  44938. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44939. */
  44940. static get ForceFullSceneLoadingForIncremental(): boolean;
  44941. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44942. /**
  44943. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44944. */
  44945. static get ShowLoadingScreen(): boolean;
  44946. static set ShowLoadingScreen(value: boolean);
  44947. /**
  44948. * Defines the current logging level (while loading the scene)
  44949. * @ignorenaming
  44950. */
  44951. static get loggingLevel(): number;
  44952. static set loggingLevel(value: number);
  44953. /**
  44954. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44955. */
  44956. static get CleanBoneMatrixWeights(): boolean;
  44957. static set CleanBoneMatrixWeights(value: boolean);
  44958. /**
  44959. * Event raised when a plugin is used to load a scene
  44960. */
  44961. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44962. private static _registeredPlugins;
  44963. private static _getDefaultPlugin;
  44964. private static _getPluginForExtension;
  44965. private static _getPluginForDirectLoad;
  44966. private static _getPluginForFilename;
  44967. private static _getDirectLoad;
  44968. private static _loadData;
  44969. private static _getFileInfo;
  44970. /**
  44971. * Gets a plugin that can load the given extension
  44972. * @param extension defines the extension to load
  44973. * @returns a plugin or null if none works
  44974. */
  44975. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44976. /**
  44977. * Gets a boolean indicating that the given extension can be loaded
  44978. * @param extension defines the extension to load
  44979. * @returns true if the extension is supported
  44980. */
  44981. static IsPluginForExtensionAvailable(extension: string): boolean;
  44982. /**
  44983. * Adds a new plugin to the list of registered plugins
  44984. * @param plugin defines the plugin to add
  44985. */
  44986. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44987. /**
  44988. * Import meshes into a scene
  44989. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44990. * @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)
  44991. * @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)
  44992. * @param scene the instance of BABYLON.Scene to append to
  44993. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44994. * @param onProgress a callback with a progress event for each file being loaded
  44995. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44996. * @param pluginExtension the extension used to determine the plugin
  44997. * @returns The loaded plugin
  44998. */
  44999. 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>;
  45000. /**
  45001. * Import meshes into a scene
  45002. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45003. * @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)
  45004. * @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)
  45005. * @param scene the instance of BABYLON.Scene to append to
  45006. * @param onProgress a callback with a progress event for each file being loaded
  45007. * @param pluginExtension the extension used to determine the plugin
  45008. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45009. */
  45010. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45011. meshes: AbstractMesh[];
  45012. particleSystems: IParticleSystem[];
  45013. skeletons: Skeleton[];
  45014. animationGroups: AnimationGroup[];
  45015. }>;
  45016. /**
  45017. * Load a scene
  45018. * @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)
  45019. * @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)
  45020. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45021. * @param onSuccess a callback with the scene when import succeeds
  45022. * @param onProgress a callback with a progress event for each file being loaded
  45023. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45024. * @param pluginExtension the extension used to determine the plugin
  45025. * @returns The loaded plugin
  45026. */
  45027. 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>;
  45028. /**
  45029. * Load 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 engine is the instance of BABYLON.Engine to use to create the scene
  45033. * @param onProgress a callback with a progress event for each file being loaded
  45034. * @param pluginExtension the extension used to determine the plugin
  45035. * @returns The loaded scene
  45036. */
  45037. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45038. /**
  45039. * Append a scene
  45040. * @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)
  45041. * @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)
  45042. * @param scene is the instance of BABYLON.Scene to append to
  45043. * @param onSuccess a callback with the scene when import succeeds
  45044. * @param onProgress a callback with a progress event for each file being loaded
  45045. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45046. * @param pluginExtension the extension used to determine the plugin
  45047. * @returns The loaded plugin
  45048. */
  45049. 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>;
  45050. /**
  45051. * Append a scene
  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
  45055. * @param onProgress a callback with a progress event for each file being loaded
  45056. * @param pluginExtension the extension used to determine the plugin
  45057. * @returns The given scene
  45058. */
  45059. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45060. /**
  45061. * Load a scene into an asset container
  45062. * @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)
  45063. * @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)
  45064. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45065. * @param onSuccess a callback with the scene when import succeeds
  45066. * @param onProgress a callback with a progress event for each file being loaded
  45067. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45068. * @param pluginExtension the extension used to determine the plugin
  45069. * @returns The loaded plugin
  45070. */
  45071. 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>;
  45072. /**
  45073. * Load a scene into an asset container
  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 (default: empty string)
  45076. * @param scene is the instance of Scene to append to
  45077. * @param onProgress a callback with a progress event for each file being loaded
  45078. * @param pluginExtension the extension used to determine the plugin
  45079. * @returns The loaded asset container
  45080. */
  45081. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45082. /**
  45083. * Import animations from a file into a scene
  45084. * @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)
  45085. * @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)
  45086. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45087. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45088. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45089. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45090. * @param onSuccess a callback with the scene when import succeeds
  45091. * @param onProgress a callback with a progress event for each file being loaded
  45092. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45093. */
  45094. 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;
  45095. /**
  45096. * Import animations from a file into a scene
  45097. * @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)
  45098. * @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)
  45099. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45100. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45101. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45102. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45103. * @param onSuccess a callback with the scene when import succeeds
  45104. * @param onProgress a callback with a progress event for each file being loaded
  45105. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45106. * @returns the updated scene with imported animations
  45107. */
  45108. 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>;
  45109. }
  45110. }
  45111. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45112. import { IDisposable, Scene } from "babylonjs/scene";
  45113. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45114. import { Observable } from "babylonjs/Misc/observable";
  45115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45116. import { Nullable } from "babylonjs/types";
  45117. /**
  45118. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45119. */
  45120. export type MotionControllerHandness = "none" | "left" | "right";
  45121. /**
  45122. * The type of components available in motion controllers.
  45123. * This is not the name of the component.
  45124. */
  45125. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45126. /**
  45127. * The state of a controller component
  45128. */
  45129. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45130. /**
  45131. * The schema of motion controller layout.
  45132. * No object will be initialized using this interface
  45133. * This is used just to define the profile.
  45134. */
  45135. export interface IMotionControllerLayout {
  45136. /**
  45137. * Path to load the assets. Usually relative to the base path
  45138. */
  45139. assetPath: string;
  45140. /**
  45141. * Available components (unsorted)
  45142. */
  45143. components: {
  45144. /**
  45145. * A map of component Ids
  45146. */
  45147. [componentId: string]: {
  45148. /**
  45149. * The type of input the component outputs
  45150. */
  45151. type: MotionControllerComponentType;
  45152. /**
  45153. * The indices of this component in the gamepad object
  45154. */
  45155. gamepadIndices: {
  45156. /**
  45157. * Index of button
  45158. */
  45159. button?: number;
  45160. /**
  45161. * If available, index of x-axis
  45162. */
  45163. xAxis?: number;
  45164. /**
  45165. * If available, index of y-axis
  45166. */
  45167. yAxis?: number;
  45168. };
  45169. /**
  45170. * The mesh's root node name
  45171. */
  45172. rootNodeName: string;
  45173. /**
  45174. * Animation definitions for this model
  45175. */
  45176. visualResponses: {
  45177. [stateKey: string]: {
  45178. /**
  45179. * What property will be animated
  45180. */
  45181. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45182. /**
  45183. * What states influence this visual response
  45184. */
  45185. states: MotionControllerComponentStateType[];
  45186. /**
  45187. * Type of animation - movement or visibility
  45188. */
  45189. valueNodeProperty: "transform" | "visibility";
  45190. /**
  45191. * Base node name to move. Its position will be calculated according to the min and max nodes
  45192. */
  45193. valueNodeName?: string;
  45194. /**
  45195. * Minimum movement node
  45196. */
  45197. minNodeName?: string;
  45198. /**
  45199. * Max movement node
  45200. */
  45201. maxNodeName?: string;
  45202. };
  45203. };
  45204. /**
  45205. * If touch enabled, what is the name of node to display user feedback
  45206. */
  45207. touchPointNodeName?: string;
  45208. };
  45209. };
  45210. /**
  45211. * Is it xr standard mapping or not
  45212. */
  45213. gamepadMapping: "" | "xr-standard";
  45214. /**
  45215. * Base root node of this entire model
  45216. */
  45217. rootNodeName: string;
  45218. /**
  45219. * Defines the main button component id
  45220. */
  45221. selectComponentId: string;
  45222. }
  45223. /**
  45224. * A definition for the layout map in the input profile
  45225. */
  45226. export interface IMotionControllerLayoutMap {
  45227. /**
  45228. * Layouts with handness type as a key
  45229. */
  45230. [handness: string]: IMotionControllerLayout;
  45231. }
  45232. /**
  45233. * The XR Input profile schema
  45234. * Profiles can be found here:
  45235. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45236. */
  45237. export interface IMotionControllerProfile {
  45238. /**
  45239. * fallback profiles for this profileId
  45240. */
  45241. fallbackProfileIds: string[];
  45242. /**
  45243. * The layout map, with handness as key
  45244. */
  45245. layouts: IMotionControllerLayoutMap;
  45246. /**
  45247. * The id of this profile
  45248. * correlates to the profile(s) in the xrInput.profiles array
  45249. */
  45250. profileId: string;
  45251. }
  45252. /**
  45253. * A helper-interface for the 3 meshes needed for controller button animation
  45254. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45255. */
  45256. export interface IMotionControllerButtonMeshMap {
  45257. /**
  45258. * the mesh that defines the pressed value mesh position.
  45259. * This is used to find the max-position of this button
  45260. */
  45261. pressedMesh: AbstractMesh;
  45262. /**
  45263. * the mesh that defines the unpressed value mesh position.
  45264. * This is used to find the min (or initial) position of this button
  45265. */
  45266. unpressedMesh: AbstractMesh;
  45267. /**
  45268. * The mesh that will be changed when value changes
  45269. */
  45270. valueMesh: AbstractMesh;
  45271. }
  45272. /**
  45273. * A helper-interface for the 3 meshes needed for controller axis animation.
  45274. * This will be expanded when touchpad animations are fully supported
  45275. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45276. */
  45277. export interface IMotionControllerMeshMap {
  45278. /**
  45279. * the mesh that defines the maximum value mesh position.
  45280. */
  45281. maxMesh?: AbstractMesh;
  45282. /**
  45283. * the mesh that defines the minimum value mesh position.
  45284. */
  45285. minMesh?: AbstractMesh;
  45286. /**
  45287. * The mesh that will be changed when axis value changes
  45288. */
  45289. valueMesh: AbstractMesh;
  45290. }
  45291. /**
  45292. * The elements needed for change-detection of the gamepad objects in motion controllers
  45293. */
  45294. export interface IMinimalMotionControllerObject {
  45295. /**
  45296. * Available axes of this controller
  45297. */
  45298. axes: number[];
  45299. /**
  45300. * An array of available buttons
  45301. */
  45302. buttons: Array<{
  45303. /**
  45304. * Value of the button/trigger
  45305. */
  45306. value: number;
  45307. /**
  45308. * If the button/trigger is currently touched
  45309. */
  45310. touched: boolean;
  45311. /**
  45312. * If the button/trigger is currently pressed
  45313. */
  45314. pressed: boolean;
  45315. }>;
  45316. }
  45317. /**
  45318. * An Abstract Motion controller
  45319. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45320. * Each component has an observable to check for changes in value and state
  45321. */
  45322. export abstract class WebXRAbstractMotionController implements IDisposable {
  45323. protected scene: Scene;
  45324. protected layout: IMotionControllerLayout;
  45325. /**
  45326. * The gamepad object correlating to this controller
  45327. */
  45328. gamepadObject: IMinimalMotionControllerObject;
  45329. /**
  45330. * handness (left/right/none) of this controller
  45331. */
  45332. handness: MotionControllerHandness;
  45333. private _initComponent;
  45334. private _modelReady;
  45335. /**
  45336. * A map of components (WebXRControllerComponent) in this motion controller
  45337. * Components have a ComponentType and can also have both button and axis definitions
  45338. */
  45339. readonly components: {
  45340. [id: string]: WebXRControllerComponent;
  45341. };
  45342. /**
  45343. * Disable the model's animation. Can be set at any time.
  45344. */
  45345. disableAnimation: boolean;
  45346. /**
  45347. * Observers registered here will be triggered when the model of this controller is done loading
  45348. */
  45349. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45350. /**
  45351. * The profile id of this motion controller
  45352. */
  45353. abstract profileId: string;
  45354. /**
  45355. * The root mesh of the model. It is null if the model was not yet initialized
  45356. */
  45357. rootMesh: Nullable<AbstractMesh>;
  45358. /**
  45359. * constructs a new abstract motion controller
  45360. * @param scene the scene to which the model of the controller will be added
  45361. * @param layout The profile layout to load
  45362. * @param gamepadObject The gamepad object correlating to this controller
  45363. * @param handness handness (left/right/none) of this controller
  45364. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45365. */
  45366. constructor(scene: Scene, layout: IMotionControllerLayout,
  45367. /**
  45368. * The gamepad object correlating to this controller
  45369. */
  45370. gamepadObject: IMinimalMotionControllerObject,
  45371. /**
  45372. * handness (left/right/none) of this controller
  45373. */
  45374. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45375. /**
  45376. * Dispose this controller, the model mesh and all its components
  45377. */
  45378. dispose(): void;
  45379. /**
  45380. * Returns all components of specific type
  45381. * @param type the type to search for
  45382. * @return an array of components with this type
  45383. */
  45384. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45385. /**
  45386. * get a component based an its component id as defined in layout.components
  45387. * @param id the id of the component
  45388. * @returns the component correlates to the id or undefined if not found
  45389. */
  45390. getComponent(id: string): WebXRControllerComponent;
  45391. /**
  45392. * Get the list of components available in this motion controller
  45393. * @returns an array of strings correlating to available components
  45394. */
  45395. getComponentIds(): string[];
  45396. /**
  45397. * Get the first component of specific type
  45398. * @param type type of component to find
  45399. * @return a controller component or null if not found
  45400. */
  45401. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45402. /**
  45403. * Get the main (Select) component of this controller as defined in the layout
  45404. * @returns the main component of this controller
  45405. */
  45406. getMainComponent(): WebXRControllerComponent;
  45407. /**
  45408. * Loads the model correlating to this controller
  45409. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45410. * @returns A promise fulfilled with the result of the model loading
  45411. */
  45412. loadModel(): Promise<boolean>;
  45413. /**
  45414. * Update this model using the current XRFrame
  45415. * @param xrFrame the current xr frame to use and update the model
  45416. */
  45417. updateFromXRFrame(xrFrame: XRFrame): void;
  45418. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45419. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45420. /**
  45421. * Moves the axis on the controller mesh based on its current state
  45422. * @param axis the index of the axis
  45423. * @param axisValue the value of the axis which determines the meshes new position
  45424. * @hidden
  45425. */
  45426. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45427. /**
  45428. * Update the model itself with the current frame data
  45429. * @param xrFrame the frame to use for updating the model mesh
  45430. */
  45431. protected updateModel(xrFrame: XRFrame): void;
  45432. /**
  45433. * Get the filename and path for this controller's model
  45434. * @returns a map of filename and path
  45435. */
  45436. protected abstract _getFilenameAndPath(): {
  45437. filename: string;
  45438. path: string;
  45439. };
  45440. /**
  45441. * This function is called before the mesh is loaded. It checks for loading constraints.
  45442. * For example, this function can check if the GLB loader is available
  45443. * If this function returns false, the generic controller will be loaded instead
  45444. * @returns Is the client ready to load the mesh
  45445. */
  45446. protected abstract _getModelLoadingConstraints(): boolean;
  45447. /**
  45448. * This function will be called after the model was successfully loaded and can be used
  45449. * for mesh transformations before it is available for the user
  45450. * @param meshes the loaded meshes
  45451. */
  45452. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45453. /**
  45454. * Set the root mesh for this controller. Important for the WebXR controller class
  45455. * @param meshes the loaded meshes
  45456. */
  45457. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45458. /**
  45459. * A function executed each frame that updates the mesh (if needed)
  45460. * @param xrFrame the current xrFrame
  45461. */
  45462. protected abstract _updateModel(xrFrame: XRFrame): void;
  45463. private _getGenericFilenameAndPath;
  45464. private _getGenericParentMesh;
  45465. }
  45466. }
  45467. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45468. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45470. import { Scene } from "babylonjs/scene";
  45471. /**
  45472. * A generic trigger-only motion controller for WebXR
  45473. */
  45474. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45475. /**
  45476. * Static version of the profile id of this controller
  45477. */
  45478. static ProfileId: string;
  45479. profileId: string;
  45480. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45481. protected _getFilenameAndPath(): {
  45482. filename: string;
  45483. path: string;
  45484. };
  45485. protected _getModelLoadingConstraints(): boolean;
  45486. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45487. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45488. protected _updateModel(): void;
  45489. }
  45490. }
  45491. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45492. import { Vector4 } from "babylonjs/Maths/math.vector";
  45493. import { Mesh } from "babylonjs/Meshes/mesh";
  45494. import { Scene } from "babylonjs/scene";
  45495. import { Nullable } from "babylonjs/types";
  45496. /**
  45497. * Class containing static functions to help procedurally build meshes
  45498. */
  45499. export class SphereBuilder {
  45500. /**
  45501. * Creates a sphere mesh
  45502. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45503. * * 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`)
  45504. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45505. * * 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
  45506. * * 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)
  45507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45510. * @param name defines the name of the mesh
  45511. * @param options defines the options used to create the mesh
  45512. * @param scene defines the hosting scene
  45513. * @returns the sphere mesh
  45514. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45515. */
  45516. static CreateSphere(name: string, options: {
  45517. segments?: number;
  45518. diameter?: number;
  45519. diameterX?: number;
  45520. diameterY?: number;
  45521. diameterZ?: number;
  45522. arc?: number;
  45523. slice?: number;
  45524. sideOrientation?: number;
  45525. frontUVs?: Vector4;
  45526. backUVs?: Vector4;
  45527. updatable?: boolean;
  45528. }, scene?: Nullable<Scene>): Mesh;
  45529. }
  45530. }
  45531. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45533. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45534. import { Scene } from "babylonjs/scene";
  45535. /**
  45536. * A profiled motion controller has its profile loaded from an online repository.
  45537. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45538. */
  45539. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45540. private _repositoryUrl;
  45541. private _buttonMeshMapping;
  45542. private _touchDots;
  45543. /**
  45544. * The profile ID of this controller. Will be populated when the controller initializes.
  45545. */
  45546. profileId: string;
  45547. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45548. dispose(): void;
  45549. protected _getFilenameAndPath(): {
  45550. filename: string;
  45551. path: string;
  45552. };
  45553. protected _getModelLoadingConstraints(): boolean;
  45554. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45555. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45556. protected _updateModel(_xrFrame: XRFrame): void;
  45557. }
  45558. }
  45559. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45560. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45561. import { Scene } from "babylonjs/scene";
  45562. /**
  45563. * A construction function type to create a new controller based on an xrInput object
  45564. */
  45565. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45566. /**
  45567. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45568. *
  45569. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45570. * it should be replaced with auto-loaded controllers.
  45571. *
  45572. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45573. */
  45574. export class WebXRMotionControllerManager {
  45575. private static _AvailableControllers;
  45576. private static _Fallbacks;
  45577. private static _ProfileLoadingPromises;
  45578. private static _ProfilesList;
  45579. /**
  45580. * The base URL of the online controller repository. Can be changed at any time.
  45581. */
  45582. static BaseRepositoryUrl: string;
  45583. /**
  45584. * Which repository gets priority - local or online
  45585. */
  45586. static PrioritizeOnlineRepository: boolean;
  45587. /**
  45588. * Use the online repository, or use only locally-defined controllers
  45589. */
  45590. static UseOnlineRepository: boolean;
  45591. /**
  45592. * Clear the cache used for profile loading and reload when requested again
  45593. */
  45594. static ClearProfilesCache(): void;
  45595. /**
  45596. * Register the default fallbacks.
  45597. * This function is called automatically when this file is imported.
  45598. */
  45599. static DefaultFallbacks(): void;
  45600. /**
  45601. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45602. * @param profileId the profile to which a fallback needs to be found
  45603. * @return an array with corresponding fallback profiles
  45604. */
  45605. static FindFallbackWithProfileId(profileId: string): string[];
  45606. /**
  45607. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45608. * The order of search:
  45609. *
  45610. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45611. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45612. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45613. * 4) return the generic trigger controller if none were found
  45614. *
  45615. * @param xrInput the xrInput to which a new controller is initialized
  45616. * @param scene the scene to which the model will be added
  45617. * @param forceProfile force a certain profile for this controller
  45618. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45619. */
  45620. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45621. /**
  45622. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45623. *
  45624. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45625. *
  45626. * @param type the profile type to register
  45627. * @param constructFunction the function to be called when loading this profile
  45628. */
  45629. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45630. /**
  45631. * Register a fallback to a specific profile.
  45632. * @param profileId the profileId that will receive the fallbacks
  45633. * @param fallbacks A list of fallback profiles
  45634. */
  45635. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45636. /**
  45637. * Will update the list of profiles available in the repository
  45638. * @return a promise that resolves to a map of profiles available online
  45639. */
  45640. static UpdateProfilesList(): Promise<{
  45641. [profile: string]: string;
  45642. }>;
  45643. private static _LoadProfileFromRepository;
  45644. private static _LoadProfilesFromAvailableControllers;
  45645. }
  45646. }
  45647. declare module "babylonjs/XR/webXRInputSource" {
  45648. import { Observable } from "babylonjs/Misc/observable";
  45649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45650. import { Ray } from "babylonjs/Culling/ray";
  45651. import { Scene } from "babylonjs/scene";
  45652. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45653. /**
  45654. * Configuration options for the WebXR controller creation
  45655. */
  45656. export interface IWebXRControllerOptions {
  45657. /**
  45658. * Should the controller mesh be animated when a user interacts with it
  45659. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45660. */
  45661. disableMotionControllerAnimation?: boolean;
  45662. /**
  45663. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45664. */
  45665. doNotLoadControllerMesh?: boolean;
  45666. /**
  45667. * Force a specific controller type for this controller.
  45668. * This can be used when creating your own profile or when testing different controllers
  45669. */
  45670. forceControllerProfile?: string;
  45671. }
  45672. /**
  45673. * Represents an XR controller
  45674. */
  45675. export class WebXRInputSource {
  45676. private _scene;
  45677. /** The underlying input source for the controller */
  45678. inputSource: XRInputSource;
  45679. private _options;
  45680. private _tmpQuaternion;
  45681. private _tmpVector;
  45682. private _uniqueId;
  45683. /**
  45684. * 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
  45685. */
  45686. grip?: AbstractMesh;
  45687. /**
  45688. * If available, this is the gamepad object related to this controller.
  45689. * Using this object it is possible to get click events and trackpad changes of the
  45690. * webxr controller that is currently being used.
  45691. */
  45692. motionController?: WebXRAbstractMotionController;
  45693. /**
  45694. * Event that fires when the controller is removed/disposed.
  45695. * The object provided as event data is this controller, after associated assets were disposed.
  45696. * uniqueId is still available.
  45697. */
  45698. onDisposeObservable: Observable<WebXRInputSource>;
  45699. /**
  45700. * Will be triggered when the mesh associated with the motion controller is done loading.
  45701. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45702. * A shortened version of controller -> motion controller -> on mesh loaded.
  45703. */
  45704. onMeshLoadedObservable: Observable<AbstractMesh>;
  45705. /**
  45706. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45707. */
  45708. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45709. /**
  45710. * Pointer which can be used to select objects or attach a visible laser to
  45711. */
  45712. pointer: AbstractMesh;
  45713. /**
  45714. * Creates the controller
  45715. * @see https://doc.babylonjs.com/how_to/webxr
  45716. * @param _scene the scene which the controller should be associated to
  45717. * @param inputSource the underlying input source for the controller
  45718. * @param _options options for this controller creation
  45719. */
  45720. constructor(_scene: Scene,
  45721. /** The underlying input source for the controller */
  45722. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45723. /**
  45724. * Get this controllers unique id
  45725. */
  45726. get uniqueId(): string;
  45727. /**
  45728. * Disposes of the object
  45729. */
  45730. dispose(): void;
  45731. /**
  45732. * Gets a world space ray coming from the pointer or grip
  45733. * @param result the resulting ray
  45734. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45735. */
  45736. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45737. /**
  45738. * Updates the controller pose based on the given XRFrame
  45739. * @param xrFrame xr frame to update the pose with
  45740. * @param referenceSpace reference space to use
  45741. */
  45742. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45743. }
  45744. }
  45745. declare module "babylonjs/XR/webXRInput" {
  45746. import { Observable } from "babylonjs/Misc/observable";
  45747. import { IDisposable } from "babylonjs/scene";
  45748. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45749. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45750. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45751. /**
  45752. * The schema for initialization options of the XR Input class
  45753. */
  45754. export interface IWebXRInputOptions {
  45755. /**
  45756. * If set to true no model will be automatically loaded
  45757. */
  45758. doNotLoadControllerMeshes?: boolean;
  45759. /**
  45760. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45761. * If not found, the xr input profile data will be used.
  45762. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45763. */
  45764. forceInputProfile?: string;
  45765. /**
  45766. * Do not send a request to the controller repository to load the profile.
  45767. *
  45768. * Instead, use the controllers available in babylon itself.
  45769. */
  45770. disableOnlineControllerRepository?: boolean;
  45771. /**
  45772. * A custom URL for the controllers repository
  45773. */
  45774. customControllersRepositoryURL?: string;
  45775. /**
  45776. * Should the controller model's components not move according to the user input
  45777. */
  45778. disableControllerAnimation?: boolean;
  45779. }
  45780. /**
  45781. * XR input used to track XR inputs such as controllers/rays
  45782. */
  45783. export class WebXRInput implements IDisposable {
  45784. /**
  45785. * the xr session manager for this session
  45786. */
  45787. xrSessionManager: WebXRSessionManager;
  45788. /**
  45789. * the WebXR camera for this session. Mainly used for teleportation
  45790. */
  45791. xrCamera: WebXRCamera;
  45792. private readonly options;
  45793. /**
  45794. * XR controllers being tracked
  45795. */
  45796. controllers: Array<WebXRInputSource>;
  45797. private _frameObserver;
  45798. private _sessionEndedObserver;
  45799. private _sessionInitObserver;
  45800. /**
  45801. * Event when a controller has been connected/added
  45802. */
  45803. onControllerAddedObservable: Observable<WebXRInputSource>;
  45804. /**
  45805. * Event when a controller has been removed/disconnected
  45806. */
  45807. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45808. /**
  45809. * Initializes the WebXRInput
  45810. * @param xrSessionManager the xr session manager for this session
  45811. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45812. * @param options = initialization options for this xr input
  45813. */
  45814. constructor(
  45815. /**
  45816. * the xr session manager for this session
  45817. */
  45818. xrSessionManager: WebXRSessionManager,
  45819. /**
  45820. * the WebXR camera for this session. Mainly used for teleportation
  45821. */
  45822. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45823. private _onInputSourcesChange;
  45824. private _addAndRemoveControllers;
  45825. /**
  45826. * Disposes of the object
  45827. */
  45828. dispose(): void;
  45829. }
  45830. }
  45831. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45832. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45833. import { Observable, EventState } from "babylonjs/Misc/observable";
  45834. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45835. /**
  45836. * This is the base class for all WebXR features.
  45837. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45838. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45839. */
  45840. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45841. protected _xrSessionManager: WebXRSessionManager;
  45842. private _attached;
  45843. private _removeOnDetach;
  45844. /**
  45845. * Should auto-attach be disabled?
  45846. */
  45847. disableAutoAttach: boolean;
  45848. /**
  45849. * Construct a new (abstract) WebXR feature
  45850. * @param _xrSessionManager the xr session manager for this feature
  45851. */
  45852. constructor(_xrSessionManager: WebXRSessionManager);
  45853. /**
  45854. * Is this feature attached
  45855. */
  45856. get attached(): boolean;
  45857. /**
  45858. * attach this feature
  45859. *
  45860. * @param force should attachment be forced (even when already attached)
  45861. * @returns true if successful, false is failed or already attached
  45862. */
  45863. attach(force?: boolean): boolean;
  45864. /**
  45865. * detach this feature.
  45866. *
  45867. * @returns true if successful, false if failed or already detached
  45868. */
  45869. detach(): boolean;
  45870. /**
  45871. * Dispose this feature and all of the resources attached
  45872. */
  45873. dispose(): void;
  45874. /**
  45875. * This is used to register callbacks that will automatically be removed when detach is called.
  45876. * @param observable the observable to which the observer will be attached
  45877. * @param callback the callback to register
  45878. */
  45879. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45880. /**
  45881. * Code in this function will be executed on each xrFrame received from the browser.
  45882. * This function will not execute after the feature is detached.
  45883. * @param _xrFrame the current frame
  45884. */
  45885. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45886. }
  45887. }
  45888. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45889. import { IDisposable, Scene } from "babylonjs/scene";
  45890. import { Nullable } from "babylonjs/types";
  45891. import { Observable } from "babylonjs/Misc/observable";
  45892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45893. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45894. import { Camera } from "babylonjs/Cameras/camera";
  45895. /**
  45896. * Renders a layer on top of an existing scene
  45897. */
  45898. export class UtilityLayerRenderer implements IDisposable {
  45899. /** the original scene that will be rendered on top of */
  45900. originalScene: Scene;
  45901. private _pointerCaptures;
  45902. private _lastPointerEvents;
  45903. private static _DefaultUtilityLayer;
  45904. private static _DefaultKeepDepthUtilityLayer;
  45905. private _sharedGizmoLight;
  45906. private _renderCamera;
  45907. /**
  45908. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45909. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  45910. * @returns the camera that is used when rendering the utility layer
  45911. */
  45912. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  45913. /**
  45914. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45915. * @param cam the camera that should be used when rendering the utility layer
  45916. */
  45917. setRenderCamera(cam: Nullable<Camera>): void;
  45918. /**
  45919. * @hidden
  45920. * Light which used by gizmos to get light shading
  45921. */
  45922. _getSharedGizmoLight(): HemisphericLight;
  45923. /**
  45924. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45925. */
  45926. pickUtilitySceneFirst: boolean;
  45927. /**
  45928. * 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)
  45929. */
  45930. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45931. /**
  45932. * 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)
  45933. */
  45934. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45935. /**
  45936. * The scene that is rendered on top of the original scene
  45937. */
  45938. utilityLayerScene: Scene;
  45939. /**
  45940. * If the utility layer should automatically be rendered on top of existing scene
  45941. */
  45942. shouldRender: boolean;
  45943. /**
  45944. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45945. */
  45946. onlyCheckPointerDownEvents: boolean;
  45947. /**
  45948. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45949. */
  45950. processAllEvents: boolean;
  45951. /**
  45952. * Observable raised when the pointer move from the utility layer scene to the main scene
  45953. */
  45954. onPointerOutObservable: Observable<number>;
  45955. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45956. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45957. private _afterRenderObserver;
  45958. private _sceneDisposeObserver;
  45959. private _originalPointerObserver;
  45960. /**
  45961. * Instantiates a UtilityLayerRenderer
  45962. * @param originalScene the original scene that will be rendered on top of
  45963. * @param handleEvents boolean indicating if the utility layer should handle events
  45964. */
  45965. constructor(
  45966. /** the original scene that will be rendered on top of */
  45967. originalScene: Scene, handleEvents?: boolean);
  45968. private _notifyObservers;
  45969. /**
  45970. * Renders the utility layers scene on top of the original scene
  45971. */
  45972. render(): void;
  45973. /**
  45974. * Disposes of the renderer
  45975. */
  45976. dispose(): void;
  45977. private _updateCamera;
  45978. }
  45979. }
  45980. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45981. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45983. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45984. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45985. import { Scene } from "babylonjs/scene";
  45986. import { Nullable } from "babylonjs/types";
  45987. import { Color3 } from "babylonjs/Maths/math.color";
  45988. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45989. /**
  45990. * Options interface for the pointer selection module
  45991. */
  45992. export interface IWebXRControllerPointerSelectionOptions {
  45993. /**
  45994. * if provided, this scene will be used to render meshes.
  45995. */
  45996. customUtilityLayerScene?: Scene;
  45997. /**
  45998. * 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)
  45999. * If not disabled, the last picked point will be used to execute a pointer up event
  46000. * If disabled, pointer up event will be triggered right after the pointer down event.
  46001. * Used in screen and gaze target ray mode only
  46002. */
  46003. disablePointerUpOnTouchOut: boolean;
  46004. /**
  46005. * For gaze mode (time to select instead of press)
  46006. */
  46007. forceGazeMode: boolean;
  46008. /**
  46009. * 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
  46010. * to start a new countdown to the pointer down event.
  46011. * Defaults to 1.
  46012. */
  46013. gazeModePointerMovedFactor?: number;
  46014. /**
  46015. * Different button type to use instead of the main component
  46016. */
  46017. overrideButtonId?: string;
  46018. /**
  46019. * use this rendering group id for the meshes (optional)
  46020. */
  46021. renderingGroupId?: number;
  46022. /**
  46023. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46024. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46025. * 3000 means 3 seconds between pointing at something and selecting it
  46026. */
  46027. timeToSelect?: number;
  46028. /**
  46029. * Should meshes created here be added to a utility layer or the main scene
  46030. */
  46031. useUtilityLayer?: boolean;
  46032. /**
  46033. * the xr input to use with this pointer selection
  46034. */
  46035. xrInput: WebXRInput;
  46036. }
  46037. /**
  46038. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46039. */
  46040. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46041. private readonly _options;
  46042. private static _idCounter;
  46043. private _attachController;
  46044. private _controllers;
  46045. private _scene;
  46046. private _tmpVectorForPickCompare;
  46047. /**
  46048. * The module's name
  46049. */
  46050. static readonly Name: string;
  46051. /**
  46052. * The (Babylon) version of this module.
  46053. * This is an integer representing the implementation version.
  46054. * This number does not correspond to the WebXR specs version
  46055. */
  46056. static readonly Version: number;
  46057. /**
  46058. * Disable lighting on the laser pointer (so it will always be visible)
  46059. */
  46060. disablePointerLighting: boolean;
  46061. /**
  46062. * Disable lighting on the selection mesh (so it will always be visible)
  46063. */
  46064. disableSelectionMeshLighting: boolean;
  46065. /**
  46066. * Should the laser pointer be displayed
  46067. */
  46068. displayLaserPointer: boolean;
  46069. /**
  46070. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46071. */
  46072. displaySelectionMesh: boolean;
  46073. /**
  46074. * This color will be set to the laser pointer when selection is triggered
  46075. */
  46076. laserPointerPickedColor: Color3;
  46077. /**
  46078. * Default color of the laser pointer
  46079. */
  46080. lasterPointerDefaultColor: Color3;
  46081. /**
  46082. * default color of the selection ring
  46083. */
  46084. selectionMeshDefaultColor: Color3;
  46085. /**
  46086. * This color will be applied to the selection ring when selection is triggered
  46087. */
  46088. selectionMeshPickedColor: Color3;
  46089. /**
  46090. * constructs a new background remover module
  46091. * @param _xrSessionManager the session manager for this module
  46092. * @param _options read-only options to be used in this module
  46093. */
  46094. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46095. /**
  46096. * attach this feature
  46097. * Will usually be called by the features manager
  46098. *
  46099. * @returns true if successful.
  46100. */
  46101. attach(): boolean;
  46102. /**
  46103. * detach this feature.
  46104. * Will usually be called by the features manager
  46105. *
  46106. * @returns true if successful.
  46107. */
  46108. detach(): boolean;
  46109. /**
  46110. * Will get the mesh under a specific pointer.
  46111. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46112. * @param controllerId the controllerId to check
  46113. * @returns The mesh under pointer or null if no mesh is under the pointer
  46114. */
  46115. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46116. /**
  46117. * Get the xr controller that correlates to the pointer id in the pointer event
  46118. *
  46119. * @param id the pointer id to search for
  46120. * @returns the controller that correlates to this id or null if not found
  46121. */
  46122. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46123. protected _onXRFrame(_xrFrame: XRFrame): void;
  46124. private _attachGazeMode;
  46125. private _attachScreenRayMode;
  46126. private _attachTrackedPointerRayMode;
  46127. private _convertNormalToDirectionOfRay;
  46128. private _detachController;
  46129. private _generateNewMeshPair;
  46130. private _pickingMoved;
  46131. private _updatePointerDistance;
  46132. }
  46133. }
  46134. declare module "babylonjs/XR/webXREnterExitUI" {
  46135. import { Nullable } from "babylonjs/types";
  46136. import { Observable } from "babylonjs/Misc/observable";
  46137. import { IDisposable, Scene } from "babylonjs/scene";
  46138. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46139. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46140. /**
  46141. * Button which can be used to enter a different mode of XR
  46142. */
  46143. export class WebXREnterExitUIButton {
  46144. /** button element */
  46145. element: HTMLElement;
  46146. /** XR initialization options for the button */
  46147. sessionMode: XRSessionMode;
  46148. /** Reference space type */
  46149. referenceSpaceType: XRReferenceSpaceType;
  46150. /**
  46151. * Creates a WebXREnterExitUIButton
  46152. * @param element button element
  46153. * @param sessionMode XR initialization session mode
  46154. * @param referenceSpaceType the type of reference space to be used
  46155. */
  46156. constructor(
  46157. /** button element */
  46158. element: HTMLElement,
  46159. /** XR initialization options for the button */
  46160. sessionMode: XRSessionMode,
  46161. /** Reference space type */
  46162. referenceSpaceType: XRReferenceSpaceType);
  46163. /**
  46164. * Extendable function which can be used to update the button's visuals when the state changes
  46165. * @param activeButton the current active button in the UI
  46166. */
  46167. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46168. }
  46169. /**
  46170. * Options to create the webXR UI
  46171. */
  46172. export class WebXREnterExitUIOptions {
  46173. /**
  46174. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46175. */
  46176. customButtons?: Array<WebXREnterExitUIButton>;
  46177. /**
  46178. * A reference space type to use when creating the default button.
  46179. * Default is local-floor
  46180. */
  46181. referenceSpaceType?: XRReferenceSpaceType;
  46182. /**
  46183. * Context to enter xr with
  46184. */
  46185. renderTarget?: Nullable<WebXRRenderTarget>;
  46186. /**
  46187. * A session mode to use when creating the default button.
  46188. * Default is immersive-vr
  46189. */
  46190. sessionMode?: XRSessionMode;
  46191. }
  46192. /**
  46193. * UI to allow the user to enter/exit XR mode
  46194. */
  46195. export class WebXREnterExitUI implements IDisposable {
  46196. private scene;
  46197. /** version of the options passed to this UI */
  46198. options: WebXREnterExitUIOptions;
  46199. private _activeButton;
  46200. private _buttons;
  46201. private _overlay;
  46202. /**
  46203. * Fired every time the active button is changed.
  46204. *
  46205. * When xr is entered via a button that launches xr that button will be the callback parameter
  46206. *
  46207. * When exiting xr the callback parameter will be null)
  46208. */
  46209. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46210. /**
  46211. *
  46212. * @param scene babylon scene object to use
  46213. * @param options (read-only) version of the options passed to this UI
  46214. */
  46215. private constructor();
  46216. /**
  46217. * Creates UI to allow the user to enter/exit XR mode
  46218. * @param scene the scene to add the ui to
  46219. * @param helper the xr experience helper to enter/exit xr with
  46220. * @param options options to configure the UI
  46221. * @returns the created ui
  46222. */
  46223. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46224. /**
  46225. * Disposes of the XR UI component
  46226. */
  46227. dispose(): void;
  46228. private _updateButtons;
  46229. }
  46230. }
  46231. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46232. import { Vector3 } from "babylonjs/Maths/math.vector";
  46233. import { Color4 } from "babylonjs/Maths/math.color";
  46234. import { Nullable } from "babylonjs/types";
  46235. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46236. import { Scene } from "babylonjs/scene";
  46237. /**
  46238. * Class containing static functions to help procedurally build meshes
  46239. */
  46240. export class LinesBuilder {
  46241. /**
  46242. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46243. * * 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
  46244. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46245. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46246. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46247. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46248. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46249. * * 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
  46250. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46253. * @param name defines the name of the new line system
  46254. * @param options defines the options used to create the line system
  46255. * @param scene defines the hosting scene
  46256. * @returns a new line system mesh
  46257. */
  46258. static CreateLineSystem(name: string, options: {
  46259. lines: Vector3[][];
  46260. updatable?: boolean;
  46261. instance?: Nullable<LinesMesh>;
  46262. colors?: Nullable<Color4[][]>;
  46263. useVertexAlpha?: boolean;
  46264. }, scene: Nullable<Scene>): LinesMesh;
  46265. /**
  46266. * Creates a line mesh
  46267. * 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
  46268. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46269. * * The parameter `points` is an array successive Vector3
  46270. * * 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
  46271. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46272. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46273. * * When updating an instance, remember that only point positions can change, not the number of points
  46274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46276. * @param name defines the name of the new line system
  46277. * @param options defines the options used to create the line system
  46278. * @param scene defines the hosting scene
  46279. * @returns a new line mesh
  46280. */
  46281. static CreateLines(name: string, options: {
  46282. points: Vector3[];
  46283. updatable?: boolean;
  46284. instance?: Nullable<LinesMesh>;
  46285. colors?: Color4[];
  46286. useVertexAlpha?: boolean;
  46287. }, scene?: Nullable<Scene>): LinesMesh;
  46288. /**
  46289. * Creates a dashed line mesh
  46290. * * 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
  46291. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46292. * * The parameter `points` is an array successive Vector3
  46293. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46294. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46295. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46296. * * 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
  46297. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46298. * * When updating an instance, remember that only point positions can change, not the number of points
  46299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46300. * @param name defines the name of the mesh
  46301. * @param options defines the options used to create the mesh
  46302. * @param scene defines the hosting scene
  46303. * @returns the dashed line mesh
  46304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46305. */
  46306. static CreateDashedLines(name: string, options: {
  46307. points: Vector3[];
  46308. dashSize?: number;
  46309. gapSize?: number;
  46310. dashNb?: number;
  46311. updatable?: boolean;
  46312. instance?: LinesMesh;
  46313. useVertexAlpha?: boolean;
  46314. }, scene?: Nullable<Scene>): LinesMesh;
  46315. }
  46316. }
  46317. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46318. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46319. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46320. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46322. import { Vector3 } from "babylonjs/Maths/math.vector";
  46323. import { Material } from "babylonjs/Materials/material";
  46324. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46325. import { Scene } from "babylonjs/scene";
  46326. /**
  46327. * The options container for the teleportation module
  46328. */
  46329. export interface IWebXRTeleportationOptions {
  46330. /**
  46331. * if provided, this scene will be used to render meshes.
  46332. */
  46333. customUtilityLayerScene?: Scene;
  46334. /**
  46335. * Values to configure the default target mesh
  46336. */
  46337. defaultTargetMeshOptions?: {
  46338. /**
  46339. * Fill color of the teleportation area
  46340. */
  46341. teleportationFillColor?: string;
  46342. /**
  46343. * Border color for the teleportation area
  46344. */
  46345. teleportationBorderColor?: string;
  46346. /**
  46347. * Disable the mesh's animation sequence
  46348. */
  46349. disableAnimation?: boolean;
  46350. /**
  46351. * Disable lighting on the material or the ring and arrow
  46352. */
  46353. disableLighting?: boolean;
  46354. /**
  46355. * Override the default material of the torus and arrow
  46356. */
  46357. torusArrowMaterial?: Material;
  46358. };
  46359. /**
  46360. * A list of meshes to use as floor meshes.
  46361. * Meshes can be added and removed after initializing the feature using the
  46362. * addFloorMesh and removeFloorMesh functions
  46363. * If empty, rotation will still work
  46364. */
  46365. floorMeshes?: AbstractMesh[];
  46366. /**
  46367. * use this rendering group id for the meshes (optional)
  46368. */
  46369. renderingGroupId?: number;
  46370. /**
  46371. * Should teleportation move only to snap points
  46372. */
  46373. snapPointsOnly?: boolean;
  46374. /**
  46375. * An array of points to which the teleportation will snap to.
  46376. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46377. */
  46378. snapPositions?: Vector3[];
  46379. /**
  46380. * How close should the teleportation ray be in order to snap to position.
  46381. * Default to 0.8 units (meters)
  46382. */
  46383. snapToPositionRadius?: number;
  46384. /**
  46385. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46386. * If you want to support rotation, make sure your mesh has a direction indicator.
  46387. *
  46388. * When left untouched, the default mesh will be initialized.
  46389. */
  46390. teleportationTargetMesh?: AbstractMesh;
  46391. /**
  46392. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46393. */
  46394. timeToTeleport?: number;
  46395. /**
  46396. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46397. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46398. */
  46399. useMainComponentOnly?: boolean;
  46400. /**
  46401. * Should meshes created here be added to a utility layer or the main scene
  46402. */
  46403. useUtilityLayer?: boolean;
  46404. /**
  46405. * Babylon XR Input class for controller
  46406. */
  46407. xrInput: WebXRInput;
  46408. }
  46409. /**
  46410. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46411. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46412. * the input of the attached controllers.
  46413. */
  46414. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46415. private _options;
  46416. private _controllers;
  46417. private _currentTeleportationControllerId;
  46418. private _floorMeshes;
  46419. private _quadraticBezierCurve;
  46420. private _selectionFeature;
  46421. private _snapToPositions;
  46422. private _snappedToPoint;
  46423. private _teleportationRingMaterial?;
  46424. private _tmpRay;
  46425. private _tmpVector;
  46426. /**
  46427. * The module's name
  46428. */
  46429. static readonly Name: string;
  46430. /**
  46431. * The (Babylon) version of this module.
  46432. * This is an integer representing the implementation version.
  46433. * This number does not correspond to the webxr specs version
  46434. */
  46435. static readonly Version: number;
  46436. /**
  46437. * Is movement backwards enabled
  46438. */
  46439. backwardsMovementEnabled: boolean;
  46440. /**
  46441. * Distance to travel when moving backwards
  46442. */
  46443. backwardsTeleportationDistance: number;
  46444. /**
  46445. * The distance from the user to the inspection point in the direction of the controller
  46446. * A higher number will allow the user to move further
  46447. * defaults to 5 (meters, in xr units)
  46448. */
  46449. parabolicCheckRadius: number;
  46450. /**
  46451. * Should the module support parabolic ray on top of direct ray
  46452. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46453. * Very helpful when moving between floors / different heights
  46454. */
  46455. parabolicRayEnabled: boolean;
  46456. /**
  46457. * How much rotation should be applied when rotating right and left
  46458. */
  46459. rotationAngle: number;
  46460. /**
  46461. * Is rotation enabled when moving forward?
  46462. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46463. */
  46464. rotationEnabled: boolean;
  46465. /**
  46466. * constructs a new anchor system
  46467. * @param _xrSessionManager an instance of WebXRSessionManager
  46468. * @param _options configuration object for this feature
  46469. */
  46470. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46471. /**
  46472. * Get the snapPointsOnly flag
  46473. */
  46474. get snapPointsOnly(): boolean;
  46475. /**
  46476. * Sets the snapPointsOnly flag
  46477. * @param snapToPoints should teleportation be exclusively to snap points
  46478. */
  46479. set snapPointsOnly(snapToPoints: boolean);
  46480. /**
  46481. * Add a new mesh to the floor meshes array
  46482. * @param mesh the mesh to use as floor mesh
  46483. */
  46484. addFloorMesh(mesh: AbstractMesh): void;
  46485. /**
  46486. * Add a new snap-to point to fix teleportation to this position
  46487. * @param newSnapPoint The new Snap-To point
  46488. */
  46489. addSnapPoint(newSnapPoint: Vector3): void;
  46490. attach(): boolean;
  46491. detach(): boolean;
  46492. dispose(): void;
  46493. /**
  46494. * Remove a mesh from the floor meshes array
  46495. * @param mesh the mesh to remove
  46496. */
  46497. removeFloorMesh(mesh: AbstractMesh): void;
  46498. /**
  46499. * Remove a mesh from the floor meshes array using its name
  46500. * @param name the mesh name to remove
  46501. */
  46502. removeFloorMeshByName(name: string): void;
  46503. /**
  46504. * 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
  46505. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46506. * @returns was the point found and removed or not
  46507. */
  46508. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46509. /**
  46510. * This function sets a selection feature that will be disabled when
  46511. * the forward ray is shown and will be reattached when hidden.
  46512. * This is used to remove the selection rays when moving.
  46513. * @param selectionFeature the feature to disable when forward movement is enabled
  46514. */
  46515. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46516. protected _onXRFrame(_xrFrame: XRFrame): void;
  46517. private _attachController;
  46518. private _createDefaultTargetMesh;
  46519. private _detachController;
  46520. private _findClosestSnapPointWithRadius;
  46521. private _setTargetMeshPosition;
  46522. private _setTargetMeshVisibility;
  46523. private _showParabolicPath;
  46524. private _teleportForward;
  46525. }
  46526. }
  46527. declare module "babylonjs/XR/webXRDefaultExperience" {
  46528. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46529. import { Scene } from "babylonjs/scene";
  46530. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46531. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46532. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46533. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46535. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46536. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46537. /**
  46538. * Options for the default xr helper
  46539. */
  46540. export class WebXRDefaultExperienceOptions {
  46541. /**
  46542. * Enable or disable default UI to enter XR
  46543. */
  46544. disableDefaultUI?: boolean;
  46545. /**
  46546. * Should teleportation not initialize. defaults to false.
  46547. */
  46548. disableTeleportation?: boolean;
  46549. /**
  46550. * Floor meshes that will be used for teleport
  46551. */
  46552. floorMeshes?: Array<AbstractMesh>;
  46553. /**
  46554. * If set to true, the first frame will not be used to reset position
  46555. * The first frame is mainly used when copying transformation from the old camera
  46556. * Mainly used in AR
  46557. */
  46558. ignoreNativeCameraTransformation?: boolean;
  46559. /**
  46560. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46561. */
  46562. inputOptions?: IWebXRInputOptions;
  46563. /**
  46564. * optional configuration for the output canvas
  46565. */
  46566. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46567. /**
  46568. * optional UI options. This can be used among other to change session mode and reference space type
  46569. */
  46570. uiOptions?: WebXREnterExitUIOptions;
  46571. /**
  46572. * When loading teleportation and pointer select, use stable versions instead of latest.
  46573. */
  46574. useStablePlugins?: boolean;
  46575. }
  46576. /**
  46577. * Default experience which provides a similar setup to the previous webVRExperience
  46578. */
  46579. export class WebXRDefaultExperience {
  46580. /**
  46581. * Base experience
  46582. */
  46583. baseExperience: WebXRExperienceHelper;
  46584. /**
  46585. * Enables ui for entering/exiting xr
  46586. */
  46587. enterExitUI: WebXREnterExitUI;
  46588. /**
  46589. * Input experience extension
  46590. */
  46591. input: WebXRInput;
  46592. /**
  46593. * Enables laser pointer and selection
  46594. */
  46595. pointerSelection: WebXRControllerPointerSelection;
  46596. /**
  46597. * Default target xr should render to
  46598. */
  46599. renderTarget: WebXRRenderTarget;
  46600. /**
  46601. * Enables teleportation
  46602. */
  46603. teleportation: WebXRMotionControllerTeleportation;
  46604. private constructor();
  46605. /**
  46606. * Creates the default xr experience
  46607. * @param scene scene
  46608. * @param options options for basic configuration
  46609. * @returns resulting WebXRDefaultExperience
  46610. */
  46611. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46612. /**
  46613. * DIsposes of the experience helper
  46614. */
  46615. dispose(): void;
  46616. }
  46617. }
  46618. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46619. import { Observable } from "babylonjs/Misc/observable";
  46620. import { Nullable } from "babylonjs/types";
  46621. import { Camera } from "babylonjs/Cameras/camera";
  46622. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46623. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46624. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46625. import { Scene } from "babylonjs/scene";
  46626. import { Vector3 } from "babylonjs/Maths/math.vector";
  46627. import { Color3 } from "babylonjs/Maths/math.color";
  46628. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46630. import { Mesh } from "babylonjs/Meshes/mesh";
  46631. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46632. import { EasingFunction } from "babylonjs/Animations/easing";
  46633. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46634. import "babylonjs/Meshes/Builders/groundBuilder";
  46635. import "babylonjs/Meshes/Builders/torusBuilder";
  46636. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46637. import "babylonjs/Gamepads/gamepadSceneComponent";
  46638. import "babylonjs/Animations/animatable";
  46639. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46640. /**
  46641. * Options to modify the vr teleportation behavior.
  46642. */
  46643. export interface VRTeleportationOptions {
  46644. /**
  46645. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46646. */
  46647. floorMeshName?: string;
  46648. /**
  46649. * A list of meshes to be used as the teleportation floor. (default: empty)
  46650. */
  46651. floorMeshes?: Mesh[];
  46652. /**
  46653. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46654. */
  46655. teleportationMode?: number;
  46656. /**
  46657. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46658. */
  46659. teleportationTime?: number;
  46660. /**
  46661. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46662. */
  46663. teleportationSpeed?: number;
  46664. /**
  46665. * The easing function used in the animation or null for Linear. (default CircleEase)
  46666. */
  46667. easingFunction?: EasingFunction;
  46668. }
  46669. /**
  46670. * Options to modify the vr experience helper's behavior.
  46671. */
  46672. export interface VRExperienceHelperOptions extends WebVROptions {
  46673. /**
  46674. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46675. */
  46676. createDeviceOrientationCamera?: boolean;
  46677. /**
  46678. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46679. */
  46680. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46681. /**
  46682. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46683. */
  46684. laserToggle?: boolean;
  46685. /**
  46686. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46687. */
  46688. floorMeshes?: Mesh[];
  46689. /**
  46690. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46691. */
  46692. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46693. /**
  46694. * Defines if WebXR should be used instead of WebVR (if available)
  46695. */
  46696. useXR?: boolean;
  46697. }
  46698. /**
  46699. * Event containing information after VR has been entered
  46700. */
  46701. export class OnAfterEnteringVRObservableEvent {
  46702. /**
  46703. * If entering vr was successful
  46704. */
  46705. success: boolean;
  46706. }
  46707. /**
  46708. * Helps to quickly add VR support to an existing scene.
  46709. * See http://doc.babylonjs.com/how_to/webvr_helper
  46710. */
  46711. export class VRExperienceHelper {
  46712. /** Options to modify the vr experience helper's behavior. */
  46713. webVROptions: VRExperienceHelperOptions;
  46714. private _scene;
  46715. private _position;
  46716. private _btnVR;
  46717. private _btnVRDisplayed;
  46718. private _webVRsupported;
  46719. private _webVRready;
  46720. private _webVRrequesting;
  46721. private _webVRpresenting;
  46722. private _hasEnteredVR;
  46723. private _fullscreenVRpresenting;
  46724. private _inputElement;
  46725. private _webVRCamera;
  46726. private _vrDeviceOrientationCamera;
  46727. private _deviceOrientationCamera;
  46728. private _existingCamera;
  46729. private _onKeyDown;
  46730. private _onVrDisplayPresentChange;
  46731. private _onVRDisplayChanged;
  46732. private _onVRRequestPresentStart;
  46733. private _onVRRequestPresentComplete;
  46734. /**
  46735. * 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)
  46736. */
  46737. enableGazeEvenWhenNoPointerLock: boolean;
  46738. /**
  46739. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46740. */
  46741. exitVROnDoubleTap: boolean;
  46742. /**
  46743. * Observable raised right before entering VR.
  46744. */
  46745. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46746. /**
  46747. * Observable raised when entering VR has completed.
  46748. */
  46749. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46750. /**
  46751. * Observable raised when exiting VR.
  46752. */
  46753. onExitingVRObservable: Observable<VRExperienceHelper>;
  46754. /**
  46755. * Observable raised when controller mesh is loaded.
  46756. */
  46757. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46758. /** Return this.onEnteringVRObservable
  46759. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46760. */
  46761. get onEnteringVR(): Observable<VRExperienceHelper>;
  46762. /** Return this.onExitingVRObservable
  46763. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46764. */
  46765. get onExitingVR(): Observable<VRExperienceHelper>;
  46766. /** Return this.onControllerMeshLoadedObservable
  46767. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46768. */
  46769. get onControllerMeshLoaded(): Observable<WebVRController>;
  46770. private _rayLength;
  46771. private _useCustomVRButton;
  46772. private _teleportationRequested;
  46773. private _teleportActive;
  46774. private _floorMeshName;
  46775. private _floorMeshesCollection;
  46776. private _teleportationMode;
  46777. private _teleportationTime;
  46778. private _teleportationSpeed;
  46779. private _teleportationEasing;
  46780. private _rotationAllowed;
  46781. private _teleportBackwardsVector;
  46782. private _teleportationTarget;
  46783. private _isDefaultTeleportationTarget;
  46784. private _postProcessMove;
  46785. private _teleportationFillColor;
  46786. private _teleportationBorderColor;
  46787. private _rotationAngle;
  46788. private _haloCenter;
  46789. private _cameraGazer;
  46790. private _padSensibilityUp;
  46791. private _padSensibilityDown;
  46792. private _leftController;
  46793. private _rightController;
  46794. private _gazeColor;
  46795. private _laserColor;
  46796. private _pickedLaserColor;
  46797. private _pickedGazeColor;
  46798. /**
  46799. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46800. */
  46801. onNewMeshSelected: Observable<AbstractMesh>;
  46802. /**
  46803. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46804. * This observable will provide the mesh and the controller used to select the mesh
  46805. */
  46806. onMeshSelectedWithController: Observable<{
  46807. mesh: AbstractMesh;
  46808. controller: WebVRController;
  46809. }>;
  46810. /**
  46811. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46812. */
  46813. onNewMeshPicked: Observable<PickingInfo>;
  46814. private _circleEase;
  46815. /**
  46816. * Observable raised before camera teleportation
  46817. */
  46818. onBeforeCameraTeleport: Observable<Vector3>;
  46819. /**
  46820. * Observable raised after camera teleportation
  46821. */
  46822. onAfterCameraTeleport: Observable<Vector3>;
  46823. /**
  46824. * Observable raised when current selected mesh gets unselected
  46825. */
  46826. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46827. private _raySelectionPredicate;
  46828. /**
  46829. * To be optionaly changed by user to define custom ray selection
  46830. */
  46831. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46832. /**
  46833. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46834. */
  46835. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46836. /**
  46837. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46838. */
  46839. teleportationEnabled: boolean;
  46840. private _defaultHeight;
  46841. private _teleportationInitialized;
  46842. private _interactionsEnabled;
  46843. private _interactionsRequested;
  46844. private _displayGaze;
  46845. private _displayLaserPointer;
  46846. /**
  46847. * The mesh used to display where the user is going to teleport.
  46848. */
  46849. get teleportationTarget(): Mesh;
  46850. /**
  46851. * Sets the mesh to be used to display where the user is going to teleport.
  46852. */
  46853. set teleportationTarget(value: Mesh);
  46854. /**
  46855. * 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
  46856. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46857. * See http://doc.babylonjs.com/resources/baking_transformations
  46858. */
  46859. get gazeTrackerMesh(): Mesh;
  46860. set gazeTrackerMesh(value: Mesh);
  46861. /**
  46862. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46863. */
  46864. updateGazeTrackerScale: boolean;
  46865. /**
  46866. * If the gaze trackers color should be updated when selecting meshes
  46867. */
  46868. updateGazeTrackerColor: boolean;
  46869. /**
  46870. * If the controller laser color should be updated when selecting meshes
  46871. */
  46872. updateControllerLaserColor: boolean;
  46873. /**
  46874. * The gaze tracking mesh corresponding to the left controller
  46875. */
  46876. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46877. /**
  46878. * The gaze tracking mesh corresponding to the right controller
  46879. */
  46880. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46881. /**
  46882. * If the ray of the gaze should be displayed.
  46883. */
  46884. get displayGaze(): boolean;
  46885. /**
  46886. * Sets if the ray of the gaze should be displayed.
  46887. */
  46888. set displayGaze(value: boolean);
  46889. /**
  46890. * If the ray of the LaserPointer should be displayed.
  46891. */
  46892. get displayLaserPointer(): boolean;
  46893. /**
  46894. * Sets if the ray of the LaserPointer should be displayed.
  46895. */
  46896. set displayLaserPointer(value: boolean);
  46897. /**
  46898. * The deviceOrientationCamera used as the camera when not in VR.
  46899. */
  46900. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46901. /**
  46902. * Based on the current WebVR support, returns the current VR camera used.
  46903. */
  46904. get currentVRCamera(): Nullable<Camera>;
  46905. /**
  46906. * The webVRCamera which is used when in VR.
  46907. */
  46908. get webVRCamera(): WebVRFreeCamera;
  46909. /**
  46910. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46911. */
  46912. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46913. /**
  46914. * The html button that is used to trigger entering into VR.
  46915. */
  46916. get vrButton(): Nullable<HTMLButtonElement>;
  46917. private get _teleportationRequestInitiated();
  46918. /**
  46919. * Defines whether or not Pointer lock should be requested when switching to
  46920. * full screen.
  46921. */
  46922. requestPointerLockOnFullScreen: boolean;
  46923. /**
  46924. * If asking to force XR, this will be populated with the default xr experience
  46925. */
  46926. xr: WebXRDefaultExperience;
  46927. /**
  46928. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46929. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46930. */
  46931. xrTestDone: boolean;
  46932. /**
  46933. * Instantiates a VRExperienceHelper.
  46934. * Helps to quickly add VR support to an existing scene.
  46935. * @param scene The scene the VRExperienceHelper belongs to.
  46936. * @param webVROptions Options to modify the vr experience helper's behavior.
  46937. */
  46938. constructor(scene: Scene,
  46939. /** Options to modify the vr experience helper's behavior. */
  46940. webVROptions?: VRExperienceHelperOptions);
  46941. private completeVRInit;
  46942. private _onDefaultMeshLoaded;
  46943. private _onResize;
  46944. private _onFullscreenChange;
  46945. /**
  46946. * Gets a value indicating if we are currently in VR mode.
  46947. */
  46948. get isInVRMode(): boolean;
  46949. private onVrDisplayPresentChange;
  46950. private onVRDisplayChanged;
  46951. private moveButtonToBottomRight;
  46952. private displayVRButton;
  46953. private updateButtonVisibility;
  46954. private _cachedAngularSensibility;
  46955. /**
  46956. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46957. * Otherwise, will use the fullscreen API.
  46958. */
  46959. enterVR(): void;
  46960. /**
  46961. * Attempt to exit VR, or fullscreen.
  46962. */
  46963. exitVR(): void;
  46964. /**
  46965. * The position of the vr experience helper.
  46966. */
  46967. get position(): Vector3;
  46968. /**
  46969. * Sets the position of the vr experience helper.
  46970. */
  46971. set position(value: Vector3);
  46972. /**
  46973. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46974. */
  46975. enableInteractions(): void;
  46976. private get _noControllerIsActive();
  46977. private beforeRender;
  46978. private _isTeleportationFloor;
  46979. /**
  46980. * Adds a floor mesh to be used for teleportation.
  46981. * @param floorMesh the mesh to be used for teleportation.
  46982. */
  46983. addFloorMesh(floorMesh: Mesh): void;
  46984. /**
  46985. * Removes a floor mesh from being used for teleportation.
  46986. * @param floorMesh the mesh to be removed.
  46987. */
  46988. removeFloorMesh(floorMesh: Mesh): void;
  46989. /**
  46990. * Enables interactions and teleportation using the VR controllers and gaze.
  46991. * @param vrTeleportationOptions options to modify teleportation behavior.
  46992. */
  46993. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46994. private _onNewGamepadConnected;
  46995. private _tryEnableInteractionOnController;
  46996. private _onNewGamepadDisconnected;
  46997. private _enableInteractionOnController;
  46998. private _checkTeleportWithRay;
  46999. private _checkRotate;
  47000. private _checkTeleportBackwards;
  47001. private _enableTeleportationOnController;
  47002. private _createTeleportationCircles;
  47003. private _displayTeleportationTarget;
  47004. private _hideTeleportationTarget;
  47005. private _rotateCamera;
  47006. private _moveTeleportationSelectorTo;
  47007. private _workingVector;
  47008. private _workingQuaternion;
  47009. private _workingMatrix;
  47010. /**
  47011. * Time Constant Teleportation Mode
  47012. */
  47013. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47014. /**
  47015. * Speed Constant Teleportation Mode
  47016. */
  47017. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47018. /**
  47019. * Teleports the users feet to the desired location
  47020. * @param location The location where the user's feet should be placed
  47021. */
  47022. teleportCamera(location: Vector3): void;
  47023. private _convertNormalToDirectionOfRay;
  47024. private _castRayAndSelectObject;
  47025. private _notifySelectedMeshUnselected;
  47026. /**
  47027. * Permanently set new colors for the laser pointer
  47028. * @param color the new laser color
  47029. * @param pickedColor the new laser color when picked mesh detected
  47030. */
  47031. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47032. /**
  47033. * Set lighting enabled / disabled on the laser pointer of both controllers
  47034. * @param enabled should the lighting be enabled on the laser pointer
  47035. */
  47036. setLaserLightingState(enabled?: boolean): void;
  47037. /**
  47038. * Permanently set new colors for the gaze pointer
  47039. * @param color the new gaze color
  47040. * @param pickedColor the new gaze color when picked mesh detected
  47041. */
  47042. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47043. /**
  47044. * Sets the color of the laser ray from the vr controllers.
  47045. * @param color new color for the ray.
  47046. */
  47047. changeLaserColor(color: Color3): void;
  47048. /**
  47049. * Sets the color of the ray from the vr headsets gaze.
  47050. * @param color new color for the ray.
  47051. */
  47052. changeGazeColor(color: Color3): void;
  47053. /**
  47054. * Exits VR and disposes of the vr experience helper
  47055. */
  47056. dispose(): void;
  47057. /**
  47058. * Gets the name of the VRExperienceHelper class
  47059. * @returns "VRExperienceHelper"
  47060. */
  47061. getClassName(): string;
  47062. }
  47063. }
  47064. declare module "babylonjs/Cameras/VR/index" {
  47065. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47066. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47067. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47068. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47069. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47070. export * from "babylonjs/Cameras/VR/webVRCamera";
  47071. }
  47072. declare module "babylonjs/Cameras/RigModes/index" {
  47073. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47074. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47075. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47076. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47077. }
  47078. declare module "babylonjs/Cameras/index" {
  47079. export * from "babylonjs/Cameras/Inputs/index";
  47080. export * from "babylonjs/Cameras/cameraInputsManager";
  47081. export * from "babylonjs/Cameras/camera";
  47082. export * from "babylonjs/Cameras/targetCamera";
  47083. export * from "babylonjs/Cameras/freeCamera";
  47084. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47085. export * from "babylonjs/Cameras/touchCamera";
  47086. export * from "babylonjs/Cameras/arcRotateCamera";
  47087. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47088. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47089. export * from "babylonjs/Cameras/flyCamera";
  47090. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47091. export * from "babylonjs/Cameras/followCamera";
  47092. export * from "babylonjs/Cameras/followCameraInputsManager";
  47093. export * from "babylonjs/Cameras/gamepadCamera";
  47094. export * from "babylonjs/Cameras/Stereoscopic/index";
  47095. export * from "babylonjs/Cameras/universalCamera";
  47096. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47097. export * from "babylonjs/Cameras/VR/index";
  47098. export * from "babylonjs/Cameras/RigModes/index";
  47099. }
  47100. declare module "babylonjs/Collisions/index" {
  47101. export * from "babylonjs/Collisions/collider";
  47102. export * from "babylonjs/Collisions/collisionCoordinator";
  47103. export * from "babylonjs/Collisions/pickingInfo";
  47104. export * from "babylonjs/Collisions/intersectionInfo";
  47105. export * from "babylonjs/Collisions/meshCollisionData";
  47106. }
  47107. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47108. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47109. import { Vector3 } from "babylonjs/Maths/math.vector";
  47110. import { Ray } from "babylonjs/Culling/ray";
  47111. import { Plane } from "babylonjs/Maths/math.plane";
  47112. /**
  47113. * Contains an array of blocks representing the octree
  47114. */
  47115. export interface IOctreeContainer<T> {
  47116. /**
  47117. * Blocks within the octree
  47118. */
  47119. blocks: Array<OctreeBlock<T>>;
  47120. }
  47121. /**
  47122. * Class used to store a cell in an octree
  47123. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47124. */
  47125. export class OctreeBlock<T> {
  47126. /**
  47127. * Gets the content of the current block
  47128. */
  47129. entries: T[];
  47130. /**
  47131. * Gets the list of block children
  47132. */
  47133. blocks: Array<OctreeBlock<T>>;
  47134. private _depth;
  47135. private _maxDepth;
  47136. private _capacity;
  47137. private _minPoint;
  47138. private _maxPoint;
  47139. private _boundingVectors;
  47140. private _creationFunc;
  47141. /**
  47142. * Creates a new block
  47143. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47144. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47145. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47146. * @param depth defines the current depth of this block in the octree
  47147. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47148. * @param creationFunc defines a callback to call when an element is added to the block
  47149. */
  47150. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47151. /**
  47152. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47153. */
  47154. get capacity(): number;
  47155. /**
  47156. * Gets the minimum vector (in world space) of the block's bounding box
  47157. */
  47158. get minPoint(): Vector3;
  47159. /**
  47160. * Gets the maximum vector (in world space) of the block's bounding box
  47161. */
  47162. get maxPoint(): Vector3;
  47163. /**
  47164. * Add a new element to this block
  47165. * @param entry defines the element to add
  47166. */
  47167. addEntry(entry: T): void;
  47168. /**
  47169. * Remove an element from this block
  47170. * @param entry defines the element to remove
  47171. */
  47172. removeEntry(entry: T): void;
  47173. /**
  47174. * Add an array of elements to this block
  47175. * @param entries defines the array of elements to add
  47176. */
  47177. addEntries(entries: T[]): void;
  47178. /**
  47179. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47180. * @param frustumPlanes defines the frustum planes to test
  47181. * @param selection defines the array to store current content if selection is positive
  47182. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47183. */
  47184. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47185. /**
  47186. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47187. * @param sphereCenter defines the bounding sphere center
  47188. * @param sphereRadius defines the bounding sphere radius
  47189. * @param selection defines the array to store current content if selection is positive
  47190. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47191. */
  47192. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47193. /**
  47194. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47195. * @param ray defines the ray to test with
  47196. * @param selection defines the array to store current content if selection is positive
  47197. */
  47198. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47199. /**
  47200. * Subdivide the content into child blocks (this block will then be empty)
  47201. */
  47202. createInnerBlocks(): void;
  47203. /**
  47204. * @hidden
  47205. */
  47206. 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;
  47207. }
  47208. }
  47209. declare module "babylonjs/Culling/Octrees/octree" {
  47210. import { SmartArray } from "babylonjs/Misc/smartArray";
  47211. import { Vector3 } from "babylonjs/Maths/math.vector";
  47212. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47214. import { Ray } from "babylonjs/Culling/ray";
  47215. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47216. import { Plane } from "babylonjs/Maths/math.plane";
  47217. /**
  47218. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47219. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47220. */
  47221. export class Octree<T> {
  47222. /** 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.) */
  47223. maxDepth: number;
  47224. /**
  47225. * Blocks within the octree containing objects
  47226. */
  47227. blocks: Array<OctreeBlock<T>>;
  47228. /**
  47229. * Content stored in the octree
  47230. */
  47231. dynamicContent: T[];
  47232. private _maxBlockCapacity;
  47233. private _selectionContent;
  47234. private _creationFunc;
  47235. /**
  47236. * Creates a octree
  47237. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47238. * @param creationFunc function to be used to instatiate the octree
  47239. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47240. * @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.)
  47241. */
  47242. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47243. /** 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.) */
  47244. maxDepth?: number);
  47245. /**
  47246. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47247. * @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);
  47248. * @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);
  47249. * @param entries meshes to be added to the octree blocks
  47250. */
  47251. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47252. /**
  47253. * Adds a mesh to the octree
  47254. * @param entry Mesh to add to the octree
  47255. */
  47256. addMesh(entry: T): void;
  47257. /**
  47258. * Remove an element from the octree
  47259. * @param entry defines the element to remove
  47260. */
  47261. removeMesh(entry: T): void;
  47262. /**
  47263. * Selects an array of meshes within the frustum
  47264. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47265. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47266. * @returns array of meshes within the frustum
  47267. */
  47268. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47269. /**
  47270. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47271. * @param sphereCenter defines the bounding sphere center
  47272. * @param sphereRadius defines the bounding sphere radius
  47273. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47274. * @returns an array of objects that intersect the sphere
  47275. */
  47276. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47277. /**
  47278. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47279. * @param ray defines the ray to test with
  47280. * @returns array of intersected objects
  47281. */
  47282. intersectsRay(ray: Ray): SmartArray<T>;
  47283. /**
  47284. * Adds a mesh into the octree block if it intersects the block
  47285. */
  47286. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47287. /**
  47288. * Adds a submesh into the octree block if it intersects the block
  47289. */
  47290. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47291. }
  47292. }
  47293. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47294. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47295. import { Scene } from "babylonjs/scene";
  47296. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47298. import { Ray } from "babylonjs/Culling/ray";
  47299. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47300. import { Collider } from "babylonjs/Collisions/collider";
  47301. module "babylonjs/scene" {
  47302. interface Scene {
  47303. /**
  47304. * @hidden
  47305. * Backing Filed
  47306. */
  47307. _selectionOctree: Octree<AbstractMesh>;
  47308. /**
  47309. * Gets the octree used to boost mesh selection (picking)
  47310. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47311. */
  47312. selectionOctree: Octree<AbstractMesh>;
  47313. /**
  47314. * Creates or updates the octree used to boost selection (picking)
  47315. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47316. * @param maxCapacity defines the maximum capacity per leaf
  47317. * @param maxDepth defines the maximum depth of the octree
  47318. * @returns an octree of AbstractMesh
  47319. */
  47320. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47321. }
  47322. }
  47323. module "babylonjs/Meshes/abstractMesh" {
  47324. interface AbstractMesh {
  47325. /**
  47326. * @hidden
  47327. * Backing Field
  47328. */
  47329. _submeshesOctree: Octree<SubMesh>;
  47330. /**
  47331. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47332. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47333. * @param maxCapacity defines the maximum size of each block (64 by default)
  47334. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47335. * @returns the new octree
  47336. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47337. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47338. */
  47339. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47340. }
  47341. }
  47342. /**
  47343. * Defines the octree scene component responsible to manage any octrees
  47344. * in a given scene.
  47345. */
  47346. export class OctreeSceneComponent {
  47347. /**
  47348. * The component name help to identify the component in the list of scene components.
  47349. */
  47350. readonly name: string;
  47351. /**
  47352. * The scene the component belongs to.
  47353. */
  47354. scene: Scene;
  47355. /**
  47356. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47357. */
  47358. readonly checksIsEnabled: boolean;
  47359. /**
  47360. * Creates a new instance of the component for the given scene
  47361. * @param scene Defines the scene to register the component in
  47362. */
  47363. constructor(scene: Scene);
  47364. /**
  47365. * Registers the component in a given scene
  47366. */
  47367. register(): void;
  47368. /**
  47369. * Return the list of active meshes
  47370. * @returns the list of active meshes
  47371. */
  47372. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47373. /**
  47374. * Return the list of active sub meshes
  47375. * @param mesh The mesh to get the candidates sub meshes from
  47376. * @returns the list of active sub meshes
  47377. */
  47378. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47379. private _tempRay;
  47380. /**
  47381. * Return the list of sub meshes intersecting with a given local ray
  47382. * @param mesh defines the mesh to find the submesh for
  47383. * @param localRay defines the ray in local space
  47384. * @returns the list of intersecting sub meshes
  47385. */
  47386. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47387. /**
  47388. * Return the list of sub meshes colliding with a collider
  47389. * @param mesh defines the mesh to find the submesh for
  47390. * @param collider defines the collider to evaluate the collision against
  47391. * @returns the list of colliding sub meshes
  47392. */
  47393. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47394. /**
  47395. * Rebuilds the elements related to this component in case of
  47396. * context lost for instance.
  47397. */
  47398. rebuild(): void;
  47399. /**
  47400. * Disposes the component and the associated ressources.
  47401. */
  47402. dispose(): void;
  47403. }
  47404. }
  47405. declare module "babylonjs/Culling/Octrees/index" {
  47406. export * from "babylonjs/Culling/Octrees/octree";
  47407. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47408. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47409. }
  47410. declare module "babylonjs/Culling/index" {
  47411. export * from "babylonjs/Culling/boundingBox";
  47412. export * from "babylonjs/Culling/boundingInfo";
  47413. export * from "babylonjs/Culling/boundingSphere";
  47414. export * from "babylonjs/Culling/Octrees/index";
  47415. export * from "babylonjs/Culling/ray";
  47416. }
  47417. declare module "babylonjs/Gizmos/gizmo" {
  47418. import { Nullable } from "babylonjs/types";
  47419. import { IDisposable } from "babylonjs/scene";
  47420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47421. import { Mesh } from "babylonjs/Meshes/mesh";
  47422. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47423. /**
  47424. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47425. */
  47426. export class Gizmo implements IDisposable {
  47427. /** The utility layer the gizmo will be added to */
  47428. gizmoLayer: UtilityLayerRenderer;
  47429. /**
  47430. * The root mesh of the gizmo
  47431. */
  47432. _rootMesh: Mesh;
  47433. private _attachedMesh;
  47434. /**
  47435. * Ratio for the scale of the gizmo (Default: 1)
  47436. */
  47437. scaleRatio: number;
  47438. /**
  47439. * If a custom mesh has been set (Default: false)
  47440. */
  47441. protected _customMeshSet: boolean;
  47442. /**
  47443. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47444. * * When set, interactions will be enabled
  47445. */
  47446. get attachedMesh(): Nullable<AbstractMesh>;
  47447. set attachedMesh(value: Nullable<AbstractMesh>);
  47448. /**
  47449. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47450. * @param mesh The mesh to replace the default mesh of the gizmo
  47451. */
  47452. setCustomMesh(mesh: Mesh): void;
  47453. /**
  47454. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47455. */
  47456. updateGizmoRotationToMatchAttachedMesh: boolean;
  47457. /**
  47458. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47459. */
  47460. updateGizmoPositionToMatchAttachedMesh: boolean;
  47461. /**
  47462. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47463. */
  47464. updateScale: boolean;
  47465. protected _interactionsEnabled: boolean;
  47466. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47467. private _beforeRenderObserver;
  47468. private _tempVector;
  47469. /**
  47470. * Creates a gizmo
  47471. * @param gizmoLayer The utility layer the gizmo will be added to
  47472. */
  47473. constructor(
  47474. /** The utility layer the gizmo will be added to */
  47475. gizmoLayer?: UtilityLayerRenderer);
  47476. /**
  47477. * Updates the gizmo to match the attached mesh's position/rotation
  47478. */
  47479. protected _update(): void;
  47480. /**
  47481. * Disposes of the gizmo
  47482. */
  47483. dispose(): void;
  47484. }
  47485. }
  47486. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47487. import { Observable } from "babylonjs/Misc/observable";
  47488. import { Nullable } from "babylonjs/types";
  47489. import { Vector3 } from "babylonjs/Maths/math.vector";
  47490. import { Color3 } from "babylonjs/Maths/math.color";
  47491. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47493. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47494. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47495. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47496. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47497. import { Scene } from "babylonjs/scene";
  47498. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47499. /**
  47500. * Single plane drag gizmo
  47501. */
  47502. export class PlaneDragGizmo extends Gizmo {
  47503. /**
  47504. * Drag behavior responsible for the gizmos dragging interactions
  47505. */
  47506. dragBehavior: PointerDragBehavior;
  47507. private _pointerObserver;
  47508. /**
  47509. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47510. */
  47511. snapDistance: number;
  47512. /**
  47513. * Event that fires each time the gizmo snaps to a new location.
  47514. * * snapDistance is the the change in distance
  47515. */
  47516. onSnapObservable: Observable<{
  47517. snapDistance: number;
  47518. }>;
  47519. private _plane;
  47520. private _coloredMaterial;
  47521. private _hoverMaterial;
  47522. private _isEnabled;
  47523. private _parent;
  47524. /** @hidden */
  47525. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47526. /** @hidden */
  47527. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47528. /**
  47529. * Creates a PlaneDragGizmo
  47530. * @param gizmoLayer The utility layer the gizmo will be added to
  47531. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47532. * @param color The color of the gizmo
  47533. */
  47534. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47535. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47536. /**
  47537. * If the gizmo is enabled
  47538. */
  47539. set isEnabled(value: boolean);
  47540. get isEnabled(): boolean;
  47541. /**
  47542. * Disposes of the gizmo
  47543. */
  47544. dispose(): void;
  47545. }
  47546. }
  47547. declare module "babylonjs/Gizmos/positionGizmo" {
  47548. import { Observable } from "babylonjs/Misc/observable";
  47549. import { Nullable } from "babylonjs/types";
  47550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47551. import { Mesh } from "babylonjs/Meshes/mesh";
  47552. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47553. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47554. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47555. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47556. /**
  47557. * Gizmo that enables dragging a mesh along 3 axis
  47558. */
  47559. export class PositionGizmo extends Gizmo {
  47560. /**
  47561. * Internal gizmo used for interactions on the x axis
  47562. */
  47563. xGizmo: AxisDragGizmo;
  47564. /**
  47565. * Internal gizmo used for interactions on the y axis
  47566. */
  47567. yGizmo: AxisDragGizmo;
  47568. /**
  47569. * Internal gizmo used for interactions on the z axis
  47570. */
  47571. zGizmo: AxisDragGizmo;
  47572. /**
  47573. * Internal gizmo used for interactions on the yz plane
  47574. */
  47575. xPlaneGizmo: PlaneDragGizmo;
  47576. /**
  47577. * Internal gizmo used for interactions on the xz plane
  47578. */
  47579. yPlaneGizmo: PlaneDragGizmo;
  47580. /**
  47581. * Internal gizmo used for interactions on the xy plane
  47582. */
  47583. zPlaneGizmo: PlaneDragGizmo;
  47584. /**
  47585. * private variables
  47586. */
  47587. private _meshAttached;
  47588. private _updateGizmoRotationToMatchAttachedMesh;
  47589. private _snapDistance;
  47590. private _scaleRatio;
  47591. /** Fires an event when any of it's sub gizmos are dragged */
  47592. onDragStartObservable: Observable<unknown>;
  47593. /** Fires an event when any of it's sub gizmos are released from dragging */
  47594. onDragEndObservable: Observable<unknown>;
  47595. /**
  47596. * If set to true, planar drag is enabled
  47597. */
  47598. private _planarGizmoEnabled;
  47599. get attachedMesh(): Nullable<AbstractMesh>;
  47600. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47601. /**
  47602. * Creates a PositionGizmo
  47603. * @param gizmoLayer The utility layer the gizmo will be added to
  47604. */
  47605. constructor(gizmoLayer?: UtilityLayerRenderer);
  47606. /**
  47607. * If the planar drag gizmo is enabled
  47608. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47609. */
  47610. set planarGizmoEnabled(value: boolean);
  47611. get planarGizmoEnabled(): boolean;
  47612. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47613. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47614. /**
  47615. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47616. */
  47617. set snapDistance(value: number);
  47618. get snapDistance(): number;
  47619. /**
  47620. * Ratio for the scale of the gizmo (Default: 1)
  47621. */
  47622. set scaleRatio(value: number);
  47623. get scaleRatio(): number;
  47624. /**
  47625. * Disposes of the gizmo
  47626. */
  47627. dispose(): void;
  47628. /**
  47629. * CustomMeshes are not supported by this gizmo
  47630. * @param mesh The mesh to replace the default mesh of the gizmo
  47631. */
  47632. setCustomMesh(mesh: Mesh): void;
  47633. }
  47634. }
  47635. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47636. import { Observable } from "babylonjs/Misc/observable";
  47637. import { Nullable } from "babylonjs/types";
  47638. import { Vector3 } from "babylonjs/Maths/math.vector";
  47639. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47641. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47642. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47643. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47644. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47645. import { Scene } from "babylonjs/scene";
  47646. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47647. import { Color3 } from "babylonjs/Maths/math.color";
  47648. /**
  47649. * Single axis drag gizmo
  47650. */
  47651. export class AxisDragGizmo extends Gizmo {
  47652. /**
  47653. * Drag behavior responsible for the gizmos dragging interactions
  47654. */
  47655. dragBehavior: PointerDragBehavior;
  47656. private _pointerObserver;
  47657. /**
  47658. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47659. */
  47660. snapDistance: number;
  47661. /**
  47662. * Event that fires each time the gizmo snaps to a new location.
  47663. * * snapDistance is the the change in distance
  47664. */
  47665. onSnapObservable: Observable<{
  47666. snapDistance: number;
  47667. }>;
  47668. private _isEnabled;
  47669. private _parent;
  47670. private _arrow;
  47671. private _coloredMaterial;
  47672. private _hoverMaterial;
  47673. /** @hidden */
  47674. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47675. /** @hidden */
  47676. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47677. /**
  47678. * Creates an AxisDragGizmo
  47679. * @param gizmoLayer The utility layer the gizmo will be added to
  47680. * @param dragAxis The axis which the gizmo will be able to drag on
  47681. * @param color The color of the gizmo
  47682. */
  47683. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47684. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47685. /**
  47686. * If the gizmo is enabled
  47687. */
  47688. set isEnabled(value: boolean);
  47689. get isEnabled(): boolean;
  47690. /**
  47691. * Disposes of the gizmo
  47692. */
  47693. dispose(): void;
  47694. }
  47695. }
  47696. declare module "babylonjs/Debug/axesViewer" {
  47697. import { Vector3 } from "babylonjs/Maths/math.vector";
  47698. import { Nullable } from "babylonjs/types";
  47699. import { Scene } from "babylonjs/scene";
  47700. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47701. /**
  47702. * The Axes viewer will show 3 axes in a specific point in space
  47703. */
  47704. export class AxesViewer {
  47705. private _xAxis;
  47706. private _yAxis;
  47707. private _zAxis;
  47708. private _scaleLinesFactor;
  47709. private _instanced;
  47710. /**
  47711. * Gets the hosting scene
  47712. */
  47713. scene: Scene;
  47714. /**
  47715. * Gets or sets a number used to scale line length
  47716. */
  47717. scaleLines: number;
  47718. /** Gets the node hierarchy used to render x-axis */
  47719. get xAxis(): TransformNode;
  47720. /** Gets the node hierarchy used to render y-axis */
  47721. get yAxis(): TransformNode;
  47722. /** Gets the node hierarchy used to render z-axis */
  47723. get zAxis(): TransformNode;
  47724. /**
  47725. * Creates a new AxesViewer
  47726. * @param scene defines the hosting scene
  47727. * @param scaleLines defines a number used to scale line length (1 by default)
  47728. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47729. * @param xAxis defines the node hierarchy used to render the x-axis
  47730. * @param yAxis defines the node hierarchy used to render the y-axis
  47731. * @param zAxis defines the node hierarchy used to render the z-axis
  47732. */
  47733. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47734. /**
  47735. * Force the viewer to update
  47736. * @param position defines the position of the viewer
  47737. * @param xaxis defines the x axis of the viewer
  47738. * @param yaxis defines the y axis of the viewer
  47739. * @param zaxis defines the z axis of the viewer
  47740. */
  47741. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47742. /**
  47743. * Creates an instance of this axes viewer.
  47744. * @returns a new axes viewer with instanced meshes
  47745. */
  47746. createInstance(): AxesViewer;
  47747. /** Releases resources */
  47748. dispose(): void;
  47749. private static _SetRenderingGroupId;
  47750. }
  47751. }
  47752. declare module "babylonjs/Debug/boneAxesViewer" {
  47753. import { Nullable } from "babylonjs/types";
  47754. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47755. import { Vector3 } from "babylonjs/Maths/math.vector";
  47756. import { Mesh } from "babylonjs/Meshes/mesh";
  47757. import { Bone } from "babylonjs/Bones/bone";
  47758. import { Scene } from "babylonjs/scene";
  47759. /**
  47760. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47761. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47762. */
  47763. export class BoneAxesViewer extends AxesViewer {
  47764. /**
  47765. * Gets or sets the target mesh where to display the axes viewer
  47766. */
  47767. mesh: Nullable<Mesh>;
  47768. /**
  47769. * Gets or sets the target bone where to display the axes viewer
  47770. */
  47771. bone: Nullable<Bone>;
  47772. /** Gets current position */
  47773. pos: Vector3;
  47774. /** Gets direction of X axis */
  47775. xaxis: Vector3;
  47776. /** Gets direction of Y axis */
  47777. yaxis: Vector3;
  47778. /** Gets direction of Z axis */
  47779. zaxis: Vector3;
  47780. /**
  47781. * Creates a new BoneAxesViewer
  47782. * @param scene defines the hosting scene
  47783. * @param bone defines the target bone
  47784. * @param mesh defines the target mesh
  47785. * @param scaleLines defines a scaling factor for line length (1 by default)
  47786. */
  47787. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47788. /**
  47789. * Force the viewer to update
  47790. */
  47791. update(): void;
  47792. /** Releases resources */
  47793. dispose(): void;
  47794. }
  47795. }
  47796. declare module "babylonjs/Debug/debugLayer" {
  47797. import { Scene } from "babylonjs/scene";
  47798. /**
  47799. * Interface used to define scene explorer extensibility option
  47800. */
  47801. export interface IExplorerExtensibilityOption {
  47802. /**
  47803. * Define the option label
  47804. */
  47805. label: string;
  47806. /**
  47807. * Defines the action to execute on click
  47808. */
  47809. action: (entity: any) => void;
  47810. }
  47811. /**
  47812. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47813. */
  47814. export interface IExplorerExtensibilityGroup {
  47815. /**
  47816. * Defines a predicate to test if a given type mut be extended
  47817. */
  47818. predicate: (entity: any) => boolean;
  47819. /**
  47820. * Gets the list of options added to a type
  47821. */
  47822. entries: IExplorerExtensibilityOption[];
  47823. }
  47824. /**
  47825. * Interface used to define the options to use to create the Inspector
  47826. */
  47827. export interface IInspectorOptions {
  47828. /**
  47829. * Display in overlay mode (default: false)
  47830. */
  47831. overlay?: boolean;
  47832. /**
  47833. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47834. */
  47835. globalRoot?: HTMLElement;
  47836. /**
  47837. * Display the Scene explorer
  47838. */
  47839. showExplorer?: boolean;
  47840. /**
  47841. * Display the property inspector
  47842. */
  47843. showInspector?: boolean;
  47844. /**
  47845. * Display in embed mode (both panes on the right)
  47846. */
  47847. embedMode?: boolean;
  47848. /**
  47849. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47850. */
  47851. handleResize?: boolean;
  47852. /**
  47853. * Allow the panes to popup (default: true)
  47854. */
  47855. enablePopup?: boolean;
  47856. /**
  47857. * Allow the panes to be closed by users (default: true)
  47858. */
  47859. enableClose?: boolean;
  47860. /**
  47861. * Optional list of extensibility entries
  47862. */
  47863. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47864. /**
  47865. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47866. */
  47867. inspectorURL?: string;
  47868. /**
  47869. * Optional initial tab (default to DebugLayerTab.Properties)
  47870. */
  47871. initialTab?: DebugLayerTab;
  47872. }
  47873. module "babylonjs/scene" {
  47874. interface Scene {
  47875. /**
  47876. * @hidden
  47877. * Backing field
  47878. */
  47879. _debugLayer: DebugLayer;
  47880. /**
  47881. * Gets the debug layer (aka Inspector) associated with the scene
  47882. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47883. */
  47884. debugLayer: DebugLayer;
  47885. }
  47886. }
  47887. /**
  47888. * Enum of inspector action tab
  47889. */
  47890. export enum DebugLayerTab {
  47891. /**
  47892. * Properties tag (default)
  47893. */
  47894. Properties = 0,
  47895. /**
  47896. * Debug tab
  47897. */
  47898. Debug = 1,
  47899. /**
  47900. * Statistics tab
  47901. */
  47902. Statistics = 2,
  47903. /**
  47904. * Tools tab
  47905. */
  47906. Tools = 3,
  47907. /**
  47908. * Settings tab
  47909. */
  47910. Settings = 4
  47911. }
  47912. /**
  47913. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47914. * what is happening in your scene
  47915. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47916. */
  47917. export class DebugLayer {
  47918. /**
  47919. * Define the url to get the inspector script from.
  47920. * By default it uses the babylonjs CDN.
  47921. * @ignoreNaming
  47922. */
  47923. static InspectorURL: string;
  47924. private _scene;
  47925. private BJSINSPECTOR;
  47926. private _onPropertyChangedObservable?;
  47927. /**
  47928. * Observable triggered when a property is changed through the inspector.
  47929. */
  47930. get onPropertyChangedObservable(): any;
  47931. /**
  47932. * Instantiates a new debug layer.
  47933. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47934. * what is happening in your scene
  47935. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47936. * @param scene Defines the scene to inspect
  47937. */
  47938. constructor(scene: Scene);
  47939. /** Creates the inspector window. */
  47940. private _createInspector;
  47941. /**
  47942. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47943. * @param entity defines the entity to select
  47944. * @param lineContainerTitle defines the specific block to highlight
  47945. */
  47946. select(entity: any, lineContainerTitle?: string): void;
  47947. /** Get the inspector from bundle or global */
  47948. private _getGlobalInspector;
  47949. /**
  47950. * Get if the inspector is visible or not.
  47951. * @returns true if visible otherwise, false
  47952. */
  47953. isVisible(): boolean;
  47954. /**
  47955. * Hide the inspector and close its window.
  47956. */
  47957. hide(): void;
  47958. /**
  47959. * Launch the debugLayer.
  47960. * @param config Define the configuration of the inspector
  47961. * @return a promise fulfilled when the debug layer is visible
  47962. */
  47963. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47964. }
  47965. }
  47966. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47967. import { Nullable } from "babylonjs/types";
  47968. import { Scene } from "babylonjs/scene";
  47969. import { Vector4 } from "babylonjs/Maths/math.vector";
  47970. import { Color4 } from "babylonjs/Maths/math.color";
  47971. import { Mesh } from "babylonjs/Meshes/mesh";
  47972. /**
  47973. * Class containing static functions to help procedurally build meshes
  47974. */
  47975. export class BoxBuilder {
  47976. /**
  47977. * Creates a box mesh
  47978. * * The parameter `size` sets the size (float) of each box side (default 1)
  47979. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47980. * * 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)
  47981. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47985. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47986. * @param name defines the name of the mesh
  47987. * @param options defines the options used to create the mesh
  47988. * @param scene defines the hosting scene
  47989. * @returns the box mesh
  47990. */
  47991. static CreateBox(name: string, options: {
  47992. size?: number;
  47993. width?: number;
  47994. height?: number;
  47995. depth?: number;
  47996. faceUV?: Vector4[];
  47997. faceColors?: Color4[];
  47998. sideOrientation?: number;
  47999. frontUVs?: Vector4;
  48000. backUVs?: Vector4;
  48001. wrap?: boolean;
  48002. topBaseAt?: number;
  48003. bottomBaseAt?: number;
  48004. updatable?: boolean;
  48005. }, scene?: Nullable<Scene>): Mesh;
  48006. }
  48007. }
  48008. declare module "babylonjs/Debug/physicsViewer" {
  48009. import { Nullable } from "babylonjs/types";
  48010. import { Scene } from "babylonjs/scene";
  48011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48012. import { Mesh } from "babylonjs/Meshes/mesh";
  48013. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48014. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48015. /**
  48016. * Used to show the physics impostor around the specific mesh
  48017. */
  48018. export class PhysicsViewer {
  48019. /** @hidden */
  48020. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48021. /** @hidden */
  48022. protected _meshes: Array<Nullable<AbstractMesh>>;
  48023. /** @hidden */
  48024. protected _scene: Nullable<Scene>;
  48025. /** @hidden */
  48026. protected _numMeshes: number;
  48027. /** @hidden */
  48028. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48029. private _renderFunction;
  48030. private _utilityLayer;
  48031. private _debugBoxMesh;
  48032. private _debugSphereMesh;
  48033. private _debugCylinderMesh;
  48034. private _debugMaterial;
  48035. private _debugMeshMeshes;
  48036. /**
  48037. * Creates a new PhysicsViewer
  48038. * @param scene defines the hosting scene
  48039. */
  48040. constructor(scene: Scene);
  48041. /** @hidden */
  48042. protected _updateDebugMeshes(): void;
  48043. /**
  48044. * Renders a specified physic impostor
  48045. * @param impostor defines the impostor to render
  48046. * @param targetMesh defines the mesh represented by the impostor
  48047. * @returns the new debug mesh used to render the impostor
  48048. */
  48049. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48050. /**
  48051. * Hides a specified physic impostor
  48052. * @param impostor defines the impostor to hide
  48053. */
  48054. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48055. private _getDebugMaterial;
  48056. private _getDebugBoxMesh;
  48057. private _getDebugSphereMesh;
  48058. private _getDebugCylinderMesh;
  48059. private _getDebugMeshMesh;
  48060. private _getDebugMesh;
  48061. /** Releases all resources */
  48062. dispose(): void;
  48063. }
  48064. }
  48065. declare module "babylonjs/Debug/rayHelper" {
  48066. import { Nullable } from "babylonjs/types";
  48067. import { Ray } from "babylonjs/Culling/ray";
  48068. import { Vector3 } from "babylonjs/Maths/math.vector";
  48069. import { Color3 } from "babylonjs/Maths/math.color";
  48070. import { Scene } from "babylonjs/scene";
  48071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48072. import "babylonjs/Meshes/Builders/linesBuilder";
  48073. /**
  48074. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48075. * in order to better appreciate the issue one might have.
  48076. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48077. */
  48078. export class RayHelper {
  48079. /**
  48080. * Defines the ray we are currently tryin to visualize.
  48081. */
  48082. ray: Nullable<Ray>;
  48083. private _renderPoints;
  48084. private _renderLine;
  48085. private _renderFunction;
  48086. private _scene;
  48087. private _updateToMeshFunction;
  48088. private _attachedToMesh;
  48089. private _meshSpaceDirection;
  48090. private _meshSpaceOrigin;
  48091. /**
  48092. * Helper function to create a colored helper in a scene in one line.
  48093. * @param ray Defines the ray we are currently tryin to visualize
  48094. * @param scene Defines the scene the ray is used in
  48095. * @param color Defines the color we want to see the ray in
  48096. * @returns The newly created ray helper.
  48097. */
  48098. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48099. /**
  48100. * Instantiate a new ray helper.
  48101. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48102. * in order to better appreciate the issue one might have.
  48103. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48104. * @param ray Defines the ray we are currently tryin to visualize
  48105. */
  48106. constructor(ray: Ray);
  48107. /**
  48108. * Shows the ray we are willing to debug.
  48109. * @param scene Defines the scene the ray needs to be rendered in
  48110. * @param color Defines the color the ray needs to be rendered in
  48111. */
  48112. show(scene: Scene, color?: Color3): void;
  48113. /**
  48114. * Hides the ray we are debugging.
  48115. */
  48116. hide(): void;
  48117. private _render;
  48118. /**
  48119. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48120. * @param mesh Defines the mesh we want the helper attached to
  48121. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48122. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48123. * @param length Defines the length of the ray
  48124. */
  48125. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48126. /**
  48127. * Detach the ray helper from the mesh it has previously been attached to.
  48128. */
  48129. detachFromMesh(): void;
  48130. private _updateToMesh;
  48131. /**
  48132. * Dispose the helper and release its associated resources.
  48133. */
  48134. dispose(): void;
  48135. }
  48136. }
  48137. declare module "babylonjs/Debug/skeletonViewer" {
  48138. import { Color3 } from "babylonjs/Maths/math.color";
  48139. import { Scene } from "babylonjs/scene";
  48140. import { Nullable } from "babylonjs/types";
  48141. import { Skeleton } from "babylonjs/Bones/skeleton";
  48142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48143. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48144. /**
  48145. * Class used to render a debug view of a given skeleton
  48146. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48147. */
  48148. export class SkeletonViewer {
  48149. /** defines the skeleton to render */
  48150. skeleton: Skeleton;
  48151. /** defines the mesh attached to the skeleton */
  48152. mesh: AbstractMesh;
  48153. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48154. autoUpdateBonesMatrices: boolean;
  48155. /** defines the rendering group id to use with the viewer */
  48156. renderingGroupId: number;
  48157. /** Gets or sets the color used to render the skeleton */
  48158. color: Color3;
  48159. private _scene;
  48160. private _debugLines;
  48161. private _debugMesh;
  48162. private _isEnabled;
  48163. private _renderFunction;
  48164. private _utilityLayer;
  48165. /**
  48166. * Returns the mesh used to render the bones
  48167. */
  48168. get debugMesh(): Nullable<LinesMesh>;
  48169. /**
  48170. * Creates a new SkeletonViewer
  48171. * @param skeleton defines the skeleton to render
  48172. * @param mesh defines the mesh attached to the skeleton
  48173. * @param scene defines the hosting scene
  48174. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48175. * @param renderingGroupId defines the rendering group id to use with the viewer
  48176. */
  48177. constructor(
  48178. /** defines the skeleton to render */
  48179. skeleton: Skeleton,
  48180. /** defines the mesh attached to the skeleton */
  48181. mesh: AbstractMesh, scene: Scene,
  48182. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48183. autoUpdateBonesMatrices?: boolean,
  48184. /** defines the rendering group id to use with the viewer */
  48185. renderingGroupId?: number);
  48186. /** Gets or sets a boolean indicating if the viewer is enabled */
  48187. set isEnabled(value: boolean);
  48188. get isEnabled(): boolean;
  48189. private _getBonePosition;
  48190. private _getLinesForBonesWithLength;
  48191. private _getLinesForBonesNoLength;
  48192. /** Update the viewer to sync with current skeleton state */
  48193. update(): void;
  48194. /** Release associated resources */
  48195. dispose(): void;
  48196. }
  48197. }
  48198. declare module "babylonjs/Debug/index" {
  48199. export * from "babylonjs/Debug/axesViewer";
  48200. export * from "babylonjs/Debug/boneAxesViewer";
  48201. export * from "babylonjs/Debug/debugLayer";
  48202. export * from "babylonjs/Debug/physicsViewer";
  48203. export * from "babylonjs/Debug/rayHelper";
  48204. export * from "babylonjs/Debug/skeletonViewer";
  48205. }
  48206. declare module "babylonjs/Engines/nullEngine" {
  48207. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48208. import { Engine } from "babylonjs/Engines/engine";
  48209. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48210. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48211. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48212. import { Effect } from "babylonjs/Materials/effect";
  48213. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48214. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48215. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48216. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48217. /**
  48218. * Options to create the null engine
  48219. */
  48220. export class NullEngineOptions {
  48221. /**
  48222. * Render width (Default: 512)
  48223. */
  48224. renderWidth: number;
  48225. /**
  48226. * Render height (Default: 256)
  48227. */
  48228. renderHeight: number;
  48229. /**
  48230. * Texture size (Default: 512)
  48231. */
  48232. textureSize: number;
  48233. /**
  48234. * If delta time between frames should be constant
  48235. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48236. */
  48237. deterministicLockstep: boolean;
  48238. /**
  48239. * Maximum about of steps between frames (Default: 4)
  48240. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48241. */
  48242. lockstepMaxSteps: number;
  48243. }
  48244. /**
  48245. * The null engine class provides support for headless version of babylon.js.
  48246. * This can be used in server side scenario or for testing purposes
  48247. */
  48248. export class NullEngine extends Engine {
  48249. private _options;
  48250. /**
  48251. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48252. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48253. * @returns true if engine is in deterministic lock step mode
  48254. */
  48255. isDeterministicLockStep(): boolean;
  48256. /**
  48257. * Gets the max steps when engine is running in deterministic lock step
  48258. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48259. * @returns the max steps
  48260. */
  48261. getLockstepMaxSteps(): number;
  48262. /**
  48263. * Gets the current hardware scaling level.
  48264. * By default the hardware scaling level is computed from the window device ratio.
  48265. * 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.
  48266. * @returns a number indicating the current hardware scaling level
  48267. */
  48268. getHardwareScalingLevel(): number;
  48269. constructor(options?: NullEngineOptions);
  48270. /**
  48271. * Creates a vertex buffer
  48272. * @param vertices the data for the vertex buffer
  48273. * @returns the new WebGL static buffer
  48274. */
  48275. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48276. /**
  48277. * Creates a new index buffer
  48278. * @param indices defines the content of the index buffer
  48279. * @param updatable defines if the index buffer must be updatable
  48280. * @returns a new webGL buffer
  48281. */
  48282. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48283. /**
  48284. * Clear the current render buffer or the current render target (if any is set up)
  48285. * @param color defines the color to use
  48286. * @param backBuffer defines if the back buffer must be cleared
  48287. * @param depth defines if the depth buffer must be cleared
  48288. * @param stencil defines if the stencil buffer must be cleared
  48289. */
  48290. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48291. /**
  48292. * Gets the current render width
  48293. * @param useScreen defines if screen size must be used (or the current render target if any)
  48294. * @returns a number defining the current render width
  48295. */
  48296. getRenderWidth(useScreen?: boolean): number;
  48297. /**
  48298. * Gets the current render height
  48299. * @param useScreen defines if screen size must be used (or the current render target if any)
  48300. * @returns a number defining the current render height
  48301. */
  48302. getRenderHeight(useScreen?: boolean): number;
  48303. /**
  48304. * Set the WebGL's viewport
  48305. * @param viewport defines the viewport element to be used
  48306. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48307. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48308. */
  48309. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48310. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48311. /**
  48312. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48313. * @param pipelineContext defines the pipeline context to use
  48314. * @param uniformsNames defines the list of uniform names
  48315. * @returns an array of webGL uniform locations
  48316. */
  48317. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48318. /**
  48319. * Gets the lsit of active attributes for a given webGL program
  48320. * @param pipelineContext defines the pipeline context to use
  48321. * @param attributesNames defines the list of attribute names to get
  48322. * @returns an array of indices indicating the offset of each attribute
  48323. */
  48324. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48325. /**
  48326. * Binds an effect to the webGL context
  48327. * @param effect defines the effect to bind
  48328. */
  48329. bindSamplers(effect: Effect): void;
  48330. /**
  48331. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48332. * @param effect defines the effect to activate
  48333. */
  48334. enableEffect(effect: Effect): void;
  48335. /**
  48336. * Set various states to the webGL context
  48337. * @param culling defines backface culling state
  48338. * @param zOffset defines the value to apply to zOffset (0 by default)
  48339. * @param force defines if states must be applied even if cache is up to date
  48340. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48341. */
  48342. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48343. /**
  48344. * Set the value of an uniform to an array of int32
  48345. * @param uniform defines the webGL uniform location where to store the value
  48346. * @param array defines the array of int32 to store
  48347. */
  48348. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48349. /**
  48350. * Set the value of an uniform to an array of int32 (stored as vec2)
  48351. * @param uniform defines the webGL uniform location where to store the value
  48352. * @param array defines the array of int32 to store
  48353. */
  48354. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48355. /**
  48356. * Set the value of an uniform to an array of int32 (stored as vec3)
  48357. * @param uniform defines the webGL uniform location where to store the value
  48358. * @param array defines the array of int32 to store
  48359. */
  48360. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48361. /**
  48362. * Set the value of an uniform to an array of int32 (stored as vec4)
  48363. * @param uniform defines the webGL uniform location where to store the value
  48364. * @param array defines the array of int32 to store
  48365. */
  48366. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48367. /**
  48368. * Set the value of an uniform to an array of float32
  48369. * @param uniform defines the webGL uniform location where to store the value
  48370. * @param array defines the array of float32 to store
  48371. */
  48372. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48373. /**
  48374. * Set the value of an uniform to an array of float32 (stored as vec2)
  48375. * @param uniform defines the webGL uniform location where to store the value
  48376. * @param array defines the array of float32 to store
  48377. */
  48378. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48379. /**
  48380. * Set the value of an uniform to an array of float32 (stored as vec3)
  48381. * @param uniform defines the webGL uniform location where to store the value
  48382. * @param array defines the array of float32 to store
  48383. */
  48384. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48385. /**
  48386. * Set the value of an uniform to an array of float32 (stored as vec4)
  48387. * @param uniform defines the webGL uniform location where to store the value
  48388. * @param array defines the array of float32 to store
  48389. */
  48390. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48391. /**
  48392. * Set the value of an uniform to an array of number
  48393. * @param uniform defines the webGL uniform location where to store the value
  48394. * @param array defines the array of number to store
  48395. */
  48396. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48397. /**
  48398. * Set the value of an uniform to an array of number (stored as vec2)
  48399. * @param uniform defines the webGL uniform location where to store the value
  48400. * @param array defines the array of number to store
  48401. */
  48402. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48403. /**
  48404. * Set the value of an uniform to an array of number (stored as vec3)
  48405. * @param uniform defines the webGL uniform location where to store the value
  48406. * @param array defines the array of number to store
  48407. */
  48408. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48409. /**
  48410. * Set the value of an uniform to an array of number (stored as vec4)
  48411. * @param uniform defines the webGL uniform location where to store the value
  48412. * @param array defines the array of number to store
  48413. */
  48414. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48415. /**
  48416. * Set the value of an uniform to an array of float32 (stored as matrices)
  48417. * @param uniform defines the webGL uniform location where to store the value
  48418. * @param matrices defines the array of float32 to store
  48419. */
  48420. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48421. /**
  48422. * Set the value of an uniform to a matrix (3x3)
  48423. * @param uniform defines the webGL uniform location where to store the value
  48424. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48425. */
  48426. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48427. /**
  48428. * Set the value of an uniform to a matrix (2x2)
  48429. * @param uniform defines the webGL uniform location where to store the value
  48430. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48431. */
  48432. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48433. /**
  48434. * Set the value of an uniform to a number (float)
  48435. * @param uniform defines the webGL uniform location where to store the value
  48436. * @param value defines the float number to store
  48437. */
  48438. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48439. /**
  48440. * Set the value of an uniform to a vec2
  48441. * @param uniform defines the webGL uniform location where to store the value
  48442. * @param x defines the 1st component of the value
  48443. * @param y defines the 2nd component of the value
  48444. */
  48445. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48446. /**
  48447. * Set the value of an uniform to a vec3
  48448. * @param uniform defines the webGL uniform location where to store the value
  48449. * @param x defines the 1st component of the value
  48450. * @param y defines the 2nd component of the value
  48451. * @param z defines the 3rd component of the value
  48452. */
  48453. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48454. /**
  48455. * Set the value of an uniform to a boolean
  48456. * @param uniform defines the webGL uniform location where to store the value
  48457. * @param bool defines the boolean to store
  48458. */
  48459. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48460. /**
  48461. * Set the value of an uniform to a vec4
  48462. * @param uniform defines the webGL uniform location where to store the value
  48463. * @param x defines the 1st component of the value
  48464. * @param y defines the 2nd component of the value
  48465. * @param z defines the 3rd component of the value
  48466. * @param w defines the 4th component of the value
  48467. */
  48468. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48469. /**
  48470. * Sets the current alpha mode
  48471. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48472. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48473. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48474. */
  48475. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48476. /**
  48477. * Bind webGl buffers directly to the webGL context
  48478. * @param vertexBuffers defines the vertex buffer to bind
  48479. * @param indexBuffer defines the index buffer to bind
  48480. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48481. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48482. * @param effect defines the effect associated with the vertex buffer
  48483. */
  48484. bindBuffers(vertexBuffers: {
  48485. [key: string]: VertexBuffer;
  48486. }, indexBuffer: DataBuffer, effect: Effect): void;
  48487. /**
  48488. * Force the entire cache to be cleared
  48489. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48490. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48491. */
  48492. wipeCaches(bruteForce?: boolean): void;
  48493. /**
  48494. * Send a draw order
  48495. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48496. * @param indexStart defines the starting index
  48497. * @param indexCount defines the number of index to draw
  48498. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48499. */
  48500. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48501. /**
  48502. * Draw a list of indexed primitives
  48503. * @param fillMode defines the primitive to use
  48504. * @param indexStart defines the starting index
  48505. * @param indexCount defines the number of index to draw
  48506. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48507. */
  48508. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48509. /**
  48510. * Draw a list of unindexed primitives
  48511. * @param fillMode defines the primitive to use
  48512. * @param verticesStart defines the index of first vertex to draw
  48513. * @param verticesCount defines the count of vertices to draw
  48514. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48515. */
  48516. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48517. /** @hidden */
  48518. _createTexture(): WebGLTexture;
  48519. /** @hidden */
  48520. _releaseTexture(texture: InternalTexture): void;
  48521. /**
  48522. * Usually called from Texture.ts.
  48523. * Passed information to create a WebGLTexture
  48524. * @param urlArg defines a value which contains one of the following:
  48525. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48526. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48527. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48528. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48529. * @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)
  48530. * @param scene needed for loading to the correct scene
  48531. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48532. * @param onLoad optional callback to be called upon successful completion
  48533. * @param onError optional callback to be called upon failure
  48534. * @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
  48535. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48536. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48537. * @param forcedExtension defines the extension to use to pick the right loader
  48538. * @param mimeType defines an optional mime type
  48539. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48540. */
  48541. 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;
  48542. /**
  48543. * Creates a new render target texture
  48544. * @param size defines the size of the texture
  48545. * @param options defines the options used to create the texture
  48546. * @returns a new render target texture stored in an InternalTexture
  48547. */
  48548. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48549. /**
  48550. * Update the sampling mode of a given texture
  48551. * @param samplingMode defines the required sampling mode
  48552. * @param texture defines the texture to update
  48553. */
  48554. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48555. /**
  48556. * Binds the frame buffer to the specified texture.
  48557. * @param texture The texture to render to or null for the default canvas
  48558. * @param faceIndex The face of the texture to render to in case of cube texture
  48559. * @param requiredWidth The width of the target to render to
  48560. * @param requiredHeight The height of the target to render to
  48561. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48562. * @param lodLevel defines le lod level to bind to the frame buffer
  48563. */
  48564. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48565. /**
  48566. * Unbind the current render target texture from the webGL context
  48567. * @param texture defines the render target texture to unbind
  48568. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48569. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48570. */
  48571. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48572. /**
  48573. * Creates a dynamic vertex buffer
  48574. * @param vertices the data for the dynamic vertex buffer
  48575. * @returns the new WebGL dynamic buffer
  48576. */
  48577. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48578. /**
  48579. * Update the content of a dynamic texture
  48580. * @param texture defines the texture to update
  48581. * @param canvas defines the canvas containing the source
  48582. * @param invertY defines if data must be stored with Y axis inverted
  48583. * @param premulAlpha defines if alpha is stored as premultiplied
  48584. * @param format defines the format of the data
  48585. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48586. */
  48587. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48588. /**
  48589. * Gets a boolean indicating if all created effects are ready
  48590. * @returns true if all effects are ready
  48591. */
  48592. areAllEffectsReady(): boolean;
  48593. /**
  48594. * @hidden
  48595. * Get the current error code of the webGL context
  48596. * @returns the error code
  48597. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48598. */
  48599. getError(): number;
  48600. /** @hidden */
  48601. _getUnpackAlignement(): number;
  48602. /** @hidden */
  48603. _unpackFlipY(value: boolean): void;
  48604. /**
  48605. * Update a dynamic index buffer
  48606. * @param indexBuffer defines the target index buffer
  48607. * @param indices defines the data to update
  48608. * @param offset defines the offset in the target index buffer where update should start
  48609. */
  48610. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48611. /**
  48612. * Updates a dynamic vertex buffer.
  48613. * @param vertexBuffer the vertex buffer to update
  48614. * @param vertices the data used to update the vertex buffer
  48615. * @param byteOffset the byte offset of the data (optional)
  48616. * @param byteLength the byte length of the data (optional)
  48617. */
  48618. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48619. /** @hidden */
  48620. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48621. /** @hidden */
  48622. _bindTexture(channel: number, texture: InternalTexture): void;
  48623. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48624. /**
  48625. * 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
  48626. */
  48627. releaseEffects(): void;
  48628. displayLoadingUI(): void;
  48629. hideLoadingUI(): void;
  48630. /** @hidden */
  48631. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48632. /** @hidden */
  48633. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48634. /** @hidden */
  48635. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48636. /** @hidden */
  48637. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48638. }
  48639. }
  48640. declare module "babylonjs/Instrumentation/timeToken" {
  48641. import { Nullable } from "babylonjs/types";
  48642. /**
  48643. * @hidden
  48644. **/
  48645. export class _TimeToken {
  48646. _startTimeQuery: Nullable<WebGLQuery>;
  48647. _endTimeQuery: Nullable<WebGLQuery>;
  48648. _timeElapsedQuery: Nullable<WebGLQuery>;
  48649. _timeElapsedQueryEnded: boolean;
  48650. }
  48651. }
  48652. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48653. import { Nullable, int } from "babylonjs/types";
  48654. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48655. /** @hidden */
  48656. export class _OcclusionDataStorage {
  48657. /** @hidden */
  48658. occlusionInternalRetryCounter: number;
  48659. /** @hidden */
  48660. isOcclusionQueryInProgress: boolean;
  48661. /** @hidden */
  48662. isOccluded: boolean;
  48663. /** @hidden */
  48664. occlusionRetryCount: number;
  48665. /** @hidden */
  48666. occlusionType: number;
  48667. /** @hidden */
  48668. occlusionQueryAlgorithmType: number;
  48669. }
  48670. module "babylonjs/Engines/engine" {
  48671. interface Engine {
  48672. /**
  48673. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48674. * @return the new query
  48675. */
  48676. createQuery(): WebGLQuery;
  48677. /**
  48678. * Delete and release a webGL query
  48679. * @param query defines the query to delete
  48680. * @return the current engine
  48681. */
  48682. deleteQuery(query: WebGLQuery): Engine;
  48683. /**
  48684. * Check if a given query has resolved and got its value
  48685. * @param query defines the query to check
  48686. * @returns true if the query got its value
  48687. */
  48688. isQueryResultAvailable(query: WebGLQuery): boolean;
  48689. /**
  48690. * Gets the value of a given query
  48691. * @param query defines the query to check
  48692. * @returns the value of the query
  48693. */
  48694. getQueryResult(query: WebGLQuery): number;
  48695. /**
  48696. * Initiates an occlusion query
  48697. * @param algorithmType defines the algorithm to use
  48698. * @param query defines the query to use
  48699. * @returns the current engine
  48700. * @see http://doc.babylonjs.com/features/occlusionquery
  48701. */
  48702. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48703. /**
  48704. * Ends an occlusion query
  48705. * @see http://doc.babylonjs.com/features/occlusionquery
  48706. * @param algorithmType defines the algorithm to use
  48707. * @returns the current engine
  48708. */
  48709. endOcclusionQuery(algorithmType: number): Engine;
  48710. /**
  48711. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48712. * Please note that only one query can be issued at a time
  48713. * @returns a time token used to track the time span
  48714. */
  48715. startTimeQuery(): Nullable<_TimeToken>;
  48716. /**
  48717. * Ends a time query
  48718. * @param token defines the token used to measure the time span
  48719. * @returns the time spent (in ns)
  48720. */
  48721. endTimeQuery(token: _TimeToken): int;
  48722. /** @hidden */
  48723. _currentNonTimestampToken: Nullable<_TimeToken>;
  48724. /** @hidden */
  48725. _createTimeQuery(): WebGLQuery;
  48726. /** @hidden */
  48727. _deleteTimeQuery(query: WebGLQuery): void;
  48728. /** @hidden */
  48729. _getGlAlgorithmType(algorithmType: number): number;
  48730. /** @hidden */
  48731. _getTimeQueryResult(query: WebGLQuery): any;
  48732. /** @hidden */
  48733. _getTimeQueryAvailability(query: WebGLQuery): any;
  48734. }
  48735. }
  48736. module "babylonjs/Meshes/abstractMesh" {
  48737. interface AbstractMesh {
  48738. /**
  48739. * Backing filed
  48740. * @hidden
  48741. */
  48742. __occlusionDataStorage: _OcclusionDataStorage;
  48743. /**
  48744. * Access property
  48745. * @hidden
  48746. */
  48747. _occlusionDataStorage: _OcclusionDataStorage;
  48748. /**
  48749. * 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.
  48750. * The default value is -1 which means don't break the query and wait till the result
  48751. * @see http://doc.babylonjs.com/features/occlusionquery
  48752. */
  48753. occlusionRetryCount: number;
  48754. /**
  48755. * 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:
  48756. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48757. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48758. * * 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.
  48759. * @see http://doc.babylonjs.com/features/occlusionquery
  48760. */
  48761. occlusionType: number;
  48762. /**
  48763. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48764. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48765. * * 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.
  48766. * @see http://doc.babylonjs.com/features/occlusionquery
  48767. */
  48768. occlusionQueryAlgorithmType: number;
  48769. /**
  48770. * 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
  48771. * @see http://doc.babylonjs.com/features/occlusionquery
  48772. */
  48773. isOccluded: boolean;
  48774. /**
  48775. * Flag to check the progress status of the query
  48776. * @see http://doc.babylonjs.com/features/occlusionquery
  48777. */
  48778. isOcclusionQueryInProgress: boolean;
  48779. }
  48780. }
  48781. }
  48782. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48783. import { Nullable } from "babylonjs/types";
  48784. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48785. /** @hidden */
  48786. export var _forceTransformFeedbackToBundle: boolean;
  48787. module "babylonjs/Engines/engine" {
  48788. interface Engine {
  48789. /**
  48790. * Creates a webGL transform feedback object
  48791. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48792. * @returns the webGL transform feedback object
  48793. */
  48794. createTransformFeedback(): WebGLTransformFeedback;
  48795. /**
  48796. * Delete a webGL transform feedback object
  48797. * @param value defines the webGL transform feedback object to delete
  48798. */
  48799. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48800. /**
  48801. * Bind a webGL transform feedback object to the webgl context
  48802. * @param value defines the webGL transform feedback object to bind
  48803. */
  48804. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48805. /**
  48806. * Begins a transform feedback operation
  48807. * @param usePoints defines if points or triangles must be used
  48808. */
  48809. beginTransformFeedback(usePoints: boolean): void;
  48810. /**
  48811. * Ends a transform feedback operation
  48812. */
  48813. endTransformFeedback(): void;
  48814. /**
  48815. * Specify the varyings to use with transform feedback
  48816. * @param program defines the associated webGL program
  48817. * @param value defines the list of strings representing the varying names
  48818. */
  48819. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48820. /**
  48821. * Bind a webGL buffer for a transform feedback operation
  48822. * @param value defines the webGL buffer to bind
  48823. */
  48824. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48825. }
  48826. }
  48827. }
  48828. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48829. import { Scene } from "babylonjs/scene";
  48830. import { Engine } from "babylonjs/Engines/engine";
  48831. import { Texture } from "babylonjs/Materials/Textures/texture";
  48832. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48833. import "babylonjs/Engines/Extensions/engine.multiRender";
  48834. /**
  48835. * Creation options of the multi render target texture.
  48836. */
  48837. export interface IMultiRenderTargetOptions {
  48838. /**
  48839. * Define if the texture needs to create mip maps after render.
  48840. */
  48841. generateMipMaps?: boolean;
  48842. /**
  48843. * Define the types of all the draw buffers we want to create
  48844. */
  48845. types?: number[];
  48846. /**
  48847. * Define the sampling modes of all the draw buffers we want to create
  48848. */
  48849. samplingModes?: number[];
  48850. /**
  48851. * Define if a depth buffer is required
  48852. */
  48853. generateDepthBuffer?: boolean;
  48854. /**
  48855. * Define if a stencil buffer is required
  48856. */
  48857. generateStencilBuffer?: boolean;
  48858. /**
  48859. * Define if a depth texture is required instead of a depth buffer
  48860. */
  48861. generateDepthTexture?: boolean;
  48862. /**
  48863. * Define the number of desired draw buffers
  48864. */
  48865. textureCount?: number;
  48866. /**
  48867. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48868. */
  48869. doNotChangeAspectRatio?: boolean;
  48870. /**
  48871. * Define the default type of the buffers we are creating
  48872. */
  48873. defaultType?: number;
  48874. }
  48875. /**
  48876. * A multi render target, like a render target provides the ability to render to a texture.
  48877. * Unlike the render target, it can render to several draw buffers in one draw.
  48878. * This is specially interesting in deferred rendering or for any effects requiring more than
  48879. * just one color from a single pass.
  48880. */
  48881. export class MultiRenderTarget extends RenderTargetTexture {
  48882. private _internalTextures;
  48883. private _textures;
  48884. private _multiRenderTargetOptions;
  48885. /**
  48886. * Get if draw buffers are currently supported by the used hardware and browser.
  48887. */
  48888. get isSupported(): boolean;
  48889. /**
  48890. * Get the list of textures generated by the multi render target.
  48891. */
  48892. get textures(): Texture[];
  48893. /**
  48894. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48895. */
  48896. get depthTexture(): Texture;
  48897. /**
  48898. * Set the wrapping mode on U of all the textures we are rendering to.
  48899. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48900. */
  48901. set wrapU(wrap: number);
  48902. /**
  48903. * Set the wrapping mode on V of all the textures we are rendering to.
  48904. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48905. */
  48906. set wrapV(wrap: number);
  48907. /**
  48908. * Instantiate a new multi render target texture.
  48909. * A multi render target, like a render target provides the ability to render to a texture.
  48910. * Unlike the render target, it can render to several draw buffers in one draw.
  48911. * This is specially interesting in deferred rendering or for any effects requiring more than
  48912. * just one color from a single pass.
  48913. * @param name Define the name of the texture
  48914. * @param size Define the size of the buffers to render to
  48915. * @param count Define the number of target we are rendering into
  48916. * @param scene Define the scene the texture belongs to
  48917. * @param options Define the options used to create the multi render target
  48918. */
  48919. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48920. /** @hidden */
  48921. _rebuild(): void;
  48922. private _createInternalTextures;
  48923. private _createTextures;
  48924. /**
  48925. * Define the number of samples used if MSAA is enabled.
  48926. */
  48927. get samples(): number;
  48928. set samples(value: number);
  48929. /**
  48930. * Resize all the textures in the multi render target.
  48931. * Be carrefull as it will recreate all the data in the new texture.
  48932. * @param size Define the new size
  48933. */
  48934. resize(size: any): void;
  48935. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48936. /**
  48937. * Dispose the render targets and their associated resources
  48938. */
  48939. dispose(): void;
  48940. /**
  48941. * Release all the underlying texture used as draw buffers.
  48942. */
  48943. releaseInternalTextures(): void;
  48944. }
  48945. }
  48946. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48948. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48949. import { Nullable } from "babylonjs/types";
  48950. module "babylonjs/Engines/thinEngine" {
  48951. interface ThinEngine {
  48952. /**
  48953. * Unbind a list of render target textures from the webGL context
  48954. * This is used only when drawBuffer extension or webGL2 are active
  48955. * @param textures defines the render target textures to unbind
  48956. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48957. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48958. */
  48959. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48960. /**
  48961. * Create a multi render target texture
  48962. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48963. * @param size defines the size of the texture
  48964. * @param options defines the creation options
  48965. * @returns the cube texture as an InternalTexture
  48966. */
  48967. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48968. /**
  48969. * Update the sample count for a given multiple render target texture
  48970. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48971. * @param textures defines the textures to update
  48972. * @param samples defines the sample count to set
  48973. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48974. */
  48975. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48976. }
  48977. }
  48978. }
  48979. declare module "babylonjs/Engines/Extensions/engine.views" {
  48980. import { Camera } from "babylonjs/Cameras/camera";
  48981. import { Nullable } from "babylonjs/types";
  48982. /**
  48983. * Class used to define an additional view for the engine
  48984. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48985. */
  48986. export class EngineView {
  48987. /** Defines the canvas where to render the view */
  48988. target: HTMLCanvasElement;
  48989. /** Defines an optional camera used to render the view (will use active camera else) */
  48990. camera?: Camera;
  48991. }
  48992. module "babylonjs/Engines/engine" {
  48993. interface Engine {
  48994. /**
  48995. * Gets or sets the HTML element to use for attaching events
  48996. */
  48997. inputElement: Nullable<HTMLElement>;
  48998. /**
  48999. * Gets the current engine view
  49000. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49001. */
  49002. activeView: Nullable<EngineView>;
  49003. /** Gets or sets the list of views */
  49004. views: EngineView[];
  49005. /**
  49006. * Register a new child canvas
  49007. * @param canvas defines the canvas to register
  49008. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49009. * @returns the associated view
  49010. */
  49011. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49012. /**
  49013. * Remove a registered child canvas
  49014. * @param canvas defines the canvas to remove
  49015. * @returns the current engine
  49016. */
  49017. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49018. }
  49019. }
  49020. }
  49021. declare module "babylonjs/Engines/Extensions/index" {
  49022. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49023. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49024. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49025. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49026. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49027. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49028. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49029. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49030. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49031. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49032. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49033. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49034. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49035. export * from "babylonjs/Engines/Extensions/engine.views";
  49036. }
  49037. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49038. import { Nullable } from "babylonjs/types";
  49039. /**
  49040. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49041. */
  49042. export interface CubeMapInfo {
  49043. /**
  49044. * The pixel array for the front face.
  49045. * This is stored in format, left to right, up to down format.
  49046. */
  49047. front: Nullable<ArrayBufferView>;
  49048. /**
  49049. * The pixel array for the back face.
  49050. * This is stored in format, left to right, up to down format.
  49051. */
  49052. back: Nullable<ArrayBufferView>;
  49053. /**
  49054. * The pixel array for the left face.
  49055. * This is stored in format, left to right, up to down format.
  49056. */
  49057. left: Nullable<ArrayBufferView>;
  49058. /**
  49059. * The pixel array for the right face.
  49060. * This is stored in format, left to right, up to down format.
  49061. */
  49062. right: Nullable<ArrayBufferView>;
  49063. /**
  49064. * The pixel array for the up face.
  49065. * This is stored in format, left to right, up to down format.
  49066. */
  49067. up: Nullable<ArrayBufferView>;
  49068. /**
  49069. * The pixel array for the down face.
  49070. * This is stored in format, left to right, up to down format.
  49071. */
  49072. down: Nullable<ArrayBufferView>;
  49073. /**
  49074. * The size of the cubemap stored.
  49075. *
  49076. * Each faces will be size * size pixels.
  49077. */
  49078. size: number;
  49079. /**
  49080. * The format of the texture.
  49081. *
  49082. * RGBA, RGB.
  49083. */
  49084. format: number;
  49085. /**
  49086. * The type of the texture data.
  49087. *
  49088. * UNSIGNED_INT, FLOAT.
  49089. */
  49090. type: number;
  49091. /**
  49092. * Specifies whether the texture is in gamma space.
  49093. */
  49094. gammaSpace: boolean;
  49095. }
  49096. /**
  49097. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49098. */
  49099. export class PanoramaToCubeMapTools {
  49100. private static FACE_FRONT;
  49101. private static FACE_BACK;
  49102. private static FACE_RIGHT;
  49103. private static FACE_LEFT;
  49104. private static FACE_DOWN;
  49105. private static FACE_UP;
  49106. /**
  49107. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49108. *
  49109. * @param float32Array The source data.
  49110. * @param inputWidth The width of the input panorama.
  49111. * @param inputHeight The height of the input panorama.
  49112. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49113. * @return The cubemap data
  49114. */
  49115. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49116. private static CreateCubemapTexture;
  49117. private static CalcProjectionSpherical;
  49118. }
  49119. }
  49120. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49121. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49122. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49123. import { Nullable } from "babylonjs/types";
  49124. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49125. /**
  49126. * Helper class dealing with the extraction of spherical polynomial dataArray
  49127. * from a cube map.
  49128. */
  49129. export class CubeMapToSphericalPolynomialTools {
  49130. private static FileFaces;
  49131. /**
  49132. * Converts a texture to the according Spherical Polynomial data.
  49133. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49134. *
  49135. * @param texture The texture to extract the information from.
  49136. * @return The Spherical Polynomial data.
  49137. */
  49138. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49139. /**
  49140. * Converts a cubemap to the according Spherical Polynomial data.
  49141. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49142. *
  49143. * @param cubeInfo The Cube map to extract the information from.
  49144. * @return The Spherical Polynomial data.
  49145. */
  49146. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49147. }
  49148. }
  49149. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49150. import { Nullable } from "babylonjs/types";
  49151. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49152. module "babylonjs/Materials/Textures/baseTexture" {
  49153. interface BaseTexture {
  49154. /**
  49155. * Get the polynomial representation of the texture data.
  49156. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49157. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49158. */
  49159. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49160. }
  49161. }
  49162. }
  49163. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49164. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49165. /** @hidden */
  49166. export var rgbdEncodePixelShader: {
  49167. name: string;
  49168. shader: string;
  49169. };
  49170. }
  49171. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49172. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49173. /** @hidden */
  49174. export var rgbdDecodePixelShader: {
  49175. name: string;
  49176. shader: string;
  49177. };
  49178. }
  49179. declare module "babylonjs/Misc/environmentTextureTools" {
  49180. import { Nullable } from "babylonjs/types";
  49181. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49182. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49183. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49184. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49185. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49186. import "babylonjs/Shaders/rgbdEncode.fragment";
  49187. import "babylonjs/Shaders/rgbdDecode.fragment";
  49188. /**
  49189. * Raw texture data and descriptor sufficient for WebGL texture upload
  49190. */
  49191. export interface EnvironmentTextureInfo {
  49192. /**
  49193. * Version of the environment map
  49194. */
  49195. version: number;
  49196. /**
  49197. * Width of image
  49198. */
  49199. width: number;
  49200. /**
  49201. * Irradiance information stored in the file.
  49202. */
  49203. irradiance: any;
  49204. /**
  49205. * Specular information stored in the file.
  49206. */
  49207. specular: any;
  49208. }
  49209. /**
  49210. * Defines One Image in the file. It requires only the position in the file
  49211. * as well as the length.
  49212. */
  49213. interface BufferImageData {
  49214. /**
  49215. * Length of the image data.
  49216. */
  49217. length: number;
  49218. /**
  49219. * Position of the data from the null terminator delimiting the end of the JSON.
  49220. */
  49221. position: number;
  49222. }
  49223. /**
  49224. * Defines the specular data enclosed in the file.
  49225. * This corresponds to the version 1 of the data.
  49226. */
  49227. export interface EnvironmentTextureSpecularInfoV1 {
  49228. /**
  49229. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49230. */
  49231. specularDataPosition?: number;
  49232. /**
  49233. * This contains all the images data needed to reconstruct the cubemap.
  49234. */
  49235. mipmaps: Array<BufferImageData>;
  49236. /**
  49237. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49238. */
  49239. lodGenerationScale: number;
  49240. }
  49241. /**
  49242. * Sets of helpers addressing the serialization and deserialization of environment texture
  49243. * stored in a BabylonJS env file.
  49244. * Those files are usually stored as .env files.
  49245. */
  49246. export class EnvironmentTextureTools {
  49247. /**
  49248. * Magic number identifying the env file.
  49249. */
  49250. private static _MagicBytes;
  49251. /**
  49252. * Gets the environment info from an env file.
  49253. * @param data The array buffer containing the .env bytes.
  49254. * @returns the environment file info (the json header) if successfully parsed.
  49255. */
  49256. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49257. /**
  49258. * Creates an environment texture from a loaded cube texture.
  49259. * @param texture defines the cube texture to convert in env file
  49260. * @return a promise containing the environment data if succesfull.
  49261. */
  49262. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49263. /**
  49264. * Creates a JSON representation of the spherical data.
  49265. * @param texture defines the texture containing the polynomials
  49266. * @return the JSON representation of the spherical info
  49267. */
  49268. private static _CreateEnvTextureIrradiance;
  49269. /**
  49270. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49271. * @param data the image data
  49272. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49273. * @return the views described by info providing access to the underlying buffer
  49274. */
  49275. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49276. /**
  49277. * Uploads the texture info contained in the env file to the GPU.
  49278. * @param texture defines the internal texture to upload to
  49279. * @param data defines the data to load
  49280. * @param info defines the texture info retrieved through the GetEnvInfo method
  49281. * @returns a promise
  49282. */
  49283. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49284. private static _OnImageReadyAsync;
  49285. /**
  49286. * Uploads the levels of image data to the GPU.
  49287. * @param texture defines the internal texture to upload to
  49288. * @param imageData defines the array buffer views of image data [mipmap][face]
  49289. * @returns a promise
  49290. */
  49291. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49292. /**
  49293. * Uploads spherical polynomials information to the texture.
  49294. * @param texture defines the texture we are trying to upload the information to
  49295. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49296. */
  49297. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49298. /** @hidden */
  49299. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49300. }
  49301. }
  49302. declare module "babylonjs/Maths/math.vertexFormat" {
  49303. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49304. /**
  49305. * Contains position and normal vectors for a vertex
  49306. */
  49307. export class PositionNormalVertex {
  49308. /** the position of the vertex (defaut: 0,0,0) */
  49309. position: Vector3;
  49310. /** the normal of the vertex (defaut: 0,1,0) */
  49311. normal: Vector3;
  49312. /**
  49313. * Creates a PositionNormalVertex
  49314. * @param position the position of the vertex (defaut: 0,0,0)
  49315. * @param normal the normal of the vertex (defaut: 0,1,0)
  49316. */
  49317. constructor(
  49318. /** the position of the vertex (defaut: 0,0,0) */
  49319. position?: Vector3,
  49320. /** the normal of the vertex (defaut: 0,1,0) */
  49321. normal?: Vector3);
  49322. /**
  49323. * Clones the PositionNormalVertex
  49324. * @returns the cloned PositionNormalVertex
  49325. */
  49326. clone(): PositionNormalVertex;
  49327. }
  49328. /**
  49329. * Contains position, normal and uv vectors for a vertex
  49330. */
  49331. export class PositionNormalTextureVertex {
  49332. /** the position of the vertex (defaut: 0,0,0) */
  49333. position: Vector3;
  49334. /** the normal of the vertex (defaut: 0,1,0) */
  49335. normal: Vector3;
  49336. /** the uv of the vertex (default: 0,0) */
  49337. uv: Vector2;
  49338. /**
  49339. * Creates a PositionNormalTextureVertex
  49340. * @param position the position of the vertex (defaut: 0,0,0)
  49341. * @param normal the normal of the vertex (defaut: 0,1,0)
  49342. * @param uv the uv of the vertex (default: 0,0)
  49343. */
  49344. constructor(
  49345. /** the position of the vertex (defaut: 0,0,0) */
  49346. position?: Vector3,
  49347. /** the normal of the vertex (defaut: 0,1,0) */
  49348. normal?: Vector3,
  49349. /** the uv of the vertex (default: 0,0) */
  49350. uv?: Vector2);
  49351. /**
  49352. * Clones the PositionNormalTextureVertex
  49353. * @returns the cloned PositionNormalTextureVertex
  49354. */
  49355. clone(): PositionNormalTextureVertex;
  49356. }
  49357. }
  49358. declare module "babylonjs/Maths/math" {
  49359. export * from "babylonjs/Maths/math.axis";
  49360. export * from "babylonjs/Maths/math.color";
  49361. export * from "babylonjs/Maths/math.constants";
  49362. export * from "babylonjs/Maths/math.frustum";
  49363. export * from "babylonjs/Maths/math.path";
  49364. export * from "babylonjs/Maths/math.plane";
  49365. export * from "babylonjs/Maths/math.size";
  49366. export * from "babylonjs/Maths/math.vector";
  49367. export * from "babylonjs/Maths/math.vertexFormat";
  49368. export * from "babylonjs/Maths/math.viewport";
  49369. }
  49370. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49371. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49372. /** @hidden */
  49373. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49374. private _genericAttributeLocation;
  49375. private _varyingLocationCount;
  49376. private _varyingLocationMap;
  49377. private _replacements;
  49378. private _textureCount;
  49379. private _uniforms;
  49380. lineProcessor(line: string): string;
  49381. attributeProcessor(attribute: string): string;
  49382. varyingProcessor(varying: string, isFragment: boolean): string;
  49383. uniformProcessor(uniform: string): string;
  49384. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49385. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49386. }
  49387. }
  49388. declare module "babylonjs/Engines/nativeEngine" {
  49389. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49390. import { Engine } from "babylonjs/Engines/engine";
  49391. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49392. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49394. import { Effect } from "babylonjs/Materials/effect";
  49395. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49396. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49397. import { IColor4Like } from "babylonjs/Maths/math.like";
  49398. import { Scene } from "babylonjs/scene";
  49399. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49400. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49401. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49402. /**
  49403. * Container for accessors for natively-stored mesh data buffers.
  49404. */
  49405. class NativeDataBuffer extends DataBuffer {
  49406. /**
  49407. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49408. */
  49409. nativeIndexBuffer?: any;
  49410. /**
  49411. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49412. */
  49413. nativeVertexBuffer?: any;
  49414. }
  49415. /** @hidden */
  49416. class NativeTexture extends InternalTexture {
  49417. getInternalTexture(): InternalTexture;
  49418. getViewCount(): number;
  49419. }
  49420. /** @hidden */
  49421. export class NativeEngine extends Engine {
  49422. private readonly _native;
  49423. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49424. private readonly INVALID_HANDLE;
  49425. getHardwareScalingLevel(): number;
  49426. constructor();
  49427. /**
  49428. * Can be used to override the current requestAnimationFrame requester.
  49429. * @hidden
  49430. */
  49431. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49432. /**
  49433. * Override default engine behavior.
  49434. * @param color
  49435. * @param backBuffer
  49436. * @param depth
  49437. * @param stencil
  49438. */
  49439. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49440. /**
  49441. * Gets host document
  49442. * @returns the host document object
  49443. */
  49444. getHostDocument(): Nullable<Document>;
  49445. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49446. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49447. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49448. recordVertexArrayObject(vertexBuffers: {
  49449. [key: string]: VertexBuffer;
  49450. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49451. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49452. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49453. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49454. /**
  49455. * Draw a list of indexed primitives
  49456. * @param fillMode defines the primitive to use
  49457. * @param indexStart defines the starting index
  49458. * @param indexCount defines the number of index to draw
  49459. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49460. */
  49461. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49462. /**
  49463. * Draw a list of unindexed primitives
  49464. * @param fillMode defines the primitive to use
  49465. * @param verticesStart defines the index of first vertex to draw
  49466. * @param verticesCount defines the count of vertices to draw
  49467. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49468. */
  49469. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49470. createPipelineContext(): IPipelineContext;
  49471. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49472. /** @hidden */
  49473. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49474. /** @hidden */
  49475. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49476. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49477. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49478. protected _setProgram(program: WebGLProgram): void;
  49479. _releaseEffect(effect: Effect): void;
  49480. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49481. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49482. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49483. bindSamplers(effect: Effect): void;
  49484. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49485. getRenderWidth(useScreen?: boolean): number;
  49486. getRenderHeight(useScreen?: boolean): number;
  49487. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49488. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49489. /**
  49490. * Set the z offset to apply to current rendering
  49491. * @param value defines the offset to apply
  49492. */
  49493. setZOffset(value: number): void;
  49494. /**
  49495. * Gets the current value of the zOffset
  49496. * @returns the current zOffset state
  49497. */
  49498. getZOffset(): number;
  49499. /**
  49500. * Enable or disable depth buffering
  49501. * @param enable defines the state to set
  49502. */
  49503. setDepthBuffer(enable: boolean): void;
  49504. /**
  49505. * Gets a boolean indicating if depth writing is enabled
  49506. * @returns the current depth writing state
  49507. */
  49508. getDepthWrite(): boolean;
  49509. /**
  49510. * Enable or disable depth writing
  49511. * @param enable defines the state to set
  49512. */
  49513. setDepthWrite(enable: boolean): void;
  49514. /**
  49515. * Enable or disable color writing
  49516. * @param enable defines the state to set
  49517. */
  49518. setColorWrite(enable: boolean): void;
  49519. /**
  49520. * Gets a boolean indicating if color writing is enabled
  49521. * @returns the current color writing state
  49522. */
  49523. getColorWrite(): boolean;
  49524. /**
  49525. * Sets alpha constants used by some alpha blending modes
  49526. * @param r defines the red component
  49527. * @param g defines the green component
  49528. * @param b defines the blue component
  49529. * @param a defines the alpha component
  49530. */
  49531. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49532. /**
  49533. * Sets the current alpha mode
  49534. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49535. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49536. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49537. */
  49538. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49539. /**
  49540. * Gets the current alpha mode
  49541. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49542. * @returns the current alpha mode
  49543. */
  49544. getAlphaMode(): number;
  49545. setInt(uniform: WebGLUniformLocation, int: number): void;
  49546. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49547. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49548. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49549. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49550. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49551. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49552. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49553. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49554. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49555. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49556. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49557. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49558. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49559. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49560. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49561. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49562. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49563. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49564. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49565. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49566. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49567. wipeCaches(bruteForce?: boolean): void;
  49568. _createTexture(): WebGLTexture;
  49569. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49570. /**
  49571. * Usually called from Texture.ts.
  49572. * Passed information to create a WebGLTexture
  49573. * @param urlArg defines a value which contains one of the following:
  49574. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49575. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49576. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49577. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49578. * @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)
  49579. * @param scene needed for loading to the correct scene
  49580. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49581. * @param onLoad optional callback to be called upon successful completion
  49582. * @param onError optional callback to be called upon failure
  49583. * @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
  49584. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49585. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49586. * @param forcedExtension defines the extension to use to pick the right loader
  49587. * @param mimeType defines an optional mime type
  49588. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49589. */
  49590. 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;
  49591. /**
  49592. * Creates a cube texture
  49593. * @param rootUrl defines the url where the files to load is located
  49594. * @param scene defines the current scene
  49595. * @param files defines the list of files to load (1 per face)
  49596. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49597. * @param onLoad defines an optional callback raised when the texture is loaded
  49598. * @param onError defines an optional callback raised if there is an issue to load the texture
  49599. * @param format defines the format of the data
  49600. * @param forcedExtension defines the extension to use to pick the right loader
  49601. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49602. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49603. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49604. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49605. * @returns the cube texture as an InternalTexture
  49606. */
  49607. 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;
  49608. private _getSamplingFilter;
  49609. private static _GetNativeTextureFormat;
  49610. createRenderTargetTexture(size: number | {
  49611. width: number;
  49612. height: number;
  49613. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49614. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49615. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49616. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49617. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49618. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49619. /**
  49620. * Updates a dynamic vertex buffer.
  49621. * @param vertexBuffer the vertex buffer to update
  49622. * @param data the data used to update the vertex buffer
  49623. * @param byteOffset the byte offset of the data (optional)
  49624. * @param byteLength the byte length of the data (optional)
  49625. */
  49626. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49627. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49628. private _updateAnisotropicLevel;
  49629. private _getAddressMode;
  49630. /** @hidden */
  49631. _bindTexture(channel: number, texture: InternalTexture): void;
  49632. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49633. releaseEffects(): void;
  49634. /** @hidden */
  49635. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49636. /** @hidden */
  49637. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49638. /** @hidden */
  49639. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49640. /** @hidden */
  49641. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49642. }
  49643. }
  49644. declare module "babylonjs/Engines/index" {
  49645. export * from "babylonjs/Engines/constants";
  49646. export * from "babylonjs/Engines/engineCapabilities";
  49647. export * from "babylonjs/Engines/instancingAttributeInfo";
  49648. export * from "babylonjs/Engines/thinEngine";
  49649. export * from "babylonjs/Engines/engine";
  49650. export * from "babylonjs/Engines/engineStore";
  49651. export * from "babylonjs/Engines/nullEngine";
  49652. export * from "babylonjs/Engines/Extensions/index";
  49653. export * from "babylonjs/Engines/IPipelineContext";
  49654. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49655. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49656. export * from "babylonjs/Engines/nativeEngine";
  49657. }
  49658. declare module "babylonjs/Events/clipboardEvents" {
  49659. /**
  49660. * Gather the list of clipboard event types as constants.
  49661. */
  49662. export class ClipboardEventTypes {
  49663. /**
  49664. * The clipboard event is fired when a copy command is active (pressed).
  49665. */
  49666. static readonly COPY: number;
  49667. /**
  49668. * The clipboard event is fired when a cut command is active (pressed).
  49669. */
  49670. static readonly CUT: number;
  49671. /**
  49672. * The clipboard event is fired when a paste command is active (pressed).
  49673. */
  49674. static readonly PASTE: number;
  49675. }
  49676. /**
  49677. * This class is used to store clipboard related info for the onClipboardObservable event.
  49678. */
  49679. export class ClipboardInfo {
  49680. /**
  49681. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49682. */
  49683. type: number;
  49684. /**
  49685. * Defines the related dom event
  49686. */
  49687. event: ClipboardEvent;
  49688. /**
  49689. *Creates an instance of ClipboardInfo.
  49690. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49691. * @param event Defines the related dom event
  49692. */
  49693. constructor(
  49694. /**
  49695. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49696. */
  49697. type: number,
  49698. /**
  49699. * Defines the related dom event
  49700. */
  49701. event: ClipboardEvent);
  49702. /**
  49703. * Get the clipboard event's type from the keycode.
  49704. * @param keyCode Defines the keyCode for the current keyboard event.
  49705. * @return {number}
  49706. */
  49707. static GetTypeFromCharacter(keyCode: number): number;
  49708. }
  49709. }
  49710. declare module "babylonjs/Events/index" {
  49711. export * from "babylonjs/Events/keyboardEvents";
  49712. export * from "babylonjs/Events/pointerEvents";
  49713. export * from "babylonjs/Events/clipboardEvents";
  49714. }
  49715. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49716. import { Scene } from "babylonjs/scene";
  49717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49718. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49719. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49720. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49721. /**
  49722. * Google Daydream controller
  49723. */
  49724. export class DaydreamController extends WebVRController {
  49725. /**
  49726. * Base Url for the controller model.
  49727. */
  49728. static MODEL_BASE_URL: string;
  49729. /**
  49730. * File name for the controller model.
  49731. */
  49732. static MODEL_FILENAME: string;
  49733. /**
  49734. * Gamepad Id prefix used to identify Daydream Controller.
  49735. */
  49736. static readonly GAMEPAD_ID_PREFIX: string;
  49737. /**
  49738. * Creates a new DaydreamController from a gamepad
  49739. * @param vrGamepad the gamepad that the controller should be created from
  49740. */
  49741. constructor(vrGamepad: any);
  49742. /**
  49743. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49744. * @param scene scene in which to add meshes
  49745. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49746. */
  49747. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49748. /**
  49749. * Called once for each button that changed state since the last frame
  49750. * @param buttonIdx Which button index changed
  49751. * @param state New state of the button
  49752. * @param changes Which properties on the state changed since last frame
  49753. */
  49754. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49755. }
  49756. }
  49757. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49758. import { Scene } from "babylonjs/scene";
  49759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49760. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49761. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49762. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49763. /**
  49764. * Gear VR Controller
  49765. */
  49766. export class GearVRController extends WebVRController {
  49767. /**
  49768. * Base Url for the controller model.
  49769. */
  49770. static MODEL_BASE_URL: string;
  49771. /**
  49772. * File name for the controller model.
  49773. */
  49774. static MODEL_FILENAME: string;
  49775. /**
  49776. * Gamepad Id prefix used to identify this controller.
  49777. */
  49778. static readonly GAMEPAD_ID_PREFIX: string;
  49779. private readonly _buttonIndexToObservableNameMap;
  49780. /**
  49781. * Creates a new GearVRController from a gamepad
  49782. * @param vrGamepad the gamepad that the controller should be created from
  49783. */
  49784. constructor(vrGamepad: any);
  49785. /**
  49786. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49787. * @param scene scene in which to add meshes
  49788. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49789. */
  49790. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49791. /**
  49792. * Called once for each button that changed state since the last frame
  49793. * @param buttonIdx Which button index changed
  49794. * @param state New state of the button
  49795. * @param changes Which properties on the state changed since last frame
  49796. */
  49797. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49798. }
  49799. }
  49800. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49801. import { Scene } from "babylonjs/scene";
  49802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49803. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49804. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49805. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49806. /**
  49807. * Generic Controller
  49808. */
  49809. export class GenericController extends WebVRController {
  49810. /**
  49811. * Base Url for the controller model.
  49812. */
  49813. static readonly MODEL_BASE_URL: string;
  49814. /**
  49815. * File name for the controller model.
  49816. */
  49817. static readonly MODEL_FILENAME: string;
  49818. /**
  49819. * Creates a new GenericController from a gamepad
  49820. * @param vrGamepad the gamepad that the controller should be created from
  49821. */
  49822. constructor(vrGamepad: any);
  49823. /**
  49824. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49825. * @param scene scene in which to add meshes
  49826. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49827. */
  49828. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49829. /**
  49830. * Called once for each button that changed state since the last frame
  49831. * @param buttonIdx Which button index changed
  49832. * @param state New state of the button
  49833. * @param changes Which properties on the state changed since last frame
  49834. */
  49835. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49836. }
  49837. }
  49838. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49839. import { Observable } from "babylonjs/Misc/observable";
  49840. import { Scene } from "babylonjs/scene";
  49841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49842. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49843. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49844. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49845. /**
  49846. * Oculus Touch Controller
  49847. */
  49848. export class OculusTouchController extends WebVRController {
  49849. /**
  49850. * Base Url for the controller model.
  49851. */
  49852. static MODEL_BASE_URL: string;
  49853. /**
  49854. * File name for the left controller model.
  49855. */
  49856. static MODEL_LEFT_FILENAME: string;
  49857. /**
  49858. * File name for the right controller model.
  49859. */
  49860. static MODEL_RIGHT_FILENAME: string;
  49861. /**
  49862. * Base Url for the Quest controller model.
  49863. */
  49864. static QUEST_MODEL_BASE_URL: string;
  49865. /**
  49866. * @hidden
  49867. * If the controllers are running on a device that needs the updated Quest controller models
  49868. */
  49869. static _IsQuest: boolean;
  49870. /**
  49871. * Fired when the secondary trigger on this controller is modified
  49872. */
  49873. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49874. /**
  49875. * Fired when the thumb rest on this controller is modified
  49876. */
  49877. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49878. /**
  49879. * Creates a new OculusTouchController from a gamepad
  49880. * @param vrGamepad the gamepad that the controller should be created from
  49881. */
  49882. constructor(vrGamepad: any);
  49883. /**
  49884. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49885. * @param scene scene in which to add meshes
  49886. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49887. */
  49888. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49889. /**
  49890. * Fired when the A button on this controller is modified
  49891. */
  49892. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49893. /**
  49894. * Fired when the B button on this controller is modified
  49895. */
  49896. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49897. /**
  49898. * Fired when the X button on this controller is modified
  49899. */
  49900. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49901. /**
  49902. * Fired when the Y button on this controller is modified
  49903. */
  49904. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49905. /**
  49906. * Called once for each button that changed state since the last frame
  49907. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49908. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49909. * 2) secondary trigger (same)
  49910. * 3) A (right) X (left), touch, pressed = value
  49911. * 4) B / Y
  49912. * 5) thumb rest
  49913. * @param buttonIdx Which button index changed
  49914. * @param state New state of the button
  49915. * @param changes Which properties on the state changed since last frame
  49916. */
  49917. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49918. }
  49919. }
  49920. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49921. import { Scene } from "babylonjs/scene";
  49922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49923. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49924. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49925. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49926. import { Observable } from "babylonjs/Misc/observable";
  49927. /**
  49928. * Vive Controller
  49929. */
  49930. export class ViveController extends WebVRController {
  49931. /**
  49932. * Base Url for the controller model.
  49933. */
  49934. static MODEL_BASE_URL: string;
  49935. /**
  49936. * File name for the controller model.
  49937. */
  49938. static MODEL_FILENAME: string;
  49939. /**
  49940. * Creates a new ViveController from a gamepad
  49941. * @param vrGamepad the gamepad that the controller should be created from
  49942. */
  49943. constructor(vrGamepad: any);
  49944. /**
  49945. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49946. * @param scene scene in which to add meshes
  49947. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49948. */
  49949. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49950. /**
  49951. * Fired when the left button on this controller is modified
  49952. */
  49953. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49954. /**
  49955. * Fired when the right button on this controller is modified
  49956. */
  49957. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49958. /**
  49959. * Fired when the menu button on this controller is modified
  49960. */
  49961. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49962. /**
  49963. * Called once for each button that changed state since the last frame
  49964. * Vive mapping:
  49965. * 0: touchpad
  49966. * 1: trigger
  49967. * 2: left AND right buttons
  49968. * 3: menu button
  49969. * @param buttonIdx Which button index changed
  49970. * @param state New state of the button
  49971. * @param changes Which properties on the state changed since last frame
  49972. */
  49973. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49974. }
  49975. }
  49976. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49977. import { Observable } from "babylonjs/Misc/observable";
  49978. import { Scene } from "babylonjs/scene";
  49979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49980. import { Ray } from "babylonjs/Culling/ray";
  49981. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49982. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49983. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49984. /**
  49985. * Defines the WindowsMotionController object that the state of the windows motion controller
  49986. */
  49987. export class WindowsMotionController extends WebVRController {
  49988. /**
  49989. * The base url used to load the left and right controller models
  49990. */
  49991. static MODEL_BASE_URL: string;
  49992. /**
  49993. * The name of the left controller model file
  49994. */
  49995. static MODEL_LEFT_FILENAME: string;
  49996. /**
  49997. * The name of the right controller model file
  49998. */
  49999. static MODEL_RIGHT_FILENAME: string;
  50000. /**
  50001. * The controller name prefix for this controller type
  50002. */
  50003. static readonly GAMEPAD_ID_PREFIX: string;
  50004. /**
  50005. * The controller id pattern for this controller type
  50006. */
  50007. private static readonly GAMEPAD_ID_PATTERN;
  50008. private _loadedMeshInfo;
  50009. protected readonly _mapping: {
  50010. buttons: string[];
  50011. buttonMeshNames: {
  50012. 'trigger': string;
  50013. 'menu': string;
  50014. 'grip': string;
  50015. 'thumbstick': string;
  50016. 'trackpad': string;
  50017. };
  50018. buttonObservableNames: {
  50019. 'trigger': string;
  50020. 'menu': string;
  50021. 'grip': string;
  50022. 'thumbstick': string;
  50023. 'trackpad': string;
  50024. };
  50025. axisMeshNames: string[];
  50026. pointingPoseMeshName: string;
  50027. };
  50028. /**
  50029. * Fired when the trackpad on this controller is clicked
  50030. */
  50031. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50032. /**
  50033. * Fired when the trackpad on this controller is modified
  50034. */
  50035. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50036. /**
  50037. * The current x and y values of this controller's trackpad
  50038. */
  50039. trackpad: StickValues;
  50040. /**
  50041. * Creates a new WindowsMotionController from a gamepad
  50042. * @param vrGamepad the gamepad that the controller should be created from
  50043. */
  50044. constructor(vrGamepad: any);
  50045. /**
  50046. * Fired when the trigger on this controller is modified
  50047. */
  50048. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50049. /**
  50050. * Fired when the menu button on this controller is modified
  50051. */
  50052. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50053. /**
  50054. * Fired when the grip button on this controller is modified
  50055. */
  50056. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50057. /**
  50058. * Fired when the thumbstick button on this controller is modified
  50059. */
  50060. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50061. /**
  50062. * Fired when the touchpad button on this controller is modified
  50063. */
  50064. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50065. /**
  50066. * Fired when the touchpad values on this controller are modified
  50067. */
  50068. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50069. protected _updateTrackpad(): void;
  50070. /**
  50071. * Called once per frame by the engine.
  50072. */
  50073. update(): void;
  50074. /**
  50075. * Called once for each button that changed state since the last frame
  50076. * @param buttonIdx Which button index changed
  50077. * @param state New state of the button
  50078. * @param changes Which properties on the state changed since last frame
  50079. */
  50080. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50081. /**
  50082. * Moves the buttons on the controller mesh based on their current state
  50083. * @param buttonName the name of the button to move
  50084. * @param buttonValue the value of the button which determines the buttons new position
  50085. */
  50086. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50087. /**
  50088. * Moves the axis on the controller mesh based on its current state
  50089. * @param axis the index of the axis
  50090. * @param axisValue the value of the axis which determines the meshes new position
  50091. * @hidden
  50092. */
  50093. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50094. /**
  50095. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50096. * @param scene scene in which to add meshes
  50097. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50098. */
  50099. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50100. /**
  50101. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50102. * can be transformed by button presses and axes values, based on this._mapping.
  50103. *
  50104. * @param scene scene in which the meshes exist
  50105. * @param meshes list of meshes that make up the controller model to process
  50106. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50107. */
  50108. private processModel;
  50109. private createMeshInfo;
  50110. /**
  50111. * Gets the ray of the controller in the direction the controller is pointing
  50112. * @param length the length the resulting ray should be
  50113. * @returns a ray in the direction the controller is pointing
  50114. */
  50115. getForwardRay(length?: number): Ray;
  50116. /**
  50117. * Disposes of the controller
  50118. */
  50119. dispose(): void;
  50120. }
  50121. /**
  50122. * This class represents a new windows motion controller in XR.
  50123. */
  50124. export class XRWindowsMotionController extends WindowsMotionController {
  50125. /**
  50126. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50127. */
  50128. protected readonly _mapping: {
  50129. buttons: string[];
  50130. buttonMeshNames: {
  50131. 'trigger': string;
  50132. 'menu': string;
  50133. 'grip': string;
  50134. 'thumbstick': string;
  50135. 'trackpad': string;
  50136. };
  50137. buttonObservableNames: {
  50138. 'trigger': string;
  50139. 'menu': string;
  50140. 'grip': string;
  50141. 'thumbstick': string;
  50142. 'trackpad': string;
  50143. };
  50144. axisMeshNames: string[];
  50145. pointingPoseMeshName: string;
  50146. };
  50147. /**
  50148. * Construct a new XR-Based windows motion controller
  50149. *
  50150. * @param gamepadInfo the gamepad object from the browser
  50151. */
  50152. constructor(gamepadInfo: any);
  50153. /**
  50154. * holds the thumbstick values (X,Y)
  50155. */
  50156. thumbstickValues: StickValues;
  50157. /**
  50158. * Fired when the thumbstick on this controller is clicked
  50159. */
  50160. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50161. /**
  50162. * Fired when the thumbstick on this controller is modified
  50163. */
  50164. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50165. /**
  50166. * Fired when the touchpad button on this controller is modified
  50167. */
  50168. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50169. /**
  50170. * Fired when the touchpad values on this controller are modified
  50171. */
  50172. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50173. /**
  50174. * Fired when the thumbstick button on this controller is modified
  50175. * here to prevent breaking changes
  50176. */
  50177. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50178. /**
  50179. * updating the thumbstick(!) and not the trackpad.
  50180. * This is named this way due to the difference between WebVR and XR and to avoid
  50181. * changing the parent class.
  50182. */
  50183. protected _updateTrackpad(): void;
  50184. /**
  50185. * Disposes the class with joy
  50186. */
  50187. dispose(): void;
  50188. }
  50189. }
  50190. declare module "babylonjs/Gamepads/Controllers/index" {
  50191. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50192. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50193. export * from "babylonjs/Gamepads/Controllers/genericController";
  50194. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50195. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50196. export * from "babylonjs/Gamepads/Controllers/viveController";
  50197. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50198. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50199. }
  50200. declare module "babylonjs/Gamepads/index" {
  50201. export * from "babylonjs/Gamepads/Controllers/index";
  50202. export * from "babylonjs/Gamepads/gamepad";
  50203. export * from "babylonjs/Gamepads/gamepadManager";
  50204. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50205. export * from "babylonjs/Gamepads/xboxGamepad";
  50206. export * from "babylonjs/Gamepads/dualShockGamepad";
  50207. }
  50208. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50209. import { Scene } from "babylonjs/scene";
  50210. import { Vector4 } from "babylonjs/Maths/math.vector";
  50211. import { Color4 } from "babylonjs/Maths/math.color";
  50212. import { Mesh } from "babylonjs/Meshes/mesh";
  50213. import { Nullable } from "babylonjs/types";
  50214. /**
  50215. * Class containing static functions to help procedurally build meshes
  50216. */
  50217. export class PolyhedronBuilder {
  50218. /**
  50219. * Creates a polyhedron mesh
  50220. * * 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
  50221. * * The parameter `size` (positive float, default 1) sets the polygon size
  50222. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50223. * * 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`
  50224. * * 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
  50225. * * 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)`)
  50226. * * 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
  50227. * * 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
  50228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50231. * @param name defines the name of the mesh
  50232. * @param options defines the options used to create the mesh
  50233. * @param scene defines the hosting scene
  50234. * @returns the polyhedron mesh
  50235. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50236. */
  50237. static CreatePolyhedron(name: string, options: {
  50238. type?: number;
  50239. size?: number;
  50240. sizeX?: number;
  50241. sizeY?: number;
  50242. sizeZ?: number;
  50243. custom?: any;
  50244. faceUV?: Vector4[];
  50245. faceColors?: Color4[];
  50246. flat?: boolean;
  50247. updatable?: boolean;
  50248. sideOrientation?: number;
  50249. frontUVs?: Vector4;
  50250. backUVs?: Vector4;
  50251. }, scene?: Nullable<Scene>): Mesh;
  50252. }
  50253. }
  50254. declare module "babylonjs/Gizmos/scaleGizmo" {
  50255. import { Observable } from "babylonjs/Misc/observable";
  50256. import { Nullable } from "babylonjs/types";
  50257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50258. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50259. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50260. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50261. /**
  50262. * Gizmo that enables scaling a mesh along 3 axis
  50263. */
  50264. export class ScaleGizmo extends Gizmo {
  50265. /**
  50266. * Internal gizmo used for interactions on the x axis
  50267. */
  50268. xGizmo: AxisScaleGizmo;
  50269. /**
  50270. * Internal gizmo used for interactions on the y axis
  50271. */
  50272. yGizmo: AxisScaleGizmo;
  50273. /**
  50274. * Internal gizmo used for interactions on the z axis
  50275. */
  50276. zGizmo: AxisScaleGizmo;
  50277. /**
  50278. * Internal gizmo used to scale all axis equally
  50279. */
  50280. uniformScaleGizmo: AxisScaleGizmo;
  50281. private _meshAttached;
  50282. private _updateGizmoRotationToMatchAttachedMesh;
  50283. private _snapDistance;
  50284. private _scaleRatio;
  50285. private _uniformScalingMesh;
  50286. private _octahedron;
  50287. private _sensitivity;
  50288. /** Fires an event when any of it's sub gizmos are dragged */
  50289. onDragStartObservable: Observable<unknown>;
  50290. /** Fires an event when any of it's sub gizmos are released from dragging */
  50291. onDragEndObservable: Observable<unknown>;
  50292. get attachedMesh(): Nullable<AbstractMesh>;
  50293. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50294. /**
  50295. * Creates a ScaleGizmo
  50296. * @param gizmoLayer The utility layer the gizmo will be added to
  50297. */
  50298. constructor(gizmoLayer?: UtilityLayerRenderer);
  50299. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50300. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50301. /**
  50302. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50303. */
  50304. set snapDistance(value: number);
  50305. get snapDistance(): number;
  50306. /**
  50307. * Ratio for the scale of the gizmo (Default: 1)
  50308. */
  50309. set scaleRatio(value: number);
  50310. get scaleRatio(): number;
  50311. /**
  50312. * Sensitivity factor for dragging (Default: 1)
  50313. */
  50314. set sensitivity(value: number);
  50315. get sensitivity(): number;
  50316. /**
  50317. * Disposes of the gizmo
  50318. */
  50319. dispose(): void;
  50320. }
  50321. }
  50322. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50323. import { Observable } from "babylonjs/Misc/observable";
  50324. import { Nullable } from "babylonjs/types";
  50325. import { Vector3 } from "babylonjs/Maths/math.vector";
  50326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50327. import { Mesh } from "babylonjs/Meshes/mesh";
  50328. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50329. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50330. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50331. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50332. import { Color3 } from "babylonjs/Maths/math.color";
  50333. /**
  50334. * Single axis scale gizmo
  50335. */
  50336. export class AxisScaleGizmo extends Gizmo {
  50337. /**
  50338. * Drag behavior responsible for the gizmos dragging interactions
  50339. */
  50340. dragBehavior: PointerDragBehavior;
  50341. private _pointerObserver;
  50342. /**
  50343. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50344. */
  50345. snapDistance: number;
  50346. /**
  50347. * Event that fires each time the gizmo snaps to a new location.
  50348. * * snapDistance is the the change in distance
  50349. */
  50350. onSnapObservable: Observable<{
  50351. snapDistance: number;
  50352. }>;
  50353. /**
  50354. * If the scaling operation should be done on all axis (default: false)
  50355. */
  50356. uniformScaling: boolean;
  50357. /**
  50358. * Custom sensitivity value for the drag strength
  50359. */
  50360. sensitivity: number;
  50361. private _isEnabled;
  50362. private _parent;
  50363. private _arrow;
  50364. private _coloredMaterial;
  50365. private _hoverMaterial;
  50366. /**
  50367. * Creates an AxisScaleGizmo
  50368. * @param gizmoLayer The utility layer the gizmo will be added to
  50369. * @param dragAxis The axis which the gizmo will be able to scale on
  50370. * @param color The color of the gizmo
  50371. */
  50372. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50373. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50374. /**
  50375. * If the gizmo is enabled
  50376. */
  50377. set isEnabled(value: boolean);
  50378. get isEnabled(): boolean;
  50379. /**
  50380. * Disposes of the gizmo
  50381. */
  50382. dispose(): void;
  50383. /**
  50384. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50385. * @param mesh The mesh to replace the default mesh of the gizmo
  50386. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50387. */
  50388. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50389. }
  50390. }
  50391. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50392. import { Observable } from "babylonjs/Misc/observable";
  50393. import { Nullable } from "babylonjs/types";
  50394. import { Vector3 } from "babylonjs/Maths/math.vector";
  50395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50396. import { Mesh } from "babylonjs/Meshes/mesh";
  50397. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50398. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50399. import { Color3 } from "babylonjs/Maths/math.color";
  50400. import "babylonjs/Meshes/Builders/boxBuilder";
  50401. /**
  50402. * Bounding box gizmo
  50403. */
  50404. export class BoundingBoxGizmo extends Gizmo {
  50405. private _lineBoundingBox;
  50406. private _rotateSpheresParent;
  50407. private _scaleBoxesParent;
  50408. private _boundingDimensions;
  50409. private _renderObserver;
  50410. private _pointerObserver;
  50411. private _scaleDragSpeed;
  50412. private _tmpQuaternion;
  50413. private _tmpVector;
  50414. private _tmpRotationMatrix;
  50415. /**
  50416. * 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)
  50417. */
  50418. ignoreChildren: boolean;
  50419. /**
  50420. * 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)
  50421. */
  50422. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50423. /**
  50424. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50425. */
  50426. rotationSphereSize: number;
  50427. /**
  50428. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50429. */
  50430. scaleBoxSize: number;
  50431. /**
  50432. * 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)
  50433. */
  50434. fixedDragMeshScreenSize: boolean;
  50435. /**
  50436. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50437. */
  50438. fixedDragMeshScreenSizeDistanceFactor: number;
  50439. /**
  50440. * Fired when a rotation sphere or scale box is dragged
  50441. */
  50442. onDragStartObservable: Observable<{}>;
  50443. /**
  50444. * Fired when a scale box is dragged
  50445. */
  50446. onScaleBoxDragObservable: Observable<{}>;
  50447. /**
  50448. * Fired when a scale box drag is ended
  50449. */
  50450. onScaleBoxDragEndObservable: Observable<{}>;
  50451. /**
  50452. * Fired when a rotation sphere is dragged
  50453. */
  50454. onRotationSphereDragObservable: Observable<{}>;
  50455. /**
  50456. * Fired when a rotation sphere drag is ended
  50457. */
  50458. onRotationSphereDragEndObservable: Observable<{}>;
  50459. /**
  50460. * 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)
  50461. */
  50462. scalePivot: Nullable<Vector3>;
  50463. /**
  50464. * Mesh used as a pivot to rotate the attached mesh
  50465. */
  50466. private _anchorMesh;
  50467. private _existingMeshScale;
  50468. private _dragMesh;
  50469. private pointerDragBehavior;
  50470. private coloredMaterial;
  50471. private hoverColoredMaterial;
  50472. /**
  50473. * Sets the color of the bounding box gizmo
  50474. * @param color the color to set
  50475. */
  50476. setColor(color: Color3): void;
  50477. /**
  50478. * Creates an BoundingBoxGizmo
  50479. * @param gizmoLayer The utility layer the gizmo will be added to
  50480. * @param color The color of the gizmo
  50481. */
  50482. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50483. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50484. private _selectNode;
  50485. /**
  50486. * Updates the bounding box information for the Gizmo
  50487. */
  50488. updateBoundingBox(): void;
  50489. private _updateRotationSpheres;
  50490. private _updateScaleBoxes;
  50491. /**
  50492. * Enables rotation on the specified axis and disables rotation on the others
  50493. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50494. */
  50495. setEnabledRotationAxis(axis: string): void;
  50496. /**
  50497. * Enables/disables scaling
  50498. * @param enable if scaling should be enabled
  50499. */
  50500. setEnabledScaling(enable: boolean): void;
  50501. private _updateDummy;
  50502. /**
  50503. * Enables a pointer drag behavior on the bounding box of the gizmo
  50504. */
  50505. enableDragBehavior(): void;
  50506. /**
  50507. * Disposes of the gizmo
  50508. */
  50509. dispose(): void;
  50510. /**
  50511. * 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)
  50512. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50513. * @returns the bounding box mesh with the passed in mesh as a child
  50514. */
  50515. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50516. /**
  50517. * CustomMeshes are not supported by this gizmo
  50518. * @param mesh The mesh to replace the default mesh of the gizmo
  50519. */
  50520. setCustomMesh(mesh: Mesh): void;
  50521. }
  50522. }
  50523. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50524. import { Observable } from "babylonjs/Misc/observable";
  50525. import { Nullable } from "babylonjs/types";
  50526. import { Vector3 } from "babylonjs/Maths/math.vector";
  50527. import { Color3 } from "babylonjs/Maths/math.color";
  50528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50529. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50530. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50531. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50532. import "babylonjs/Meshes/Builders/linesBuilder";
  50533. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50534. /**
  50535. * Single plane rotation gizmo
  50536. */
  50537. export class PlaneRotationGizmo extends Gizmo {
  50538. /**
  50539. * Drag behavior responsible for the gizmos dragging interactions
  50540. */
  50541. dragBehavior: PointerDragBehavior;
  50542. private _pointerObserver;
  50543. /**
  50544. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50545. */
  50546. snapDistance: number;
  50547. /**
  50548. * Event that fires each time the gizmo snaps to a new location.
  50549. * * snapDistance is the the change in distance
  50550. */
  50551. onSnapObservable: Observable<{
  50552. snapDistance: number;
  50553. }>;
  50554. private _isEnabled;
  50555. private _parent;
  50556. /**
  50557. * Creates a PlaneRotationGizmo
  50558. * @param gizmoLayer The utility layer the gizmo will be added to
  50559. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50560. * @param color The color of the gizmo
  50561. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50562. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50563. */
  50564. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50565. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50566. /**
  50567. * If the gizmo is enabled
  50568. */
  50569. set isEnabled(value: boolean);
  50570. get isEnabled(): boolean;
  50571. /**
  50572. * Disposes of the gizmo
  50573. */
  50574. dispose(): void;
  50575. }
  50576. }
  50577. declare module "babylonjs/Gizmos/rotationGizmo" {
  50578. import { Observable } from "babylonjs/Misc/observable";
  50579. import { Nullable } from "babylonjs/types";
  50580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50581. import { Mesh } from "babylonjs/Meshes/mesh";
  50582. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50583. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50584. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50585. /**
  50586. * Gizmo that enables rotating a mesh along 3 axis
  50587. */
  50588. export class RotationGizmo extends Gizmo {
  50589. /**
  50590. * Internal gizmo used for interactions on the x axis
  50591. */
  50592. xGizmo: PlaneRotationGizmo;
  50593. /**
  50594. * Internal gizmo used for interactions on the y axis
  50595. */
  50596. yGizmo: PlaneRotationGizmo;
  50597. /**
  50598. * Internal gizmo used for interactions on the z axis
  50599. */
  50600. zGizmo: PlaneRotationGizmo;
  50601. /** Fires an event when any of it's sub gizmos are dragged */
  50602. onDragStartObservable: Observable<unknown>;
  50603. /** Fires an event when any of it's sub gizmos are released from dragging */
  50604. onDragEndObservable: Observable<unknown>;
  50605. private _meshAttached;
  50606. get attachedMesh(): Nullable<AbstractMesh>;
  50607. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50608. /**
  50609. * Creates a RotationGizmo
  50610. * @param gizmoLayer The utility layer the gizmo will be added to
  50611. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50612. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50613. */
  50614. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50615. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50616. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50617. /**
  50618. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50619. */
  50620. set snapDistance(value: number);
  50621. get snapDistance(): number;
  50622. /**
  50623. * Ratio for the scale of the gizmo (Default: 1)
  50624. */
  50625. set scaleRatio(value: number);
  50626. get scaleRatio(): number;
  50627. /**
  50628. * Disposes of the gizmo
  50629. */
  50630. dispose(): void;
  50631. /**
  50632. * CustomMeshes are not supported by this gizmo
  50633. * @param mesh The mesh to replace the default mesh of the gizmo
  50634. */
  50635. setCustomMesh(mesh: Mesh): void;
  50636. }
  50637. }
  50638. declare module "babylonjs/Gizmos/gizmoManager" {
  50639. import { Observable } from "babylonjs/Misc/observable";
  50640. import { Nullable } from "babylonjs/types";
  50641. import { Scene, IDisposable } from "babylonjs/scene";
  50642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50643. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50644. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50645. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50646. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50647. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50648. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50649. /**
  50650. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50651. */
  50652. export class GizmoManager implements IDisposable {
  50653. private scene;
  50654. /**
  50655. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50656. */
  50657. gizmos: {
  50658. positionGizmo: Nullable<PositionGizmo>;
  50659. rotationGizmo: Nullable<RotationGizmo>;
  50660. scaleGizmo: Nullable<ScaleGizmo>;
  50661. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50662. };
  50663. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50664. clearGizmoOnEmptyPointerEvent: boolean;
  50665. /** Fires an event when the manager is attached to a mesh */
  50666. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50667. private _gizmosEnabled;
  50668. private _pointerObserver;
  50669. private _attachedMesh;
  50670. private _boundingBoxColor;
  50671. private _defaultUtilityLayer;
  50672. private _defaultKeepDepthUtilityLayer;
  50673. /**
  50674. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50675. */
  50676. boundingBoxDragBehavior: SixDofDragBehavior;
  50677. /**
  50678. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50679. */
  50680. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50681. /**
  50682. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50683. */
  50684. usePointerToAttachGizmos: boolean;
  50685. /**
  50686. * Utility layer that the bounding box gizmo belongs to
  50687. */
  50688. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50689. /**
  50690. * Utility layer that all gizmos besides bounding box belong to
  50691. */
  50692. get utilityLayer(): UtilityLayerRenderer;
  50693. /**
  50694. * Instatiates a gizmo manager
  50695. * @param scene the scene to overlay the gizmos on top of
  50696. */
  50697. constructor(scene: Scene);
  50698. /**
  50699. * Attaches a set of gizmos to the specified mesh
  50700. * @param mesh The mesh the gizmo's should be attached to
  50701. */
  50702. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50703. /**
  50704. * If the position gizmo is enabled
  50705. */
  50706. set positionGizmoEnabled(value: boolean);
  50707. get positionGizmoEnabled(): boolean;
  50708. /**
  50709. * If the rotation gizmo is enabled
  50710. */
  50711. set rotationGizmoEnabled(value: boolean);
  50712. get rotationGizmoEnabled(): boolean;
  50713. /**
  50714. * If the scale gizmo is enabled
  50715. */
  50716. set scaleGizmoEnabled(value: boolean);
  50717. get scaleGizmoEnabled(): boolean;
  50718. /**
  50719. * If the boundingBox gizmo is enabled
  50720. */
  50721. set boundingBoxGizmoEnabled(value: boolean);
  50722. get boundingBoxGizmoEnabled(): boolean;
  50723. /**
  50724. * Disposes of the gizmo manager
  50725. */
  50726. dispose(): void;
  50727. }
  50728. }
  50729. declare module "babylonjs/Lights/directionalLight" {
  50730. import { Camera } from "babylonjs/Cameras/camera";
  50731. import { Scene } from "babylonjs/scene";
  50732. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50734. import { Light } from "babylonjs/Lights/light";
  50735. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50736. import { Effect } from "babylonjs/Materials/effect";
  50737. /**
  50738. * A directional light is defined by a direction (what a surprise!).
  50739. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50740. * 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.
  50741. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50742. */
  50743. export class DirectionalLight extends ShadowLight {
  50744. private _shadowFrustumSize;
  50745. /**
  50746. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50747. */
  50748. get shadowFrustumSize(): number;
  50749. /**
  50750. * Specifies a fix frustum size for the shadow generation.
  50751. */
  50752. set shadowFrustumSize(value: number);
  50753. private _shadowOrthoScale;
  50754. /**
  50755. * Gets the shadow projection scale against the optimal computed one.
  50756. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50757. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50758. */
  50759. get shadowOrthoScale(): number;
  50760. /**
  50761. * Sets the shadow projection scale against the optimal computed one.
  50762. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50763. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50764. */
  50765. set shadowOrthoScale(value: number);
  50766. /**
  50767. * Automatically compute the projection matrix to best fit (including all the casters)
  50768. * on each frame.
  50769. */
  50770. autoUpdateExtends: boolean;
  50771. /**
  50772. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50773. * on each frame. autoUpdateExtends must be set to true for this to work
  50774. */
  50775. autoCalcShadowZBounds: boolean;
  50776. private _orthoLeft;
  50777. private _orthoRight;
  50778. private _orthoTop;
  50779. private _orthoBottom;
  50780. /**
  50781. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50782. * The directional light is emitted from everywhere in the given direction.
  50783. * It can cast shadows.
  50784. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50785. * @param name The friendly name of the light
  50786. * @param direction The direction of the light
  50787. * @param scene The scene the light belongs to
  50788. */
  50789. constructor(name: string, direction: Vector3, scene: Scene);
  50790. /**
  50791. * Returns the string "DirectionalLight".
  50792. * @return The class name
  50793. */
  50794. getClassName(): string;
  50795. /**
  50796. * Returns the integer 1.
  50797. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50798. */
  50799. getTypeID(): number;
  50800. /**
  50801. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50802. * Returns the DirectionalLight Shadow projection matrix.
  50803. */
  50804. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50805. /**
  50806. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50807. * Returns the DirectionalLight Shadow projection matrix.
  50808. */
  50809. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50810. /**
  50811. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50812. * Returns the DirectionalLight Shadow projection matrix.
  50813. */
  50814. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50815. protected _buildUniformLayout(): void;
  50816. /**
  50817. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50818. * @param effect The effect to update
  50819. * @param lightIndex The index of the light in the effect to update
  50820. * @returns The directional light
  50821. */
  50822. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50823. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50824. /**
  50825. * Gets the minZ used for shadow according to both the scene and the light.
  50826. *
  50827. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50828. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50829. * @param activeCamera The camera we are returning the min for
  50830. * @returns the depth min z
  50831. */
  50832. getDepthMinZ(activeCamera: Camera): number;
  50833. /**
  50834. * Gets the maxZ used for shadow according to both the scene and the light.
  50835. *
  50836. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50837. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50838. * @param activeCamera The camera we are returning the max for
  50839. * @returns the depth max z
  50840. */
  50841. getDepthMaxZ(activeCamera: Camera): number;
  50842. /**
  50843. * Prepares the list of defines specific to the light type.
  50844. * @param defines the list of defines
  50845. * @param lightIndex defines the index of the light for the effect
  50846. */
  50847. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50848. }
  50849. }
  50850. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50851. import { Mesh } from "babylonjs/Meshes/mesh";
  50852. /**
  50853. * Class containing static functions to help procedurally build meshes
  50854. */
  50855. export class HemisphereBuilder {
  50856. /**
  50857. * Creates a hemisphere mesh
  50858. * @param name defines the name of the mesh
  50859. * @param options defines the options used to create the mesh
  50860. * @param scene defines the hosting scene
  50861. * @returns the hemisphere mesh
  50862. */
  50863. static CreateHemisphere(name: string, options: {
  50864. segments?: number;
  50865. diameter?: number;
  50866. sideOrientation?: number;
  50867. }, scene: any): Mesh;
  50868. }
  50869. }
  50870. declare module "babylonjs/Lights/spotLight" {
  50871. import { Nullable } from "babylonjs/types";
  50872. import { Scene } from "babylonjs/scene";
  50873. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50875. import { Effect } from "babylonjs/Materials/effect";
  50876. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50877. import { Light } from "babylonjs/Lights/light";
  50878. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50879. /**
  50880. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50881. * These values define a cone of light starting from the position, emitting toward the direction.
  50882. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50883. * and the exponent defines the speed of the decay of the light with distance (reach).
  50884. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50885. */
  50886. export class SpotLight extends ShadowLight {
  50887. private _angle;
  50888. private _innerAngle;
  50889. private _cosHalfAngle;
  50890. private _lightAngleScale;
  50891. private _lightAngleOffset;
  50892. /**
  50893. * Gets the cone angle of the spot light in Radians.
  50894. */
  50895. get angle(): number;
  50896. /**
  50897. * Sets the cone angle of the spot light in Radians.
  50898. */
  50899. set angle(value: number);
  50900. /**
  50901. * Only used in gltf falloff mode, this defines the angle where
  50902. * the directional falloff will start before cutting at angle which could be seen
  50903. * as outer angle.
  50904. */
  50905. get innerAngle(): number;
  50906. /**
  50907. * Only used in gltf falloff mode, this defines the angle where
  50908. * the directional falloff will start before cutting at angle which could be seen
  50909. * as outer angle.
  50910. */
  50911. set innerAngle(value: number);
  50912. private _shadowAngleScale;
  50913. /**
  50914. * Allows scaling the angle of the light for shadow generation only.
  50915. */
  50916. get shadowAngleScale(): number;
  50917. /**
  50918. * Allows scaling the angle of the light for shadow generation only.
  50919. */
  50920. set shadowAngleScale(value: number);
  50921. /**
  50922. * The light decay speed with the distance from the emission spot.
  50923. */
  50924. exponent: number;
  50925. private _projectionTextureMatrix;
  50926. /**
  50927. * Allows reading the projecton texture
  50928. */
  50929. get projectionTextureMatrix(): Matrix;
  50930. protected _projectionTextureLightNear: number;
  50931. /**
  50932. * Gets the near clip of the Spotlight for texture projection.
  50933. */
  50934. get projectionTextureLightNear(): number;
  50935. /**
  50936. * Sets the near clip of the Spotlight for texture projection.
  50937. */
  50938. set projectionTextureLightNear(value: number);
  50939. protected _projectionTextureLightFar: number;
  50940. /**
  50941. * Gets the far clip of the Spotlight for texture projection.
  50942. */
  50943. get projectionTextureLightFar(): number;
  50944. /**
  50945. * Sets the far clip of the Spotlight for texture projection.
  50946. */
  50947. set projectionTextureLightFar(value: number);
  50948. protected _projectionTextureUpDirection: Vector3;
  50949. /**
  50950. * Gets the Up vector of the Spotlight for texture projection.
  50951. */
  50952. get projectionTextureUpDirection(): Vector3;
  50953. /**
  50954. * Sets the Up vector of the Spotlight for texture projection.
  50955. */
  50956. set projectionTextureUpDirection(value: Vector3);
  50957. private _projectionTexture;
  50958. /**
  50959. * Gets the projection texture of the light.
  50960. */
  50961. get projectionTexture(): Nullable<BaseTexture>;
  50962. /**
  50963. * Sets the projection texture of the light.
  50964. */
  50965. set projectionTexture(value: Nullable<BaseTexture>);
  50966. private _projectionTextureViewLightDirty;
  50967. private _projectionTextureProjectionLightDirty;
  50968. private _projectionTextureDirty;
  50969. private _projectionTextureViewTargetVector;
  50970. private _projectionTextureViewLightMatrix;
  50971. private _projectionTextureProjectionLightMatrix;
  50972. private _projectionTextureScalingMatrix;
  50973. /**
  50974. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50975. * It can cast shadows.
  50976. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50977. * @param name The light friendly name
  50978. * @param position The position of the spot light in the scene
  50979. * @param direction The direction of the light in the scene
  50980. * @param angle The cone angle of the light in Radians
  50981. * @param exponent The light decay speed with the distance from the emission spot
  50982. * @param scene The scene the lights belongs to
  50983. */
  50984. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50985. /**
  50986. * Returns the string "SpotLight".
  50987. * @returns the class name
  50988. */
  50989. getClassName(): string;
  50990. /**
  50991. * Returns the integer 2.
  50992. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50993. */
  50994. getTypeID(): number;
  50995. /**
  50996. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50997. */
  50998. protected _setDirection(value: Vector3): void;
  50999. /**
  51000. * Overrides the position setter to recompute the projection texture view light Matrix.
  51001. */
  51002. protected _setPosition(value: Vector3): void;
  51003. /**
  51004. * 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.
  51005. * Returns the SpotLight.
  51006. */
  51007. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51008. protected _computeProjectionTextureViewLightMatrix(): void;
  51009. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51010. /**
  51011. * Main function for light texture projection matrix computing.
  51012. */
  51013. protected _computeProjectionTextureMatrix(): void;
  51014. protected _buildUniformLayout(): void;
  51015. private _computeAngleValues;
  51016. /**
  51017. * Sets the passed Effect "effect" with the Light textures.
  51018. * @param effect The effect to update
  51019. * @param lightIndex The index of the light in the effect to update
  51020. * @returns The light
  51021. */
  51022. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51023. /**
  51024. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51025. * @param effect The effect to update
  51026. * @param lightIndex The index of the light in the effect to update
  51027. * @returns The spot light
  51028. */
  51029. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51030. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51031. /**
  51032. * Disposes the light and the associated resources.
  51033. */
  51034. dispose(): void;
  51035. /**
  51036. * Prepares the list of defines specific to the light type.
  51037. * @param defines the list of defines
  51038. * @param lightIndex defines the index of the light for the effect
  51039. */
  51040. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51041. }
  51042. }
  51043. declare module "babylonjs/Gizmos/lightGizmo" {
  51044. import { Nullable } from "babylonjs/types";
  51045. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51046. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51047. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51048. import { Light } from "babylonjs/Lights/light";
  51049. /**
  51050. * Gizmo that enables viewing a light
  51051. */
  51052. export class LightGizmo extends Gizmo {
  51053. private _lightMesh;
  51054. private _material;
  51055. private _cachedPosition;
  51056. private _cachedForward;
  51057. private _attachedMeshParent;
  51058. /**
  51059. * Creates a LightGizmo
  51060. * @param gizmoLayer The utility layer the gizmo will be added to
  51061. */
  51062. constructor(gizmoLayer?: UtilityLayerRenderer);
  51063. private _light;
  51064. /**
  51065. * The light that the gizmo is attached to
  51066. */
  51067. set light(light: Nullable<Light>);
  51068. get light(): Nullable<Light>;
  51069. /**
  51070. * Gets the material used to render the light gizmo
  51071. */
  51072. get material(): StandardMaterial;
  51073. /**
  51074. * @hidden
  51075. * Updates the gizmo to match the attached mesh's position/rotation
  51076. */
  51077. protected _update(): void;
  51078. private static _Scale;
  51079. /**
  51080. * Creates the lines for a light mesh
  51081. */
  51082. private static _CreateLightLines;
  51083. /**
  51084. * Disposes of the light gizmo
  51085. */
  51086. dispose(): void;
  51087. private static _CreateHemisphericLightMesh;
  51088. private static _CreatePointLightMesh;
  51089. private static _CreateSpotLightMesh;
  51090. private static _CreateDirectionalLightMesh;
  51091. }
  51092. }
  51093. declare module "babylonjs/Gizmos/index" {
  51094. export * from "babylonjs/Gizmos/axisDragGizmo";
  51095. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51096. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51097. export * from "babylonjs/Gizmos/gizmo";
  51098. export * from "babylonjs/Gizmos/gizmoManager";
  51099. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51100. export * from "babylonjs/Gizmos/positionGizmo";
  51101. export * from "babylonjs/Gizmos/rotationGizmo";
  51102. export * from "babylonjs/Gizmos/scaleGizmo";
  51103. export * from "babylonjs/Gizmos/lightGizmo";
  51104. export * from "babylonjs/Gizmos/planeDragGizmo";
  51105. }
  51106. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51107. /** @hidden */
  51108. export var backgroundFragmentDeclaration: {
  51109. name: string;
  51110. shader: string;
  51111. };
  51112. }
  51113. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51114. /** @hidden */
  51115. export var backgroundUboDeclaration: {
  51116. name: string;
  51117. shader: string;
  51118. };
  51119. }
  51120. declare module "babylonjs/Shaders/background.fragment" {
  51121. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51122. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51123. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51124. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51125. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51126. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51127. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51128. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51129. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51130. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51131. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51132. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51133. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51134. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51135. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51136. /** @hidden */
  51137. export var backgroundPixelShader: {
  51138. name: string;
  51139. shader: string;
  51140. };
  51141. }
  51142. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51143. /** @hidden */
  51144. export var backgroundVertexDeclaration: {
  51145. name: string;
  51146. shader: string;
  51147. };
  51148. }
  51149. declare module "babylonjs/Shaders/background.vertex" {
  51150. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51151. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51152. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51153. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51154. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51155. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51156. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51157. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51158. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51159. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51160. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51161. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51162. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51163. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51164. /** @hidden */
  51165. export var backgroundVertexShader: {
  51166. name: string;
  51167. shader: string;
  51168. };
  51169. }
  51170. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51171. import { Nullable, int, float } from "babylonjs/types";
  51172. import { Scene } from "babylonjs/scene";
  51173. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51174. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51176. import { Mesh } from "babylonjs/Meshes/mesh";
  51177. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51178. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51179. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51180. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51181. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51182. import { Color3 } from "babylonjs/Maths/math.color";
  51183. import "babylonjs/Shaders/background.fragment";
  51184. import "babylonjs/Shaders/background.vertex";
  51185. /**
  51186. * Background material used to create an efficient environement around your scene.
  51187. */
  51188. export class BackgroundMaterial extends PushMaterial {
  51189. /**
  51190. * Standard reflectance value at parallel view angle.
  51191. */
  51192. static StandardReflectance0: number;
  51193. /**
  51194. * Standard reflectance value at grazing angle.
  51195. */
  51196. static StandardReflectance90: number;
  51197. protected _primaryColor: Color3;
  51198. /**
  51199. * Key light Color (multiply against the environement texture)
  51200. */
  51201. primaryColor: Color3;
  51202. protected __perceptualColor: Nullable<Color3>;
  51203. /**
  51204. * Experimental Internal Use Only.
  51205. *
  51206. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51207. * This acts as a helper to set the primary color to a more "human friendly" value.
  51208. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51209. * output color as close as possible from the chosen value.
  51210. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51211. * part of lighting setup.)
  51212. */
  51213. get _perceptualColor(): Nullable<Color3>;
  51214. set _perceptualColor(value: Nullable<Color3>);
  51215. protected _primaryColorShadowLevel: float;
  51216. /**
  51217. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51218. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51219. */
  51220. get primaryColorShadowLevel(): float;
  51221. set primaryColorShadowLevel(value: float);
  51222. protected _primaryColorHighlightLevel: float;
  51223. /**
  51224. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51225. * The primary color is used at the level chosen to define what the white area would look.
  51226. */
  51227. get primaryColorHighlightLevel(): float;
  51228. set primaryColorHighlightLevel(value: float);
  51229. protected _reflectionTexture: Nullable<BaseTexture>;
  51230. /**
  51231. * Reflection Texture used in the material.
  51232. * Should be author in a specific way for the best result (refer to the documentation).
  51233. */
  51234. reflectionTexture: Nullable<BaseTexture>;
  51235. protected _reflectionBlur: float;
  51236. /**
  51237. * Reflection Texture level of blur.
  51238. *
  51239. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51240. * texture twice.
  51241. */
  51242. reflectionBlur: float;
  51243. protected _diffuseTexture: Nullable<BaseTexture>;
  51244. /**
  51245. * Diffuse Texture used in the material.
  51246. * Should be author in a specific way for the best result (refer to the documentation).
  51247. */
  51248. diffuseTexture: Nullable<BaseTexture>;
  51249. protected _shadowLights: Nullable<IShadowLight[]>;
  51250. /**
  51251. * Specify the list of lights casting shadow on the material.
  51252. * All scene shadow lights will be included if null.
  51253. */
  51254. shadowLights: Nullable<IShadowLight[]>;
  51255. protected _shadowLevel: float;
  51256. /**
  51257. * Helps adjusting the shadow to a softer level if required.
  51258. * 0 means black shadows and 1 means no shadows.
  51259. */
  51260. shadowLevel: float;
  51261. protected _sceneCenter: Vector3;
  51262. /**
  51263. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51264. * It is usually zero but might be interesting to modify according to your setup.
  51265. */
  51266. sceneCenter: Vector3;
  51267. protected _opacityFresnel: boolean;
  51268. /**
  51269. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51270. * This helps ensuring a nice transition when the camera goes under the ground.
  51271. */
  51272. opacityFresnel: boolean;
  51273. protected _reflectionFresnel: boolean;
  51274. /**
  51275. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51276. * This helps adding a mirror texture on the ground.
  51277. */
  51278. reflectionFresnel: boolean;
  51279. protected _reflectionFalloffDistance: number;
  51280. /**
  51281. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51282. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51283. */
  51284. reflectionFalloffDistance: number;
  51285. protected _reflectionAmount: number;
  51286. /**
  51287. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51288. */
  51289. reflectionAmount: number;
  51290. protected _reflectionReflectance0: number;
  51291. /**
  51292. * This specifies the weight of the reflection at grazing angle.
  51293. */
  51294. reflectionReflectance0: number;
  51295. protected _reflectionReflectance90: number;
  51296. /**
  51297. * This specifies the weight of the reflection at a perpendicular point of view.
  51298. */
  51299. reflectionReflectance90: number;
  51300. /**
  51301. * Sets the reflection reflectance fresnel values according to the default standard
  51302. * empirically know to work well :-)
  51303. */
  51304. set reflectionStandardFresnelWeight(value: number);
  51305. protected _useRGBColor: boolean;
  51306. /**
  51307. * Helps to directly use the maps channels instead of their level.
  51308. */
  51309. useRGBColor: boolean;
  51310. protected _enableNoise: boolean;
  51311. /**
  51312. * This helps reducing the banding effect that could occur on the background.
  51313. */
  51314. enableNoise: boolean;
  51315. /**
  51316. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51317. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51318. * Recommended to be keep at 1.0 except for special cases.
  51319. */
  51320. get fovMultiplier(): number;
  51321. set fovMultiplier(value: number);
  51322. private _fovMultiplier;
  51323. /**
  51324. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51325. */
  51326. useEquirectangularFOV: boolean;
  51327. private _maxSimultaneousLights;
  51328. /**
  51329. * Number of Simultaneous lights allowed on the material.
  51330. */
  51331. maxSimultaneousLights: int;
  51332. /**
  51333. * Default configuration related to image processing available in the Background Material.
  51334. */
  51335. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51336. /**
  51337. * Keep track of the image processing observer to allow dispose and replace.
  51338. */
  51339. private _imageProcessingObserver;
  51340. /**
  51341. * Attaches a new image processing configuration to the PBR Material.
  51342. * @param configuration (if null the scene configuration will be use)
  51343. */
  51344. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51345. /**
  51346. * Gets the image processing configuration used either in this material.
  51347. */
  51348. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51349. /**
  51350. * Sets the Default image processing configuration used either in the this material.
  51351. *
  51352. * If sets to null, the scene one is in use.
  51353. */
  51354. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51355. /**
  51356. * Gets wether the color curves effect is enabled.
  51357. */
  51358. get cameraColorCurvesEnabled(): boolean;
  51359. /**
  51360. * Sets wether the color curves effect is enabled.
  51361. */
  51362. set cameraColorCurvesEnabled(value: boolean);
  51363. /**
  51364. * Gets wether the color grading effect is enabled.
  51365. */
  51366. get cameraColorGradingEnabled(): boolean;
  51367. /**
  51368. * Gets wether the color grading effect is enabled.
  51369. */
  51370. set cameraColorGradingEnabled(value: boolean);
  51371. /**
  51372. * Gets wether tonemapping is enabled or not.
  51373. */
  51374. get cameraToneMappingEnabled(): boolean;
  51375. /**
  51376. * Sets wether tonemapping is enabled or not
  51377. */
  51378. set cameraToneMappingEnabled(value: boolean);
  51379. /**
  51380. * The camera exposure used on this material.
  51381. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51382. * This corresponds to a photographic exposure.
  51383. */
  51384. get cameraExposure(): float;
  51385. /**
  51386. * The camera exposure used on this material.
  51387. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51388. * This corresponds to a photographic exposure.
  51389. */
  51390. set cameraExposure(value: float);
  51391. /**
  51392. * Gets The camera contrast used on this material.
  51393. */
  51394. get cameraContrast(): float;
  51395. /**
  51396. * Sets The camera contrast used on this material.
  51397. */
  51398. set cameraContrast(value: float);
  51399. /**
  51400. * Gets the Color Grading 2D Lookup Texture.
  51401. */
  51402. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51403. /**
  51404. * Sets the Color Grading 2D Lookup Texture.
  51405. */
  51406. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51407. /**
  51408. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51409. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51410. * 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;
  51411. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51412. */
  51413. get cameraColorCurves(): Nullable<ColorCurves>;
  51414. /**
  51415. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51416. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51417. * 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;
  51418. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51419. */
  51420. set cameraColorCurves(value: Nullable<ColorCurves>);
  51421. /**
  51422. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51423. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51424. */
  51425. switchToBGR: boolean;
  51426. private _renderTargets;
  51427. private _reflectionControls;
  51428. private _white;
  51429. private _primaryShadowColor;
  51430. private _primaryHighlightColor;
  51431. /**
  51432. * Instantiates a Background Material in the given scene
  51433. * @param name The friendly name of the material
  51434. * @param scene The scene to add the material to
  51435. */
  51436. constructor(name: string, scene: Scene);
  51437. /**
  51438. * Gets a boolean indicating that current material needs to register RTT
  51439. */
  51440. get hasRenderTargetTextures(): boolean;
  51441. /**
  51442. * The entire material has been created in order to prevent overdraw.
  51443. * @returns false
  51444. */
  51445. needAlphaTesting(): boolean;
  51446. /**
  51447. * The entire material has been created in order to prevent overdraw.
  51448. * @returns true if blending is enable
  51449. */
  51450. needAlphaBlending(): boolean;
  51451. /**
  51452. * Checks wether the material is ready to be rendered for a given mesh.
  51453. * @param mesh The mesh to render
  51454. * @param subMesh The submesh to check against
  51455. * @param useInstances Specify wether or not the material is used with instances
  51456. * @returns true if all the dependencies are ready (Textures, Effects...)
  51457. */
  51458. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51459. /**
  51460. * Compute the primary color according to the chosen perceptual color.
  51461. */
  51462. private _computePrimaryColorFromPerceptualColor;
  51463. /**
  51464. * Compute the highlights and shadow colors according to their chosen levels.
  51465. */
  51466. private _computePrimaryColors;
  51467. /**
  51468. * Build the uniform buffer used in the material.
  51469. */
  51470. buildUniformLayout(): void;
  51471. /**
  51472. * Unbind the material.
  51473. */
  51474. unbind(): void;
  51475. /**
  51476. * Bind only the world matrix to the material.
  51477. * @param world The world matrix to bind.
  51478. */
  51479. bindOnlyWorldMatrix(world: Matrix): void;
  51480. /**
  51481. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51482. * @param world The world matrix to bind.
  51483. * @param subMesh The submesh to bind for.
  51484. */
  51485. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51486. /**
  51487. * Checks to see if a texture is used in the material.
  51488. * @param texture - Base texture to use.
  51489. * @returns - Boolean specifying if a texture is used in the material.
  51490. */
  51491. hasTexture(texture: BaseTexture): boolean;
  51492. /**
  51493. * Dispose the material.
  51494. * @param forceDisposeEffect Force disposal of the associated effect.
  51495. * @param forceDisposeTextures Force disposal of the associated textures.
  51496. */
  51497. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51498. /**
  51499. * Clones the material.
  51500. * @param name The cloned name.
  51501. * @returns The cloned material.
  51502. */
  51503. clone(name: string): BackgroundMaterial;
  51504. /**
  51505. * Serializes the current material to its JSON representation.
  51506. * @returns The JSON representation.
  51507. */
  51508. serialize(): any;
  51509. /**
  51510. * Gets the class name of the material
  51511. * @returns "BackgroundMaterial"
  51512. */
  51513. getClassName(): string;
  51514. /**
  51515. * Parse a JSON input to create back a background material.
  51516. * @param source The JSON data to parse
  51517. * @param scene The scene to create the parsed material in
  51518. * @param rootUrl The root url of the assets the material depends upon
  51519. * @returns the instantiated BackgroundMaterial.
  51520. */
  51521. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51522. }
  51523. }
  51524. declare module "babylonjs/Helpers/environmentHelper" {
  51525. import { Observable } from "babylonjs/Misc/observable";
  51526. import { Nullable } from "babylonjs/types";
  51527. import { Scene } from "babylonjs/scene";
  51528. import { Vector3 } from "babylonjs/Maths/math.vector";
  51529. import { Color3 } from "babylonjs/Maths/math.color";
  51530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51531. import { Mesh } from "babylonjs/Meshes/mesh";
  51532. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51533. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51534. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51535. import "babylonjs/Meshes/Builders/planeBuilder";
  51536. import "babylonjs/Meshes/Builders/boxBuilder";
  51537. /**
  51538. * Represents the different options available during the creation of
  51539. * a Environment helper.
  51540. *
  51541. * This can control the default ground, skybox and image processing setup of your scene.
  51542. */
  51543. export interface IEnvironmentHelperOptions {
  51544. /**
  51545. * Specifies whether or not to create a ground.
  51546. * True by default.
  51547. */
  51548. createGround: boolean;
  51549. /**
  51550. * Specifies the ground size.
  51551. * 15 by default.
  51552. */
  51553. groundSize: number;
  51554. /**
  51555. * The texture used on the ground for the main color.
  51556. * Comes from the BabylonJS CDN by default.
  51557. *
  51558. * Remarks: Can be either a texture or a url.
  51559. */
  51560. groundTexture: string | BaseTexture;
  51561. /**
  51562. * The color mixed in the ground texture by default.
  51563. * BabylonJS clearColor by default.
  51564. */
  51565. groundColor: Color3;
  51566. /**
  51567. * Specifies the ground opacity.
  51568. * 1 by default.
  51569. */
  51570. groundOpacity: number;
  51571. /**
  51572. * Enables the ground to receive shadows.
  51573. * True by default.
  51574. */
  51575. enableGroundShadow: boolean;
  51576. /**
  51577. * Helps preventing the shadow to be fully black on the ground.
  51578. * 0.5 by default.
  51579. */
  51580. groundShadowLevel: number;
  51581. /**
  51582. * Creates a mirror texture attach to the ground.
  51583. * false by default.
  51584. */
  51585. enableGroundMirror: boolean;
  51586. /**
  51587. * Specifies the ground mirror size ratio.
  51588. * 0.3 by default as the default kernel is 64.
  51589. */
  51590. groundMirrorSizeRatio: number;
  51591. /**
  51592. * Specifies the ground mirror blur kernel size.
  51593. * 64 by default.
  51594. */
  51595. groundMirrorBlurKernel: number;
  51596. /**
  51597. * Specifies the ground mirror visibility amount.
  51598. * 1 by default
  51599. */
  51600. groundMirrorAmount: number;
  51601. /**
  51602. * Specifies the ground mirror reflectance weight.
  51603. * This uses the standard weight of the background material to setup the fresnel effect
  51604. * of the mirror.
  51605. * 1 by default.
  51606. */
  51607. groundMirrorFresnelWeight: number;
  51608. /**
  51609. * Specifies the ground mirror Falloff distance.
  51610. * This can helps reducing the size of the reflection.
  51611. * 0 by Default.
  51612. */
  51613. groundMirrorFallOffDistance: number;
  51614. /**
  51615. * Specifies the ground mirror texture type.
  51616. * Unsigned Int by Default.
  51617. */
  51618. groundMirrorTextureType: number;
  51619. /**
  51620. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51621. * the shown objects.
  51622. */
  51623. groundYBias: number;
  51624. /**
  51625. * Specifies whether or not to create a skybox.
  51626. * True by default.
  51627. */
  51628. createSkybox: boolean;
  51629. /**
  51630. * Specifies the skybox size.
  51631. * 20 by default.
  51632. */
  51633. skyboxSize: number;
  51634. /**
  51635. * The texture used on the skybox for the main color.
  51636. * Comes from the BabylonJS CDN by default.
  51637. *
  51638. * Remarks: Can be either a texture or a url.
  51639. */
  51640. skyboxTexture: string | BaseTexture;
  51641. /**
  51642. * The color mixed in the skybox texture by default.
  51643. * BabylonJS clearColor by default.
  51644. */
  51645. skyboxColor: Color3;
  51646. /**
  51647. * The background rotation around the Y axis of the scene.
  51648. * This helps aligning the key lights of your scene with the background.
  51649. * 0 by default.
  51650. */
  51651. backgroundYRotation: number;
  51652. /**
  51653. * Compute automatically the size of the elements to best fit with the scene.
  51654. */
  51655. sizeAuto: boolean;
  51656. /**
  51657. * Default position of the rootMesh if autoSize is not true.
  51658. */
  51659. rootPosition: Vector3;
  51660. /**
  51661. * Sets up the image processing in the scene.
  51662. * true by default.
  51663. */
  51664. setupImageProcessing: boolean;
  51665. /**
  51666. * The texture used as your environment texture in the scene.
  51667. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51668. *
  51669. * Remarks: Can be either a texture or a url.
  51670. */
  51671. environmentTexture: string | BaseTexture;
  51672. /**
  51673. * The value of the exposure to apply to the scene.
  51674. * 0.6 by default if setupImageProcessing is true.
  51675. */
  51676. cameraExposure: number;
  51677. /**
  51678. * The value of the contrast to apply to the scene.
  51679. * 1.6 by default if setupImageProcessing is true.
  51680. */
  51681. cameraContrast: number;
  51682. /**
  51683. * Specifies whether or not tonemapping should be enabled in the scene.
  51684. * true by default if setupImageProcessing is true.
  51685. */
  51686. toneMappingEnabled: boolean;
  51687. }
  51688. /**
  51689. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51690. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51691. * It also helps with the default setup of your imageProcessing configuration.
  51692. */
  51693. export class EnvironmentHelper {
  51694. /**
  51695. * Default ground texture URL.
  51696. */
  51697. private static _groundTextureCDNUrl;
  51698. /**
  51699. * Default skybox texture URL.
  51700. */
  51701. private static _skyboxTextureCDNUrl;
  51702. /**
  51703. * Default environment texture URL.
  51704. */
  51705. private static _environmentTextureCDNUrl;
  51706. /**
  51707. * Creates the default options for the helper.
  51708. */
  51709. private static _getDefaultOptions;
  51710. private _rootMesh;
  51711. /**
  51712. * Gets the root mesh created by the helper.
  51713. */
  51714. get rootMesh(): Mesh;
  51715. private _skybox;
  51716. /**
  51717. * Gets the skybox created by the helper.
  51718. */
  51719. get skybox(): Nullable<Mesh>;
  51720. private _skyboxTexture;
  51721. /**
  51722. * Gets the skybox texture created by the helper.
  51723. */
  51724. get skyboxTexture(): Nullable<BaseTexture>;
  51725. private _skyboxMaterial;
  51726. /**
  51727. * Gets the skybox material created by the helper.
  51728. */
  51729. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51730. private _ground;
  51731. /**
  51732. * Gets the ground mesh created by the helper.
  51733. */
  51734. get ground(): Nullable<Mesh>;
  51735. private _groundTexture;
  51736. /**
  51737. * Gets the ground texture created by the helper.
  51738. */
  51739. get groundTexture(): Nullable<BaseTexture>;
  51740. private _groundMirror;
  51741. /**
  51742. * Gets the ground mirror created by the helper.
  51743. */
  51744. get groundMirror(): Nullable<MirrorTexture>;
  51745. /**
  51746. * Gets the ground mirror render list to helps pushing the meshes
  51747. * you wish in the ground reflection.
  51748. */
  51749. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51750. private _groundMaterial;
  51751. /**
  51752. * Gets the ground material created by the helper.
  51753. */
  51754. get groundMaterial(): Nullable<BackgroundMaterial>;
  51755. /**
  51756. * Stores the creation options.
  51757. */
  51758. private readonly _scene;
  51759. private _options;
  51760. /**
  51761. * This observable will be notified with any error during the creation of the environment,
  51762. * mainly texture creation errors.
  51763. */
  51764. onErrorObservable: Observable<{
  51765. message?: string;
  51766. exception?: any;
  51767. }>;
  51768. /**
  51769. * constructor
  51770. * @param options Defines the options we want to customize the helper
  51771. * @param scene The scene to add the material to
  51772. */
  51773. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51774. /**
  51775. * Updates the background according to the new options
  51776. * @param options
  51777. */
  51778. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51779. /**
  51780. * Sets the primary color of all the available elements.
  51781. * @param color the main color to affect to the ground and the background
  51782. */
  51783. setMainColor(color: Color3): void;
  51784. /**
  51785. * Setup the image processing according to the specified options.
  51786. */
  51787. private _setupImageProcessing;
  51788. /**
  51789. * Setup the environment texture according to the specified options.
  51790. */
  51791. private _setupEnvironmentTexture;
  51792. /**
  51793. * Setup the background according to the specified options.
  51794. */
  51795. private _setupBackground;
  51796. /**
  51797. * Get the scene sizes according to the setup.
  51798. */
  51799. private _getSceneSize;
  51800. /**
  51801. * Setup the ground according to the specified options.
  51802. */
  51803. private _setupGround;
  51804. /**
  51805. * Setup the ground material according to the specified options.
  51806. */
  51807. private _setupGroundMaterial;
  51808. /**
  51809. * Setup the ground diffuse texture according to the specified options.
  51810. */
  51811. private _setupGroundDiffuseTexture;
  51812. /**
  51813. * Setup the ground mirror texture according to the specified options.
  51814. */
  51815. private _setupGroundMirrorTexture;
  51816. /**
  51817. * Setup the ground to receive the mirror texture.
  51818. */
  51819. private _setupMirrorInGroundMaterial;
  51820. /**
  51821. * Setup the skybox according to the specified options.
  51822. */
  51823. private _setupSkybox;
  51824. /**
  51825. * Setup the skybox material according to the specified options.
  51826. */
  51827. private _setupSkyboxMaterial;
  51828. /**
  51829. * Setup the skybox reflection texture according to the specified options.
  51830. */
  51831. private _setupSkyboxReflectionTexture;
  51832. private _errorHandler;
  51833. /**
  51834. * Dispose all the elements created by the Helper.
  51835. */
  51836. dispose(): void;
  51837. }
  51838. }
  51839. declare module "babylonjs/Helpers/photoDome" {
  51840. import { Observable } from "babylonjs/Misc/observable";
  51841. import { Nullable } from "babylonjs/types";
  51842. import { Scene } from "babylonjs/scene";
  51843. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51844. import { Mesh } from "babylonjs/Meshes/mesh";
  51845. import { Texture } from "babylonjs/Materials/Textures/texture";
  51846. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51847. import "babylonjs/Meshes/Builders/sphereBuilder";
  51848. /**
  51849. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51850. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51851. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51852. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51853. */
  51854. export class PhotoDome extends TransformNode {
  51855. /**
  51856. * Define the image as a Monoscopic panoramic 360 image.
  51857. */
  51858. static readonly MODE_MONOSCOPIC: number;
  51859. /**
  51860. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51861. */
  51862. static readonly MODE_TOPBOTTOM: number;
  51863. /**
  51864. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51865. */
  51866. static readonly MODE_SIDEBYSIDE: number;
  51867. private _useDirectMapping;
  51868. /**
  51869. * The texture being displayed on the sphere
  51870. */
  51871. protected _photoTexture: Texture;
  51872. /**
  51873. * Gets or sets the texture being displayed on the sphere
  51874. */
  51875. get photoTexture(): Texture;
  51876. set photoTexture(value: Texture);
  51877. /**
  51878. * Observable raised when an error occured while loading the 360 image
  51879. */
  51880. onLoadErrorObservable: Observable<string>;
  51881. /**
  51882. * The skybox material
  51883. */
  51884. protected _material: BackgroundMaterial;
  51885. /**
  51886. * The surface used for the skybox
  51887. */
  51888. protected _mesh: Mesh;
  51889. /**
  51890. * Gets the mesh used for the skybox.
  51891. */
  51892. get mesh(): Mesh;
  51893. /**
  51894. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51895. * Also see the options.resolution property.
  51896. */
  51897. get fovMultiplier(): number;
  51898. set fovMultiplier(value: number);
  51899. private _imageMode;
  51900. /**
  51901. * Gets or set the current video mode for the video. It can be:
  51902. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51903. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51904. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51905. */
  51906. get imageMode(): number;
  51907. set imageMode(value: number);
  51908. /**
  51909. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51910. * @param name Element's name, child elements will append suffixes for their own names.
  51911. * @param urlsOfPhoto defines the url of the photo to display
  51912. * @param options defines an object containing optional or exposed sub element properties
  51913. * @param onError defines a callback called when an error occured while loading the texture
  51914. */
  51915. constructor(name: string, urlOfPhoto: string, options: {
  51916. resolution?: number;
  51917. size?: number;
  51918. useDirectMapping?: boolean;
  51919. faceForward?: boolean;
  51920. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51921. private _onBeforeCameraRenderObserver;
  51922. private _changeImageMode;
  51923. /**
  51924. * Releases resources associated with this node.
  51925. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51926. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51927. */
  51928. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51929. }
  51930. }
  51931. declare module "babylonjs/Misc/rgbdTextureTools" {
  51932. import "babylonjs/Shaders/rgbdDecode.fragment";
  51933. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51934. import { Texture } from "babylonjs/Materials/Textures/texture";
  51935. /**
  51936. * Class used to host RGBD texture specific utilities
  51937. */
  51938. export class RGBDTextureTools {
  51939. /**
  51940. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51941. * @param texture the texture to expand.
  51942. */
  51943. static ExpandRGBDTexture(texture: Texture): void;
  51944. }
  51945. }
  51946. declare module "babylonjs/Misc/brdfTextureTools" {
  51947. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51948. import { Scene } from "babylonjs/scene";
  51949. /**
  51950. * Class used to host texture specific utilities
  51951. */
  51952. export class BRDFTextureTools {
  51953. /**
  51954. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51955. * @param scene defines the hosting scene
  51956. * @returns the environment BRDF texture
  51957. */
  51958. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51959. private static _environmentBRDFBase64Texture;
  51960. }
  51961. }
  51962. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51963. import { Nullable } from "babylonjs/types";
  51964. import { Color3 } from "babylonjs/Maths/math.color";
  51965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51966. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51967. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51968. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51969. import { Engine } from "babylonjs/Engines/engine";
  51970. import { Scene } from "babylonjs/scene";
  51971. /**
  51972. * @hidden
  51973. */
  51974. export interface IMaterialClearCoatDefines {
  51975. CLEARCOAT: boolean;
  51976. CLEARCOAT_DEFAULTIOR: boolean;
  51977. CLEARCOAT_TEXTURE: boolean;
  51978. CLEARCOAT_TEXTUREDIRECTUV: number;
  51979. CLEARCOAT_BUMP: boolean;
  51980. CLEARCOAT_BUMPDIRECTUV: number;
  51981. CLEARCOAT_TINT: boolean;
  51982. CLEARCOAT_TINT_TEXTURE: boolean;
  51983. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51984. /** @hidden */
  51985. _areTexturesDirty: boolean;
  51986. }
  51987. /**
  51988. * Define the code related to the clear coat parameters of the pbr material.
  51989. */
  51990. export class PBRClearCoatConfiguration {
  51991. /**
  51992. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51993. * The default fits with a polyurethane material.
  51994. */
  51995. private static readonly _DefaultIndexOfRefraction;
  51996. private _isEnabled;
  51997. /**
  51998. * Defines if the clear coat is enabled in the material.
  51999. */
  52000. isEnabled: boolean;
  52001. /**
  52002. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52003. */
  52004. intensity: number;
  52005. /**
  52006. * Defines the clear coat layer roughness.
  52007. */
  52008. roughness: number;
  52009. private _indexOfRefraction;
  52010. /**
  52011. * Defines the index of refraction of the clear coat.
  52012. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52013. * The default fits with a polyurethane material.
  52014. * Changing the default value is more performance intensive.
  52015. */
  52016. indexOfRefraction: number;
  52017. private _texture;
  52018. /**
  52019. * Stores the clear coat values in a texture.
  52020. */
  52021. texture: Nullable<BaseTexture>;
  52022. private _bumpTexture;
  52023. /**
  52024. * Define the clear coat specific bump texture.
  52025. */
  52026. bumpTexture: Nullable<BaseTexture>;
  52027. private _isTintEnabled;
  52028. /**
  52029. * Defines if the clear coat tint is enabled in the material.
  52030. */
  52031. isTintEnabled: boolean;
  52032. /**
  52033. * Defines the clear coat tint of the material.
  52034. * This is only use if tint is enabled
  52035. */
  52036. tintColor: Color3;
  52037. /**
  52038. * Defines the distance at which the tint color should be found in the
  52039. * clear coat media.
  52040. * This is only use if tint is enabled
  52041. */
  52042. tintColorAtDistance: number;
  52043. /**
  52044. * Defines the clear coat layer thickness.
  52045. * This is only use if tint is enabled
  52046. */
  52047. tintThickness: number;
  52048. private _tintTexture;
  52049. /**
  52050. * Stores the clear tint values in a texture.
  52051. * rgb is tint
  52052. * a is a thickness factor
  52053. */
  52054. tintTexture: Nullable<BaseTexture>;
  52055. /** @hidden */
  52056. private _internalMarkAllSubMeshesAsTexturesDirty;
  52057. /** @hidden */
  52058. _markAllSubMeshesAsTexturesDirty(): void;
  52059. /**
  52060. * Instantiate a new istance of clear coat configuration.
  52061. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52062. */
  52063. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52064. /**
  52065. * Gets wehter the submesh is ready to be used or not.
  52066. * @param defines the list of "defines" to update.
  52067. * @param scene defines the scene the material belongs to.
  52068. * @param engine defines the engine the material belongs to.
  52069. * @param disableBumpMap defines wether the material disables bump or not.
  52070. * @returns - boolean indicating that the submesh is ready or not.
  52071. */
  52072. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52073. /**
  52074. * Checks to see if a texture is used in the material.
  52075. * @param defines the list of "defines" to update.
  52076. * @param scene defines the scene to the material belongs to.
  52077. */
  52078. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52079. /**
  52080. * Binds the material data.
  52081. * @param uniformBuffer defines the Uniform buffer to fill in.
  52082. * @param scene defines the scene the material belongs to.
  52083. * @param engine defines the engine the material belongs to.
  52084. * @param disableBumpMap defines wether the material disables bump or not.
  52085. * @param isFrozen defines wether the material is frozen or not.
  52086. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52087. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52088. */
  52089. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52090. /**
  52091. * Checks to see if a texture is used in the material.
  52092. * @param texture - Base texture to use.
  52093. * @returns - Boolean specifying if a texture is used in the material.
  52094. */
  52095. hasTexture(texture: BaseTexture): boolean;
  52096. /**
  52097. * Returns an array of the actively used textures.
  52098. * @param activeTextures Array of BaseTextures
  52099. */
  52100. getActiveTextures(activeTextures: BaseTexture[]): void;
  52101. /**
  52102. * Returns the animatable textures.
  52103. * @param animatables Array of animatable textures.
  52104. */
  52105. getAnimatables(animatables: IAnimatable[]): void;
  52106. /**
  52107. * Disposes the resources of the material.
  52108. * @param forceDisposeTextures - Forces the disposal of all textures.
  52109. */
  52110. dispose(forceDisposeTextures?: boolean): void;
  52111. /**
  52112. * Get the current class name of the texture useful for serialization or dynamic coding.
  52113. * @returns "PBRClearCoatConfiguration"
  52114. */
  52115. getClassName(): string;
  52116. /**
  52117. * Add fallbacks to the effect fallbacks list.
  52118. * @param defines defines the Base texture to use.
  52119. * @param fallbacks defines the current fallback list.
  52120. * @param currentRank defines the current fallback rank.
  52121. * @returns the new fallback rank.
  52122. */
  52123. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52124. /**
  52125. * Add the required uniforms to the current list.
  52126. * @param uniforms defines the current uniform list.
  52127. */
  52128. static AddUniforms(uniforms: string[]): void;
  52129. /**
  52130. * Add the required samplers to the current list.
  52131. * @param samplers defines the current sampler list.
  52132. */
  52133. static AddSamplers(samplers: string[]): void;
  52134. /**
  52135. * Add the required uniforms to the current buffer.
  52136. * @param uniformBuffer defines the current uniform buffer.
  52137. */
  52138. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52139. /**
  52140. * Makes a duplicate of the current configuration into another one.
  52141. * @param clearCoatConfiguration define the config where to copy the info
  52142. */
  52143. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52144. /**
  52145. * Serializes this clear coat configuration.
  52146. * @returns - An object with the serialized config.
  52147. */
  52148. serialize(): any;
  52149. /**
  52150. * Parses a anisotropy Configuration from a serialized object.
  52151. * @param source - Serialized object.
  52152. * @param scene Defines the scene we are parsing for
  52153. * @param rootUrl Defines the rootUrl to load from
  52154. */
  52155. parse(source: any, scene: Scene, rootUrl: string): void;
  52156. }
  52157. }
  52158. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52159. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52161. import { Vector2 } from "babylonjs/Maths/math.vector";
  52162. import { Scene } from "babylonjs/scene";
  52163. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52164. import { Nullable } from "babylonjs/types";
  52165. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52166. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52167. /**
  52168. * @hidden
  52169. */
  52170. export interface IMaterialAnisotropicDefines {
  52171. ANISOTROPIC: boolean;
  52172. ANISOTROPIC_TEXTURE: boolean;
  52173. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52174. MAINUV1: boolean;
  52175. _areTexturesDirty: boolean;
  52176. _needUVs: boolean;
  52177. }
  52178. /**
  52179. * Define the code related to the anisotropic parameters of the pbr material.
  52180. */
  52181. export class PBRAnisotropicConfiguration {
  52182. private _isEnabled;
  52183. /**
  52184. * Defines if the anisotropy is enabled in the material.
  52185. */
  52186. isEnabled: boolean;
  52187. /**
  52188. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52189. */
  52190. intensity: number;
  52191. /**
  52192. * Defines if the effect is along the tangents, bitangents or in between.
  52193. * By default, the effect is "strectching" the highlights along the tangents.
  52194. */
  52195. direction: Vector2;
  52196. private _texture;
  52197. /**
  52198. * Stores the anisotropy values in a texture.
  52199. * rg is direction (like normal from -1 to 1)
  52200. * b is a intensity
  52201. */
  52202. texture: Nullable<BaseTexture>;
  52203. /** @hidden */
  52204. private _internalMarkAllSubMeshesAsTexturesDirty;
  52205. /** @hidden */
  52206. _markAllSubMeshesAsTexturesDirty(): void;
  52207. /**
  52208. * Instantiate a new istance of anisotropy configuration.
  52209. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52210. */
  52211. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52212. /**
  52213. * Specifies that the submesh is ready to be used.
  52214. * @param defines the list of "defines" to update.
  52215. * @param scene defines the scene the material belongs to.
  52216. * @returns - boolean indicating that the submesh is ready or not.
  52217. */
  52218. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52219. /**
  52220. * Checks to see if a texture is used in the material.
  52221. * @param defines the list of "defines" to update.
  52222. * @param mesh the mesh we are preparing the defines for.
  52223. * @param scene defines the scene the material belongs to.
  52224. */
  52225. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52226. /**
  52227. * Binds the material data.
  52228. * @param uniformBuffer defines the Uniform buffer to fill in.
  52229. * @param scene defines the scene the material belongs to.
  52230. * @param isFrozen defines wether the material is frozen or not.
  52231. */
  52232. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52233. /**
  52234. * Checks to see if a texture is used in the material.
  52235. * @param texture - Base texture to use.
  52236. * @returns - Boolean specifying if a texture is used in the material.
  52237. */
  52238. hasTexture(texture: BaseTexture): boolean;
  52239. /**
  52240. * Returns an array of the actively used textures.
  52241. * @param activeTextures Array of BaseTextures
  52242. */
  52243. getActiveTextures(activeTextures: BaseTexture[]): void;
  52244. /**
  52245. * Returns the animatable textures.
  52246. * @param animatables Array of animatable textures.
  52247. */
  52248. getAnimatables(animatables: IAnimatable[]): void;
  52249. /**
  52250. * Disposes the resources of the material.
  52251. * @param forceDisposeTextures - Forces the disposal of all textures.
  52252. */
  52253. dispose(forceDisposeTextures?: boolean): void;
  52254. /**
  52255. * Get the current class name of the texture useful for serialization or dynamic coding.
  52256. * @returns "PBRAnisotropicConfiguration"
  52257. */
  52258. getClassName(): string;
  52259. /**
  52260. * Add fallbacks to the effect fallbacks list.
  52261. * @param defines defines the Base texture to use.
  52262. * @param fallbacks defines the current fallback list.
  52263. * @param currentRank defines the current fallback rank.
  52264. * @returns the new fallback rank.
  52265. */
  52266. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52267. /**
  52268. * Add the required uniforms to the current list.
  52269. * @param uniforms defines the current uniform list.
  52270. */
  52271. static AddUniforms(uniforms: string[]): void;
  52272. /**
  52273. * Add the required uniforms to the current buffer.
  52274. * @param uniformBuffer defines the current uniform buffer.
  52275. */
  52276. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52277. /**
  52278. * Add the required samplers to the current list.
  52279. * @param samplers defines the current sampler list.
  52280. */
  52281. static AddSamplers(samplers: string[]): void;
  52282. /**
  52283. * Makes a duplicate of the current configuration into another one.
  52284. * @param anisotropicConfiguration define the config where to copy the info
  52285. */
  52286. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52287. /**
  52288. * Serializes this anisotropy configuration.
  52289. * @returns - An object with the serialized config.
  52290. */
  52291. serialize(): any;
  52292. /**
  52293. * Parses a anisotropy Configuration from a serialized object.
  52294. * @param source - Serialized object.
  52295. * @param scene Defines the scene we are parsing for
  52296. * @param rootUrl Defines the rootUrl to load from
  52297. */
  52298. parse(source: any, scene: Scene, rootUrl: string): void;
  52299. }
  52300. }
  52301. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52302. import { Scene } from "babylonjs/scene";
  52303. /**
  52304. * @hidden
  52305. */
  52306. export interface IMaterialBRDFDefines {
  52307. BRDF_V_HEIGHT_CORRELATED: boolean;
  52308. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52309. SPHERICAL_HARMONICS: boolean;
  52310. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52311. /** @hidden */
  52312. _areMiscDirty: boolean;
  52313. }
  52314. /**
  52315. * Define the code related to the BRDF parameters of the pbr material.
  52316. */
  52317. export class PBRBRDFConfiguration {
  52318. /**
  52319. * Default value used for the energy conservation.
  52320. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52321. */
  52322. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52323. /**
  52324. * Default value used for the Smith Visibility Height Correlated mode.
  52325. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52326. */
  52327. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52328. /**
  52329. * Default value used for the IBL diffuse part.
  52330. * This can help switching back to the polynomials mode globally which is a tiny bit
  52331. * less GPU intensive at the drawback of a lower quality.
  52332. */
  52333. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52334. /**
  52335. * Default value used for activating energy conservation for the specular workflow.
  52336. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52337. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52338. */
  52339. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52340. private _useEnergyConservation;
  52341. /**
  52342. * Defines if the material uses energy conservation.
  52343. */
  52344. useEnergyConservation: boolean;
  52345. private _useSmithVisibilityHeightCorrelated;
  52346. /**
  52347. * LEGACY Mode set to false
  52348. * Defines if the material uses height smith correlated visibility term.
  52349. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52350. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52351. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52352. * Not relying on height correlated will also disable energy conservation.
  52353. */
  52354. useSmithVisibilityHeightCorrelated: boolean;
  52355. private _useSphericalHarmonics;
  52356. /**
  52357. * LEGACY Mode set to false
  52358. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52359. * diffuse part of the IBL.
  52360. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52361. * to the ground truth.
  52362. */
  52363. useSphericalHarmonics: boolean;
  52364. private _useSpecularGlossinessInputEnergyConservation;
  52365. /**
  52366. * Defines if the material uses energy conservation, when the specular workflow is active.
  52367. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52368. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52369. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52370. */
  52371. useSpecularGlossinessInputEnergyConservation: boolean;
  52372. /** @hidden */
  52373. private _internalMarkAllSubMeshesAsMiscDirty;
  52374. /** @hidden */
  52375. _markAllSubMeshesAsMiscDirty(): void;
  52376. /**
  52377. * Instantiate a new istance of clear coat configuration.
  52378. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52379. */
  52380. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52381. /**
  52382. * Checks to see if a texture is used in the material.
  52383. * @param defines the list of "defines" to update.
  52384. */
  52385. prepareDefines(defines: IMaterialBRDFDefines): void;
  52386. /**
  52387. * Get the current class name of the texture useful for serialization or dynamic coding.
  52388. * @returns "PBRClearCoatConfiguration"
  52389. */
  52390. getClassName(): string;
  52391. /**
  52392. * Makes a duplicate of the current configuration into another one.
  52393. * @param brdfConfiguration define the config where to copy the info
  52394. */
  52395. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52396. /**
  52397. * Serializes this BRDF configuration.
  52398. * @returns - An object with the serialized config.
  52399. */
  52400. serialize(): any;
  52401. /**
  52402. * Parses a anisotropy Configuration from a serialized object.
  52403. * @param source - Serialized object.
  52404. * @param scene Defines the scene we are parsing for
  52405. * @param rootUrl Defines the rootUrl to load from
  52406. */
  52407. parse(source: any, scene: Scene, rootUrl: string): void;
  52408. }
  52409. }
  52410. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52411. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52412. import { Color3 } from "babylonjs/Maths/math.color";
  52413. import { Scene } from "babylonjs/scene";
  52414. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52415. import { Nullable } from "babylonjs/types";
  52416. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52417. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52418. /**
  52419. * @hidden
  52420. */
  52421. export interface IMaterialSheenDefines {
  52422. SHEEN: boolean;
  52423. SHEEN_TEXTURE: boolean;
  52424. SHEEN_TEXTUREDIRECTUV: number;
  52425. SHEEN_LINKWITHALBEDO: boolean;
  52426. /** @hidden */
  52427. _areTexturesDirty: boolean;
  52428. }
  52429. /**
  52430. * Define the code related to the Sheen parameters of the pbr material.
  52431. */
  52432. export class PBRSheenConfiguration {
  52433. private _isEnabled;
  52434. /**
  52435. * Defines if the material uses sheen.
  52436. */
  52437. isEnabled: boolean;
  52438. private _linkSheenWithAlbedo;
  52439. /**
  52440. * Defines if the sheen is linked to the sheen color.
  52441. */
  52442. linkSheenWithAlbedo: boolean;
  52443. /**
  52444. * Defines the sheen intensity.
  52445. */
  52446. intensity: number;
  52447. /**
  52448. * Defines the sheen color.
  52449. */
  52450. color: Color3;
  52451. private _texture;
  52452. /**
  52453. * Stores the sheen tint values in a texture.
  52454. * rgb is tint
  52455. * a is a intensity
  52456. */
  52457. texture: Nullable<BaseTexture>;
  52458. /** @hidden */
  52459. private _internalMarkAllSubMeshesAsTexturesDirty;
  52460. /** @hidden */
  52461. _markAllSubMeshesAsTexturesDirty(): void;
  52462. /**
  52463. * Instantiate a new istance of clear coat configuration.
  52464. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52465. */
  52466. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52467. /**
  52468. * Specifies that the submesh is ready to be used.
  52469. * @param defines the list of "defines" to update.
  52470. * @param scene defines the scene the material belongs to.
  52471. * @returns - boolean indicating that the submesh is ready or not.
  52472. */
  52473. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52474. /**
  52475. * Checks to see if a texture is used in the material.
  52476. * @param defines the list of "defines" to update.
  52477. * @param scene defines the scene the material belongs to.
  52478. */
  52479. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52480. /**
  52481. * Binds the material data.
  52482. * @param uniformBuffer defines the Uniform buffer to fill in.
  52483. * @param scene defines the scene the material belongs to.
  52484. * @param isFrozen defines wether the material is frozen or not.
  52485. */
  52486. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52487. /**
  52488. * Checks to see if a texture is used in the material.
  52489. * @param texture - Base texture to use.
  52490. * @returns - Boolean specifying if a texture is used in the material.
  52491. */
  52492. hasTexture(texture: BaseTexture): boolean;
  52493. /**
  52494. * Returns an array of the actively used textures.
  52495. * @param activeTextures Array of BaseTextures
  52496. */
  52497. getActiveTextures(activeTextures: BaseTexture[]): void;
  52498. /**
  52499. * Returns the animatable textures.
  52500. * @param animatables Array of animatable textures.
  52501. */
  52502. getAnimatables(animatables: IAnimatable[]): void;
  52503. /**
  52504. * Disposes the resources of the material.
  52505. * @param forceDisposeTextures - Forces the disposal of all textures.
  52506. */
  52507. dispose(forceDisposeTextures?: boolean): void;
  52508. /**
  52509. * Get the current class name of the texture useful for serialization or dynamic coding.
  52510. * @returns "PBRSheenConfiguration"
  52511. */
  52512. getClassName(): string;
  52513. /**
  52514. * Add fallbacks to the effect fallbacks list.
  52515. * @param defines defines the Base texture to use.
  52516. * @param fallbacks defines the current fallback list.
  52517. * @param currentRank defines the current fallback rank.
  52518. * @returns the new fallback rank.
  52519. */
  52520. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52521. /**
  52522. * Add the required uniforms to the current list.
  52523. * @param uniforms defines the current uniform list.
  52524. */
  52525. static AddUniforms(uniforms: string[]): void;
  52526. /**
  52527. * Add the required uniforms to the current buffer.
  52528. * @param uniformBuffer defines the current uniform buffer.
  52529. */
  52530. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52531. /**
  52532. * Add the required samplers to the current list.
  52533. * @param samplers defines the current sampler list.
  52534. */
  52535. static AddSamplers(samplers: string[]): void;
  52536. /**
  52537. * Makes a duplicate of the current configuration into another one.
  52538. * @param sheenConfiguration define the config where to copy the info
  52539. */
  52540. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52541. /**
  52542. * Serializes this BRDF configuration.
  52543. * @returns - An object with the serialized config.
  52544. */
  52545. serialize(): any;
  52546. /**
  52547. * Parses a anisotropy Configuration from a serialized object.
  52548. * @param source - Serialized object.
  52549. * @param scene Defines the scene we are parsing for
  52550. * @param rootUrl Defines the rootUrl to load from
  52551. */
  52552. parse(source: any, scene: Scene, rootUrl: string): void;
  52553. }
  52554. }
  52555. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52556. import { Nullable } from "babylonjs/types";
  52557. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52558. import { Color3 } from "babylonjs/Maths/math.color";
  52559. import { SmartArray } from "babylonjs/Misc/smartArray";
  52560. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52561. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52562. import { Effect } from "babylonjs/Materials/effect";
  52563. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52564. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52565. import { Engine } from "babylonjs/Engines/engine";
  52566. import { Scene } from "babylonjs/scene";
  52567. /**
  52568. * @hidden
  52569. */
  52570. export interface IMaterialSubSurfaceDefines {
  52571. SUBSURFACE: boolean;
  52572. SS_REFRACTION: boolean;
  52573. SS_TRANSLUCENCY: boolean;
  52574. SS_SCATERRING: boolean;
  52575. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52576. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52577. SS_REFRACTIONMAP_3D: boolean;
  52578. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52579. SS_LODINREFRACTIONALPHA: boolean;
  52580. SS_GAMMAREFRACTION: boolean;
  52581. SS_RGBDREFRACTION: boolean;
  52582. SS_LINEARSPECULARREFRACTION: boolean;
  52583. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52584. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52585. /** @hidden */
  52586. _areTexturesDirty: boolean;
  52587. }
  52588. /**
  52589. * Define the code related to the sub surface parameters of the pbr material.
  52590. */
  52591. export class PBRSubSurfaceConfiguration {
  52592. private _isRefractionEnabled;
  52593. /**
  52594. * Defines if the refraction is enabled in the material.
  52595. */
  52596. isRefractionEnabled: boolean;
  52597. private _isTranslucencyEnabled;
  52598. /**
  52599. * Defines if the translucency is enabled in the material.
  52600. */
  52601. isTranslucencyEnabled: boolean;
  52602. private _isScatteringEnabled;
  52603. /**
  52604. * Defines the refraction intensity of the material.
  52605. * The refraction when enabled replaces the Diffuse part of the material.
  52606. * The intensity helps transitionning between diffuse and refraction.
  52607. */
  52608. refractionIntensity: number;
  52609. /**
  52610. * Defines the translucency intensity of the material.
  52611. * When translucency has been enabled, this defines how much of the "translucency"
  52612. * is addded to the diffuse part of the material.
  52613. */
  52614. translucencyIntensity: number;
  52615. /**
  52616. * Defines the scattering intensity of the material.
  52617. * When scattering has been enabled, this defines how much of the "scattered light"
  52618. * is addded to the diffuse part of the material.
  52619. */
  52620. scatteringIntensity: number;
  52621. private _thicknessTexture;
  52622. /**
  52623. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52624. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52625. * 0 would mean minimumThickness
  52626. * 1 would mean maximumThickness
  52627. * The other channels might be use as a mask to vary the different effects intensity.
  52628. */
  52629. thicknessTexture: Nullable<BaseTexture>;
  52630. private _refractionTexture;
  52631. /**
  52632. * Defines the texture to use for refraction.
  52633. */
  52634. refractionTexture: Nullable<BaseTexture>;
  52635. private _indexOfRefraction;
  52636. /**
  52637. * Defines the index of refraction used in the material.
  52638. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52639. */
  52640. indexOfRefraction: number;
  52641. private _invertRefractionY;
  52642. /**
  52643. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52644. */
  52645. invertRefractionY: boolean;
  52646. private _linkRefractionWithTransparency;
  52647. /**
  52648. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52649. * Materials half opaque for instance using refraction could benefit from this control.
  52650. */
  52651. linkRefractionWithTransparency: boolean;
  52652. /**
  52653. * Defines the minimum thickness stored in the thickness map.
  52654. * If no thickness map is defined, this value will be used to simulate thickness.
  52655. */
  52656. minimumThickness: number;
  52657. /**
  52658. * Defines the maximum thickness stored in the thickness map.
  52659. */
  52660. maximumThickness: number;
  52661. /**
  52662. * Defines the volume tint of the material.
  52663. * This is used for both translucency and scattering.
  52664. */
  52665. tintColor: Color3;
  52666. /**
  52667. * Defines the distance at which the tint color should be found in the media.
  52668. * This is used for refraction only.
  52669. */
  52670. tintColorAtDistance: number;
  52671. /**
  52672. * Defines how far each channel transmit through the media.
  52673. * It is defined as a color to simplify it selection.
  52674. */
  52675. diffusionDistance: Color3;
  52676. private _useMaskFromThicknessTexture;
  52677. /**
  52678. * Stores the intensity of the different subsurface effects in the thickness texture.
  52679. * * the green channel is the translucency intensity.
  52680. * * the blue channel is the scattering intensity.
  52681. * * the alpha channel is the refraction intensity.
  52682. */
  52683. useMaskFromThicknessTexture: boolean;
  52684. /** @hidden */
  52685. private _internalMarkAllSubMeshesAsTexturesDirty;
  52686. /** @hidden */
  52687. _markAllSubMeshesAsTexturesDirty(): void;
  52688. /**
  52689. * Instantiate a new istance of sub surface configuration.
  52690. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52691. */
  52692. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52693. /**
  52694. * Gets wehter the submesh is ready to be used or not.
  52695. * @param defines the list of "defines" to update.
  52696. * @param scene defines the scene the material belongs to.
  52697. * @returns - boolean indicating that the submesh is ready or not.
  52698. */
  52699. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52700. /**
  52701. * Checks to see if a texture is used in the material.
  52702. * @param defines the list of "defines" to update.
  52703. * @param scene defines the scene to the material belongs to.
  52704. */
  52705. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52706. /**
  52707. * Binds the material data.
  52708. * @param uniformBuffer defines the Uniform buffer to fill in.
  52709. * @param scene defines the scene the material belongs to.
  52710. * @param engine defines the engine the material belongs to.
  52711. * @param isFrozen defines wether the material is frozen or not.
  52712. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52713. */
  52714. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52715. /**
  52716. * Unbinds the material from the mesh.
  52717. * @param activeEffect defines the effect that should be unbound from.
  52718. * @returns true if unbound, otherwise false
  52719. */
  52720. unbind(activeEffect: Effect): boolean;
  52721. /**
  52722. * Returns the texture used for refraction or null if none is used.
  52723. * @param scene defines the scene the material belongs to.
  52724. * @returns - Refraction texture if present. If no refraction texture and refraction
  52725. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52726. */
  52727. private _getRefractionTexture;
  52728. /**
  52729. * Returns true if alpha blending should be disabled.
  52730. */
  52731. get disableAlphaBlending(): boolean;
  52732. /**
  52733. * Fills the list of render target textures.
  52734. * @param renderTargets the list of render targets to update
  52735. */
  52736. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52737. /**
  52738. * Checks to see if a texture is used in the material.
  52739. * @param texture - Base texture to use.
  52740. * @returns - Boolean specifying if a texture is used in the material.
  52741. */
  52742. hasTexture(texture: BaseTexture): boolean;
  52743. /**
  52744. * Gets a boolean indicating that current material needs to register RTT
  52745. * @returns true if this uses a render target otherwise false.
  52746. */
  52747. hasRenderTargetTextures(): boolean;
  52748. /**
  52749. * Returns an array of the actively used textures.
  52750. * @param activeTextures Array of BaseTextures
  52751. */
  52752. getActiveTextures(activeTextures: BaseTexture[]): void;
  52753. /**
  52754. * Returns the animatable textures.
  52755. * @param animatables Array of animatable textures.
  52756. */
  52757. getAnimatables(animatables: IAnimatable[]): void;
  52758. /**
  52759. * Disposes the resources of the material.
  52760. * @param forceDisposeTextures - Forces the disposal of all textures.
  52761. */
  52762. dispose(forceDisposeTextures?: boolean): void;
  52763. /**
  52764. * Get the current class name of the texture useful for serialization or dynamic coding.
  52765. * @returns "PBRSubSurfaceConfiguration"
  52766. */
  52767. getClassName(): string;
  52768. /**
  52769. * Add fallbacks to the effect fallbacks list.
  52770. * @param defines defines the Base texture to use.
  52771. * @param fallbacks defines the current fallback list.
  52772. * @param currentRank defines the current fallback rank.
  52773. * @returns the new fallback rank.
  52774. */
  52775. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52776. /**
  52777. * Add the required uniforms to the current list.
  52778. * @param uniforms defines the current uniform list.
  52779. */
  52780. static AddUniforms(uniforms: string[]): void;
  52781. /**
  52782. * Add the required samplers to the current list.
  52783. * @param samplers defines the current sampler list.
  52784. */
  52785. static AddSamplers(samplers: string[]): void;
  52786. /**
  52787. * Add the required uniforms to the current buffer.
  52788. * @param uniformBuffer defines the current uniform buffer.
  52789. */
  52790. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52791. /**
  52792. * Makes a duplicate of the current configuration into another one.
  52793. * @param configuration define the config where to copy the info
  52794. */
  52795. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52796. /**
  52797. * Serializes this Sub Surface configuration.
  52798. * @returns - An object with the serialized config.
  52799. */
  52800. serialize(): any;
  52801. /**
  52802. * Parses a anisotropy Configuration from a serialized object.
  52803. * @param source - Serialized object.
  52804. * @param scene Defines the scene we are parsing for
  52805. * @param rootUrl Defines the rootUrl to load from
  52806. */
  52807. parse(source: any, scene: Scene, rootUrl: string): void;
  52808. }
  52809. }
  52810. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52811. /** @hidden */
  52812. export var pbrFragmentDeclaration: {
  52813. name: string;
  52814. shader: string;
  52815. };
  52816. }
  52817. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52818. /** @hidden */
  52819. export var pbrUboDeclaration: {
  52820. name: string;
  52821. shader: string;
  52822. };
  52823. }
  52824. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52825. /** @hidden */
  52826. export var pbrFragmentExtraDeclaration: {
  52827. name: string;
  52828. shader: string;
  52829. };
  52830. }
  52831. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52832. /** @hidden */
  52833. export var pbrFragmentSamplersDeclaration: {
  52834. name: string;
  52835. shader: string;
  52836. };
  52837. }
  52838. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52839. /** @hidden */
  52840. export var pbrHelperFunctions: {
  52841. name: string;
  52842. shader: string;
  52843. };
  52844. }
  52845. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52846. /** @hidden */
  52847. export var harmonicsFunctions: {
  52848. name: string;
  52849. shader: string;
  52850. };
  52851. }
  52852. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52853. /** @hidden */
  52854. export var pbrDirectLightingSetupFunctions: {
  52855. name: string;
  52856. shader: string;
  52857. };
  52858. }
  52859. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52860. /** @hidden */
  52861. export var pbrDirectLightingFalloffFunctions: {
  52862. name: string;
  52863. shader: string;
  52864. };
  52865. }
  52866. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52867. /** @hidden */
  52868. export var pbrBRDFFunctions: {
  52869. name: string;
  52870. shader: string;
  52871. };
  52872. }
  52873. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52874. /** @hidden */
  52875. export var pbrDirectLightingFunctions: {
  52876. name: string;
  52877. shader: string;
  52878. };
  52879. }
  52880. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52881. /** @hidden */
  52882. export var pbrIBLFunctions: {
  52883. name: string;
  52884. shader: string;
  52885. };
  52886. }
  52887. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52888. /** @hidden */
  52889. export var pbrDebug: {
  52890. name: string;
  52891. shader: string;
  52892. };
  52893. }
  52894. declare module "babylonjs/Shaders/pbr.fragment" {
  52895. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52896. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52897. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52898. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52899. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52900. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52901. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52902. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52903. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52904. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52905. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52906. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52907. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52908. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52909. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52910. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52911. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52912. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52913. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52914. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52915. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52916. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52917. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52918. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52919. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52920. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52921. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52922. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52923. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52924. /** @hidden */
  52925. export var pbrPixelShader: {
  52926. name: string;
  52927. shader: string;
  52928. };
  52929. }
  52930. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52931. /** @hidden */
  52932. export var pbrVertexDeclaration: {
  52933. name: string;
  52934. shader: string;
  52935. };
  52936. }
  52937. declare module "babylonjs/Shaders/pbr.vertex" {
  52938. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52939. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52940. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52941. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52942. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52943. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52944. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52945. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52946. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52947. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52948. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52949. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52950. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52951. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52952. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52953. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52954. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52955. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52956. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52957. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52958. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52959. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52960. /** @hidden */
  52961. export var pbrVertexShader: {
  52962. name: string;
  52963. shader: string;
  52964. };
  52965. }
  52966. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52967. import { Nullable } from "babylonjs/types";
  52968. import { Scene } from "babylonjs/scene";
  52969. import { Matrix } from "babylonjs/Maths/math.vector";
  52970. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52972. import { Mesh } from "babylonjs/Meshes/mesh";
  52973. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52974. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52975. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52976. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52977. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52978. import { Color3 } from "babylonjs/Maths/math.color";
  52979. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52980. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52981. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52982. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52983. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52984. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52985. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52986. import "babylonjs/Shaders/pbr.fragment";
  52987. import "babylonjs/Shaders/pbr.vertex";
  52988. /**
  52989. * Manages the defines for the PBR Material.
  52990. * @hidden
  52991. */
  52992. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52993. PBR: boolean;
  52994. MAINUV1: boolean;
  52995. MAINUV2: boolean;
  52996. UV1: boolean;
  52997. UV2: boolean;
  52998. ALBEDO: boolean;
  52999. GAMMAALBEDO: boolean;
  53000. ALBEDODIRECTUV: number;
  53001. VERTEXCOLOR: boolean;
  53002. AMBIENT: boolean;
  53003. AMBIENTDIRECTUV: number;
  53004. AMBIENTINGRAYSCALE: boolean;
  53005. OPACITY: boolean;
  53006. VERTEXALPHA: boolean;
  53007. OPACITYDIRECTUV: number;
  53008. OPACITYRGB: boolean;
  53009. ALPHATEST: boolean;
  53010. DEPTHPREPASS: boolean;
  53011. ALPHABLEND: boolean;
  53012. ALPHAFROMALBEDO: boolean;
  53013. ALPHATESTVALUE: string;
  53014. SPECULAROVERALPHA: boolean;
  53015. RADIANCEOVERALPHA: boolean;
  53016. ALPHAFRESNEL: boolean;
  53017. LINEARALPHAFRESNEL: boolean;
  53018. PREMULTIPLYALPHA: boolean;
  53019. EMISSIVE: boolean;
  53020. EMISSIVEDIRECTUV: number;
  53021. REFLECTIVITY: boolean;
  53022. REFLECTIVITYDIRECTUV: number;
  53023. SPECULARTERM: boolean;
  53024. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53025. MICROSURFACEAUTOMATIC: boolean;
  53026. LODBASEDMICROSFURACE: boolean;
  53027. MICROSURFACEMAP: boolean;
  53028. MICROSURFACEMAPDIRECTUV: number;
  53029. METALLICWORKFLOW: boolean;
  53030. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53031. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53032. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53033. AOSTOREINMETALMAPRED: boolean;
  53034. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53035. ENVIRONMENTBRDF: boolean;
  53036. ENVIRONMENTBRDF_RGBD: boolean;
  53037. NORMAL: boolean;
  53038. TANGENT: boolean;
  53039. BUMP: boolean;
  53040. BUMPDIRECTUV: number;
  53041. OBJECTSPACE_NORMALMAP: boolean;
  53042. PARALLAX: boolean;
  53043. PARALLAXOCCLUSION: boolean;
  53044. NORMALXYSCALE: boolean;
  53045. LIGHTMAP: boolean;
  53046. LIGHTMAPDIRECTUV: number;
  53047. USELIGHTMAPASSHADOWMAP: boolean;
  53048. GAMMALIGHTMAP: boolean;
  53049. RGBDLIGHTMAP: boolean;
  53050. REFLECTION: boolean;
  53051. REFLECTIONMAP_3D: boolean;
  53052. REFLECTIONMAP_SPHERICAL: boolean;
  53053. REFLECTIONMAP_PLANAR: boolean;
  53054. REFLECTIONMAP_CUBIC: boolean;
  53055. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53056. REFLECTIONMAP_PROJECTION: boolean;
  53057. REFLECTIONMAP_SKYBOX: boolean;
  53058. REFLECTIONMAP_EXPLICIT: boolean;
  53059. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53060. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53061. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53062. INVERTCUBICMAP: boolean;
  53063. USESPHERICALFROMREFLECTIONMAP: boolean;
  53064. USEIRRADIANCEMAP: boolean;
  53065. SPHERICAL_HARMONICS: boolean;
  53066. USESPHERICALINVERTEX: boolean;
  53067. REFLECTIONMAP_OPPOSITEZ: boolean;
  53068. LODINREFLECTIONALPHA: boolean;
  53069. GAMMAREFLECTION: boolean;
  53070. RGBDREFLECTION: boolean;
  53071. LINEARSPECULARREFLECTION: boolean;
  53072. RADIANCEOCCLUSION: boolean;
  53073. HORIZONOCCLUSION: boolean;
  53074. INSTANCES: boolean;
  53075. NUM_BONE_INFLUENCERS: number;
  53076. BonesPerMesh: number;
  53077. BONETEXTURE: boolean;
  53078. NONUNIFORMSCALING: boolean;
  53079. MORPHTARGETS: boolean;
  53080. MORPHTARGETS_NORMAL: boolean;
  53081. MORPHTARGETS_TANGENT: boolean;
  53082. MORPHTARGETS_UV: boolean;
  53083. NUM_MORPH_INFLUENCERS: number;
  53084. IMAGEPROCESSING: boolean;
  53085. VIGNETTE: boolean;
  53086. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53087. VIGNETTEBLENDMODEOPAQUE: boolean;
  53088. TONEMAPPING: boolean;
  53089. TONEMAPPING_ACES: boolean;
  53090. CONTRAST: boolean;
  53091. COLORCURVES: boolean;
  53092. COLORGRADING: boolean;
  53093. COLORGRADING3D: boolean;
  53094. SAMPLER3DGREENDEPTH: boolean;
  53095. SAMPLER3DBGRMAP: boolean;
  53096. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53097. EXPOSURE: boolean;
  53098. MULTIVIEW: boolean;
  53099. USEPHYSICALLIGHTFALLOFF: boolean;
  53100. USEGLTFLIGHTFALLOFF: boolean;
  53101. TWOSIDEDLIGHTING: boolean;
  53102. SHADOWFLOAT: boolean;
  53103. CLIPPLANE: boolean;
  53104. CLIPPLANE2: boolean;
  53105. CLIPPLANE3: boolean;
  53106. CLIPPLANE4: boolean;
  53107. CLIPPLANE5: boolean;
  53108. CLIPPLANE6: boolean;
  53109. POINTSIZE: boolean;
  53110. FOG: boolean;
  53111. LOGARITHMICDEPTH: boolean;
  53112. FORCENORMALFORWARD: boolean;
  53113. SPECULARAA: boolean;
  53114. CLEARCOAT: boolean;
  53115. CLEARCOAT_DEFAULTIOR: boolean;
  53116. CLEARCOAT_TEXTURE: boolean;
  53117. CLEARCOAT_TEXTUREDIRECTUV: number;
  53118. CLEARCOAT_BUMP: boolean;
  53119. CLEARCOAT_BUMPDIRECTUV: number;
  53120. CLEARCOAT_TINT: boolean;
  53121. CLEARCOAT_TINT_TEXTURE: boolean;
  53122. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53123. ANISOTROPIC: boolean;
  53124. ANISOTROPIC_TEXTURE: boolean;
  53125. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53126. BRDF_V_HEIGHT_CORRELATED: boolean;
  53127. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53128. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53129. SHEEN: boolean;
  53130. SHEEN_TEXTURE: boolean;
  53131. SHEEN_TEXTUREDIRECTUV: number;
  53132. SHEEN_LINKWITHALBEDO: boolean;
  53133. SUBSURFACE: boolean;
  53134. SS_REFRACTION: boolean;
  53135. SS_TRANSLUCENCY: boolean;
  53136. SS_SCATERRING: boolean;
  53137. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53138. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53139. SS_REFRACTIONMAP_3D: boolean;
  53140. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53141. SS_LODINREFRACTIONALPHA: boolean;
  53142. SS_GAMMAREFRACTION: boolean;
  53143. SS_RGBDREFRACTION: boolean;
  53144. SS_LINEARSPECULARREFRACTION: boolean;
  53145. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53146. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53147. UNLIT: boolean;
  53148. DEBUGMODE: number;
  53149. /**
  53150. * Initializes the PBR Material defines.
  53151. */
  53152. constructor();
  53153. /**
  53154. * Resets the PBR Material defines.
  53155. */
  53156. reset(): void;
  53157. }
  53158. /**
  53159. * The Physically based material base class of BJS.
  53160. *
  53161. * This offers the main features of a standard PBR material.
  53162. * For more information, please refer to the documentation :
  53163. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53164. */
  53165. export abstract class PBRBaseMaterial extends PushMaterial {
  53166. /**
  53167. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53168. */
  53169. static readonly PBRMATERIAL_OPAQUE: number;
  53170. /**
  53171. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53172. */
  53173. static readonly PBRMATERIAL_ALPHATEST: number;
  53174. /**
  53175. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53176. */
  53177. static readonly PBRMATERIAL_ALPHABLEND: number;
  53178. /**
  53179. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53180. * They are also discarded below the alpha cutoff threshold to improve performances.
  53181. */
  53182. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53183. /**
  53184. * Defines the default value of how much AO map is occluding the analytical lights
  53185. * (point spot...).
  53186. */
  53187. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53188. /**
  53189. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53190. */
  53191. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53192. /**
  53193. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53194. * to enhance interoperability with other engines.
  53195. */
  53196. static readonly LIGHTFALLOFF_GLTF: number;
  53197. /**
  53198. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53199. * to enhance interoperability with other materials.
  53200. */
  53201. static readonly LIGHTFALLOFF_STANDARD: number;
  53202. /**
  53203. * Intensity of the direct lights e.g. the four lights available in your scene.
  53204. * This impacts both the direct diffuse and specular highlights.
  53205. */
  53206. protected _directIntensity: number;
  53207. /**
  53208. * Intensity of the emissive part of the material.
  53209. * This helps controlling the emissive effect without modifying the emissive color.
  53210. */
  53211. protected _emissiveIntensity: number;
  53212. /**
  53213. * Intensity of the environment e.g. how much the environment will light the object
  53214. * either through harmonics for rough material or through the refelction for shiny ones.
  53215. */
  53216. protected _environmentIntensity: number;
  53217. /**
  53218. * This is a special control allowing the reduction of the specular highlights coming from the
  53219. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53220. */
  53221. protected _specularIntensity: number;
  53222. /**
  53223. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53224. */
  53225. private _lightingInfos;
  53226. /**
  53227. * Debug Control allowing disabling the bump map on this material.
  53228. */
  53229. protected _disableBumpMap: boolean;
  53230. /**
  53231. * AKA Diffuse Texture in standard nomenclature.
  53232. */
  53233. protected _albedoTexture: Nullable<BaseTexture>;
  53234. /**
  53235. * AKA Occlusion Texture in other nomenclature.
  53236. */
  53237. protected _ambientTexture: Nullable<BaseTexture>;
  53238. /**
  53239. * AKA Occlusion Texture Intensity in other nomenclature.
  53240. */
  53241. protected _ambientTextureStrength: number;
  53242. /**
  53243. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53244. * 1 means it completely occludes it
  53245. * 0 mean it has no impact
  53246. */
  53247. protected _ambientTextureImpactOnAnalyticalLights: number;
  53248. /**
  53249. * Stores the alpha values in a texture.
  53250. */
  53251. protected _opacityTexture: Nullable<BaseTexture>;
  53252. /**
  53253. * Stores the reflection values in a texture.
  53254. */
  53255. protected _reflectionTexture: Nullable<BaseTexture>;
  53256. /**
  53257. * Stores the emissive values in a texture.
  53258. */
  53259. protected _emissiveTexture: Nullable<BaseTexture>;
  53260. /**
  53261. * AKA Specular texture in other nomenclature.
  53262. */
  53263. protected _reflectivityTexture: Nullable<BaseTexture>;
  53264. /**
  53265. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53266. */
  53267. protected _metallicTexture: Nullable<BaseTexture>;
  53268. /**
  53269. * Specifies the metallic scalar of the metallic/roughness workflow.
  53270. * Can also be used to scale the metalness values of the metallic texture.
  53271. */
  53272. protected _metallic: Nullable<number>;
  53273. /**
  53274. * Specifies the roughness scalar of the metallic/roughness workflow.
  53275. * Can also be used to scale the roughness values of the metallic texture.
  53276. */
  53277. protected _roughness: Nullable<number>;
  53278. /**
  53279. * Specifies the an F0 factor to help configuring the material F0.
  53280. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53281. * to 0.5 the previously hard coded value stays the same.
  53282. * Can also be used to scale the F0 values of the metallic texture.
  53283. */
  53284. protected _metallicF0Factor: number;
  53285. /**
  53286. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53287. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53288. * your expectation as it multiplies with the texture data.
  53289. */
  53290. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53291. /**
  53292. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53293. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53294. */
  53295. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53296. /**
  53297. * Stores surface normal data used to displace a mesh in a texture.
  53298. */
  53299. protected _bumpTexture: Nullable<BaseTexture>;
  53300. /**
  53301. * Stores the pre-calculated light information of a mesh in a texture.
  53302. */
  53303. protected _lightmapTexture: Nullable<BaseTexture>;
  53304. /**
  53305. * The color of a material in ambient lighting.
  53306. */
  53307. protected _ambientColor: Color3;
  53308. /**
  53309. * AKA Diffuse Color in other nomenclature.
  53310. */
  53311. protected _albedoColor: Color3;
  53312. /**
  53313. * AKA Specular Color in other nomenclature.
  53314. */
  53315. protected _reflectivityColor: Color3;
  53316. /**
  53317. * The color applied when light is reflected from a material.
  53318. */
  53319. protected _reflectionColor: Color3;
  53320. /**
  53321. * The color applied when light is emitted from a material.
  53322. */
  53323. protected _emissiveColor: Color3;
  53324. /**
  53325. * AKA Glossiness in other nomenclature.
  53326. */
  53327. protected _microSurface: number;
  53328. /**
  53329. * Specifies that the material will use the light map as a show map.
  53330. */
  53331. protected _useLightmapAsShadowmap: boolean;
  53332. /**
  53333. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53334. * makes the reflect vector face the model (under horizon).
  53335. */
  53336. protected _useHorizonOcclusion: boolean;
  53337. /**
  53338. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53339. * too much the area relying on ambient texture to define their ambient occlusion.
  53340. */
  53341. protected _useRadianceOcclusion: boolean;
  53342. /**
  53343. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53344. */
  53345. protected _useAlphaFromAlbedoTexture: boolean;
  53346. /**
  53347. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53348. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53349. */
  53350. protected _useSpecularOverAlpha: boolean;
  53351. /**
  53352. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53353. */
  53354. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53355. /**
  53356. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53357. */
  53358. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53359. /**
  53360. * Specifies if the metallic texture contains the roughness information in its green channel.
  53361. */
  53362. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53363. /**
  53364. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53365. */
  53366. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53367. /**
  53368. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53369. */
  53370. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53371. /**
  53372. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53373. */
  53374. protected _useAmbientInGrayScale: boolean;
  53375. /**
  53376. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53377. * The material will try to infer what glossiness each pixel should be.
  53378. */
  53379. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53380. /**
  53381. * Defines the falloff type used in this material.
  53382. * It by default is Physical.
  53383. */
  53384. protected _lightFalloff: number;
  53385. /**
  53386. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53387. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53388. */
  53389. protected _useRadianceOverAlpha: boolean;
  53390. /**
  53391. * Allows using an object space normal map (instead of tangent space).
  53392. */
  53393. protected _useObjectSpaceNormalMap: boolean;
  53394. /**
  53395. * Allows using the bump map in parallax mode.
  53396. */
  53397. protected _useParallax: boolean;
  53398. /**
  53399. * Allows using the bump map in parallax occlusion mode.
  53400. */
  53401. protected _useParallaxOcclusion: boolean;
  53402. /**
  53403. * Controls the scale bias of the parallax mode.
  53404. */
  53405. protected _parallaxScaleBias: number;
  53406. /**
  53407. * If sets to true, disables all the lights affecting the material.
  53408. */
  53409. protected _disableLighting: boolean;
  53410. /**
  53411. * Number of Simultaneous lights allowed on the material.
  53412. */
  53413. protected _maxSimultaneousLights: number;
  53414. /**
  53415. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53416. */
  53417. protected _invertNormalMapX: boolean;
  53418. /**
  53419. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53420. */
  53421. protected _invertNormalMapY: boolean;
  53422. /**
  53423. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53424. */
  53425. protected _twoSidedLighting: boolean;
  53426. /**
  53427. * Defines the alpha limits in alpha test mode.
  53428. */
  53429. protected _alphaCutOff: number;
  53430. /**
  53431. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53432. */
  53433. protected _forceAlphaTest: boolean;
  53434. /**
  53435. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53436. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53437. */
  53438. protected _useAlphaFresnel: boolean;
  53439. /**
  53440. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53441. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53442. */
  53443. protected _useLinearAlphaFresnel: boolean;
  53444. /**
  53445. * The transparency mode of the material.
  53446. */
  53447. protected _transparencyMode: Nullable<number>;
  53448. /**
  53449. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53450. * from cos thetav and roughness:
  53451. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53452. */
  53453. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53454. /**
  53455. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53456. */
  53457. protected _forceIrradianceInFragment: boolean;
  53458. /**
  53459. * Force normal to face away from face.
  53460. */
  53461. protected _forceNormalForward: boolean;
  53462. /**
  53463. * Enables specular anti aliasing in the PBR shader.
  53464. * It will both interacts on the Geometry for analytical and IBL lighting.
  53465. * It also prefilter the roughness map based on the bump values.
  53466. */
  53467. protected _enableSpecularAntiAliasing: boolean;
  53468. /**
  53469. * Default configuration related to image processing available in the PBR Material.
  53470. */
  53471. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53472. /**
  53473. * Keep track of the image processing observer to allow dispose and replace.
  53474. */
  53475. private _imageProcessingObserver;
  53476. /**
  53477. * Attaches a new image processing configuration to the PBR Material.
  53478. * @param configuration
  53479. */
  53480. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53481. /**
  53482. * Stores the available render targets.
  53483. */
  53484. private _renderTargets;
  53485. /**
  53486. * Sets the global ambient color for the material used in lighting calculations.
  53487. */
  53488. private _globalAmbientColor;
  53489. /**
  53490. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53491. */
  53492. private _useLogarithmicDepth;
  53493. /**
  53494. * If set to true, no lighting calculations will be applied.
  53495. */
  53496. private _unlit;
  53497. private _debugMode;
  53498. /**
  53499. * @hidden
  53500. * This is reserved for the inspector.
  53501. * Defines the material debug mode.
  53502. * It helps seeing only some components of the material while troubleshooting.
  53503. */
  53504. debugMode: number;
  53505. /**
  53506. * @hidden
  53507. * This is reserved for the inspector.
  53508. * Specify from where on screen the debug mode should start.
  53509. * The value goes from -1 (full screen) to 1 (not visible)
  53510. * It helps with side by side comparison against the final render
  53511. * This defaults to -1
  53512. */
  53513. private debugLimit;
  53514. /**
  53515. * @hidden
  53516. * This is reserved for the inspector.
  53517. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53518. * You can use the factor to better multiply the final value.
  53519. */
  53520. private debugFactor;
  53521. /**
  53522. * Defines the clear coat layer parameters for the material.
  53523. */
  53524. readonly clearCoat: PBRClearCoatConfiguration;
  53525. /**
  53526. * Defines the anisotropic parameters for the material.
  53527. */
  53528. readonly anisotropy: PBRAnisotropicConfiguration;
  53529. /**
  53530. * Defines the BRDF parameters for the material.
  53531. */
  53532. readonly brdf: PBRBRDFConfiguration;
  53533. /**
  53534. * Defines the Sheen parameters for the material.
  53535. */
  53536. readonly sheen: PBRSheenConfiguration;
  53537. /**
  53538. * Defines the SubSurface parameters for the material.
  53539. */
  53540. readonly subSurface: PBRSubSurfaceConfiguration;
  53541. /**
  53542. * Custom callback helping to override the default shader used in the material.
  53543. */
  53544. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53545. protected _rebuildInParallel: boolean;
  53546. /**
  53547. * Instantiates a new PBRMaterial instance.
  53548. *
  53549. * @param name The material name
  53550. * @param scene The scene the material will be use in.
  53551. */
  53552. constructor(name: string, scene: Scene);
  53553. /**
  53554. * Gets a boolean indicating that current material needs to register RTT
  53555. */
  53556. get hasRenderTargetTextures(): boolean;
  53557. /**
  53558. * Gets the name of the material class.
  53559. */
  53560. getClassName(): string;
  53561. /**
  53562. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53563. */
  53564. get useLogarithmicDepth(): boolean;
  53565. /**
  53566. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53567. */
  53568. set useLogarithmicDepth(value: boolean);
  53569. /**
  53570. * Gets the current transparency mode.
  53571. */
  53572. get transparencyMode(): Nullable<number>;
  53573. /**
  53574. * Sets the transparency mode of the material.
  53575. *
  53576. * | Value | Type | Description |
  53577. * | ----- | ----------------------------------- | ----------- |
  53578. * | 0 | OPAQUE | |
  53579. * | 1 | ALPHATEST | |
  53580. * | 2 | ALPHABLEND | |
  53581. * | 3 | ALPHATESTANDBLEND | |
  53582. *
  53583. */
  53584. set transparencyMode(value: Nullable<number>);
  53585. /**
  53586. * Returns true if alpha blending should be disabled.
  53587. */
  53588. private get _disableAlphaBlending();
  53589. /**
  53590. * Specifies whether or not this material should be rendered in alpha blend mode.
  53591. */
  53592. needAlphaBlending(): boolean;
  53593. /**
  53594. * Specifies if the mesh will require alpha blending.
  53595. * @param mesh - BJS mesh.
  53596. */
  53597. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53598. /**
  53599. * Specifies whether or not this material should be rendered in alpha test mode.
  53600. */
  53601. needAlphaTesting(): boolean;
  53602. /**
  53603. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53604. */
  53605. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53606. /**
  53607. * Gets the texture used for the alpha test.
  53608. */
  53609. getAlphaTestTexture(): Nullable<BaseTexture>;
  53610. /**
  53611. * Specifies that the submesh is ready to be used.
  53612. * @param mesh - BJS mesh.
  53613. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53614. * @param useInstances - Specifies that instances should be used.
  53615. * @returns - boolean indicating that the submesh is ready or not.
  53616. */
  53617. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53618. /**
  53619. * Specifies if the material uses metallic roughness workflow.
  53620. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53621. */
  53622. isMetallicWorkflow(): boolean;
  53623. private _prepareEffect;
  53624. private _prepareDefines;
  53625. /**
  53626. * Force shader compilation
  53627. */
  53628. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53629. /**
  53630. * Initializes the uniform buffer layout for the shader.
  53631. */
  53632. buildUniformLayout(): void;
  53633. /**
  53634. * Unbinds the material from the mesh
  53635. */
  53636. unbind(): void;
  53637. /**
  53638. * Binds the submesh data.
  53639. * @param world - The world matrix.
  53640. * @param mesh - The BJS mesh.
  53641. * @param subMesh - A submesh of the BJS mesh.
  53642. */
  53643. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53644. /**
  53645. * Returns the animatable textures.
  53646. * @returns - Array of animatable textures.
  53647. */
  53648. getAnimatables(): IAnimatable[];
  53649. /**
  53650. * Returns the texture used for reflections.
  53651. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53652. */
  53653. private _getReflectionTexture;
  53654. /**
  53655. * Returns an array of the actively used textures.
  53656. * @returns - Array of BaseTextures
  53657. */
  53658. getActiveTextures(): BaseTexture[];
  53659. /**
  53660. * Checks to see if a texture is used in the material.
  53661. * @param texture - Base texture to use.
  53662. * @returns - Boolean specifying if a texture is used in the material.
  53663. */
  53664. hasTexture(texture: BaseTexture): boolean;
  53665. /**
  53666. * Disposes the resources of the material.
  53667. * @param forceDisposeEffect - Forces the disposal of effects.
  53668. * @param forceDisposeTextures - Forces the disposal of all textures.
  53669. */
  53670. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53671. }
  53672. }
  53673. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53674. import { Nullable } from "babylonjs/types";
  53675. import { Scene } from "babylonjs/scene";
  53676. import { Color3 } from "babylonjs/Maths/math.color";
  53677. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53678. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53679. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53680. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53681. /**
  53682. * The Physically based material of BJS.
  53683. *
  53684. * This offers the main features of a standard PBR material.
  53685. * For more information, please refer to the documentation :
  53686. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53687. */
  53688. export class PBRMaterial extends PBRBaseMaterial {
  53689. /**
  53690. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53691. */
  53692. static readonly PBRMATERIAL_OPAQUE: number;
  53693. /**
  53694. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53695. */
  53696. static readonly PBRMATERIAL_ALPHATEST: number;
  53697. /**
  53698. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53699. */
  53700. static readonly PBRMATERIAL_ALPHABLEND: number;
  53701. /**
  53702. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53703. * They are also discarded below the alpha cutoff threshold to improve performances.
  53704. */
  53705. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53706. /**
  53707. * Defines the default value of how much AO map is occluding the analytical lights
  53708. * (point spot...).
  53709. */
  53710. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53711. /**
  53712. * Intensity of the direct lights e.g. the four lights available in your scene.
  53713. * This impacts both the direct diffuse and specular highlights.
  53714. */
  53715. directIntensity: number;
  53716. /**
  53717. * Intensity of the emissive part of the material.
  53718. * This helps controlling the emissive effect without modifying the emissive color.
  53719. */
  53720. emissiveIntensity: number;
  53721. /**
  53722. * Intensity of the environment e.g. how much the environment will light the object
  53723. * either through harmonics for rough material or through the refelction for shiny ones.
  53724. */
  53725. environmentIntensity: number;
  53726. /**
  53727. * This is a special control allowing the reduction of the specular highlights coming from the
  53728. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53729. */
  53730. specularIntensity: number;
  53731. /**
  53732. * Debug Control allowing disabling the bump map on this material.
  53733. */
  53734. disableBumpMap: boolean;
  53735. /**
  53736. * AKA Diffuse Texture in standard nomenclature.
  53737. */
  53738. albedoTexture: BaseTexture;
  53739. /**
  53740. * AKA Occlusion Texture in other nomenclature.
  53741. */
  53742. ambientTexture: BaseTexture;
  53743. /**
  53744. * AKA Occlusion Texture Intensity in other nomenclature.
  53745. */
  53746. ambientTextureStrength: number;
  53747. /**
  53748. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53749. * 1 means it completely occludes it
  53750. * 0 mean it has no impact
  53751. */
  53752. ambientTextureImpactOnAnalyticalLights: number;
  53753. /**
  53754. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53755. */
  53756. opacityTexture: BaseTexture;
  53757. /**
  53758. * Stores the reflection values in a texture.
  53759. */
  53760. reflectionTexture: Nullable<BaseTexture>;
  53761. /**
  53762. * Stores the emissive values in a texture.
  53763. */
  53764. emissiveTexture: BaseTexture;
  53765. /**
  53766. * AKA Specular texture in other nomenclature.
  53767. */
  53768. reflectivityTexture: BaseTexture;
  53769. /**
  53770. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53771. */
  53772. metallicTexture: BaseTexture;
  53773. /**
  53774. * Specifies the metallic scalar of the metallic/roughness workflow.
  53775. * Can also be used to scale the metalness values of the metallic texture.
  53776. */
  53777. metallic: Nullable<number>;
  53778. /**
  53779. * Specifies the roughness scalar of the metallic/roughness workflow.
  53780. * Can also be used to scale the roughness values of the metallic texture.
  53781. */
  53782. roughness: Nullable<number>;
  53783. /**
  53784. * Specifies the an F0 factor to help configuring the material F0.
  53785. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53786. * to 0.5 the previously hard coded value stays the same.
  53787. * Can also be used to scale the F0 values of the metallic texture.
  53788. */
  53789. metallicF0Factor: number;
  53790. /**
  53791. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53792. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53793. * your expectation as it multiplies with the texture data.
  53794. */
  53795. useMetallicF0FactorFromMetallicTexture: boolean;
  53796. /**
  53797. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53798. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53799. */
  53800. microSurfaceTexture: BaseTexture;
  53801. /**
  53802. * Stores surface normal data used to displace a mesh in a texture.
  53803. */
  53804. bumpTexture: BaseTexture;
  53805. /**
  53806. * Stores the pre-calculated light information of a mesh in a texture.
  53807. */
  53808. lightmapTexture: BaseTexture;
  53809. /**
  53810. * Stores the refracted light information in a texture.
  53811. */
  53812. get refractionTexture(): Nullable<BaseTexture>;
  53813. set refractionTexture(value: Nullable<BaseTexture>);
  53814. /**
  53815. * The color of a material in ambient lighting.
  53816. */
  53817. ambientColor: Color3;
  53818. /**
  53819. * AKA Diffuse Color in other nomenclature.
  53820. */
  53821. albedoColor: Color3;
  53822. /**
  53823. * AKA Specular Color in other nomenclature.
  53824. */
  53825. reflectivityColor: Color3;
  53826. /**
  53827. * The color reflected from the material.
  53828. */
  53829. reflectionColor: Color3;
  53830. /**
  53831. * The color emitted from the material.
  53832. */
  53833. emissiveColor: Color3;
  53834. /**
  53835. * AKA Glossiness in other nomenclature.
  53836. */
  53837. microSurface: number;
  53838. /**
  53839. * source material index of refraction (IOR)' / 'destination material IOR.
  53840. */
  53841. get indexOfRefraction(): number;
  53842. set indexOfRefraction(value: number);
  53843. /**
  53844. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53845. */
  53846. get invertRefractionY(): boolean;
  53847. set invertRefractionY(value: boolean);
  53848. /**
  53849. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53850. * Materials half opaque for instance using refraction could benefit from this control.
  53851. */
  53852. get linkRefractionWithTransparency(): boolean;
  53853. set linkRefractionWithTransparency(value: boolean);
  53854. /**
  53855. * If true, the light map contains occlusion information instead of lighting info.
  53856. */
  53857. useLightmapAsShadowmap: boolean;
  53858. /**
  53859. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53860. */
  53861. useAlphaFromAlbedoTexture: boolean;
  53862. /**
  53863. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53864. */
  53865. forceAlphaTest: boolean;
  53866. /**
  53867. * Defines the alpha limits in alpha test mode.
  53868. */
  53869. alphaCutOff: number;
  53870. /**
  53871. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53872. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53873. */
  53874. useSpecularOverAlpha: boolean;
  53875. /**
  53876. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53877. */
  53878. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53879. /**
  53880. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53881. */
  53882. useRoughnessFromMetallicTextureAlpha: boolean;
  53883. /**
  53884. * Specifies if the metallic texture contains the roughness information in its green channel.
  53885. */
  53886. useRoughnessFromMetallicTextureGreen: boolean;
  53887. /**
  53888. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53889. */
  53890. useMetallnessFromMetallicTextureBlue: boolean;
  53891. /**
  53892. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53893. */
  53894. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53895. /**
  53896. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53897. */
  53898. useAmbientInGrayScale: boolean;
  53899. /**
  53900. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53901. * The material will try to infer what glossiness each pixel should be.
  53902. */
  53903. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53904. /**
  53905. * BJS is using an harcoded light falloff based on a manually sets up range.
  53906. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53907. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53908. */
  53909. get usePhysicalLightFalloff(): boolean;
  53910. /**
  53911. * BJS is using an harcoded light falloff based on a manually sets up range.
  53912. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53913. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53914. */
  53915. set usePhysicalLightFalloff(value: boolean);
  53916. /**
  53917. * In order to support the falloff compatibility with gltf, a special mode has been added
  53918. * to reproduce the gltf light falloff.
  53919. */
  53920. get useGLTFLightFalloff(): boolean;
  53921. /**
  53922. * In order to support the falloff compatibility with gltf, a special mode has been added
  53923. * to reproduce the gltf light falloff.
  53924. */
  53925. set useGLTFLightFalloff(value: boolean);
  53926. /**
  53927. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53928. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53929. */
  53930. useRadianceOverAlpha: boolean;
  53931. /**
  53932. * Allows using an object space normal map (instead of tangent space).
  53933. */
  53934. useObjectSpaceNormalMap: boolean;
  53935. /**
  53936. * Allows using the bump map in parallax mode.
  53937. */
  53938. useParallax: boolean;
  53939. /**
  53940. * Allows using the bump map in parallax occlusion mode.
  53941. */
  53942. useParallaxOcclusion: boolean;
  53943. /**
  53944. * Controls the scale bias of the parallax mode.
  53945. */
  53946. parallaxScaleBias: number;
  53947. /**
  53948. * If sets to true, disables all the lights affecting the material.
  53949. */
  53950. disableLighting: boolean;
  53951. /**
  53952. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53953. */
  53954. forceIrradianceInFragment: boolean;
  53955. /**
  53956. * Number of Simultaneous lights allowed on the material.
  53957. */
  53958. maxSimultaneousLights: number;
  53959. /**
  53960. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53961. */
  53962. invertNormalMapX: boolean;
  53963. /**
  53964. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53965. */
  53966. invertNormalMapY: boolean;
  53967. /**
  53968. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53969. */
  53970. twoSidedLighting: boolean;
  53971. /**
  53972. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53973. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53974. */
  53975. useAlphaFresnel: boolean;
  53976. /**
  53977. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53978. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53979. */
  53980. useLinearAlphaFresnel: boolean;
  53981. /**
  53982. * Let user defines the brdf lookup texture used for IBL.
  53983. * A default 8bit version is embedded but you could point at :
  53984. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53985. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53986. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53987. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53988. */
  53989. environmentBRDFTexture: Nullable<BaseTexture>;
  53990. /**
  53991. * Force normal to face away from face.
  53992. */
  53993. forceNormalForward: boolean;
  53994. /**
  53995. * Enables specular anti aliasing in the PBR shader.
  53996. * It will both interacts on the Geometry for analytical and IBL lighting.
  53997. * It also prefilter the roughness map based on the bump values.
  53998. */
  53999. enableSpecularAntiAliasing: boolean;
  54000. /**
  54001. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54002. * makes the reflect vector face the model (under horizon).
  54003. */
  54004. useHorizonOcclusion: boolean;
  54005. /**
  54006. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54007. * too much the area relying on ambient texture to define their ambient occlusion.
  54008. */
  54009. useRadianceOcclusion: boolean;
  54010. /**
  54011. * If set to true, no lighting calculations will be applied.
  54012. */
  54013. unlit: boolean;
  54014. /**
  54015. * Gets the image processing configuration used either in this material.
  54016. */
  54017. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54018. /**
  54019. * Sets the Default image processing configuration used either in the this material.
  54020. *
  54021. * If sets to null, the scene one is in use.
  54022. */
  54023. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54024. /**
  54025. * Gets wether the color curves effect is enabled.
  54026. */
  54027. get cameraColorCurvesEnabled(): boolean;
  54028. /**
  54029. * Sets wether the color curves effect is enabled.
  54030. */
  54031. set cameraColorCurvesEnabled(value: boolean);
  54032. /**
  54033. * Gets wether the color grading effect is enabled.
  54034. */
  54035. get cameraColorGradingEnabled(): boolean;
  54036. /**
  54037. * Gets wether the color grading effect is enabled.
  54038. */
  54039. set cameraColorGradingEnabled(value: boolean);
  54040. /**
  54041. * Gets wether tonemapping is enabled or not.
  54042. */
  54043. get cameraToneMappingEnabled(): boolean;
  54044. /**
  54045. * Sets wether tonemapping is enabled or not
  54046. */
  54047. set cameraToneMappingEnabled(value: boolean);
  54048. /**
  54049. * The camera exposure used on this material.
  54050. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54051. * This corresponds to a photographic exposure.
  54052. */
  54053. get cameraExposure(): number;
  54054. /**
  54055. * The camera exposure used on this material.
  54056. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54057. * This corresponds to a photographic exposure.
  54058. */
  54059. set cameraExposure(value: number);
  54060. /**
  54061. * Gets The camera contrast used on this material.
  54062. */
  54063. get cameraContrast(): number;
  54064. /**
  54065. * Sets The camera contrast used on this material.
  54066. */
  54067. set cameraContrast(value: number);
  54068. /**
  54069. * Gets the Color Grading 2D Lookup Texture.
  54070. */
  54071. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54072. /**
  54073. * Sets the Color Grading 2D Lookup Texture.
  54074. */
  54075. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54076. /**
  54077. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54078. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54079. * 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;
  54080. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54081. */
  54082. get cameraColorCurves(): Nullable<ColorCurves>;
  54083. /**
  54084. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54085. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54086. * 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;
  54087. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54088. */
  54089. set cameraColorCurves(value: Nullable<ColorCurves>);
  54090. /**
  54091. * Instantiates a new PBRMaterial instance.
  54092. *
  54093. * @param name The material name
  54094. * @param scene The scene the material will be use in.
  54095. */
  54096. constructor(name: string, scene: Scene);
  54097. /**
  54098. * Returns the name of this material class.
  54099. */
  54100. getClassName(): string;
  54101. /**
  54102. * Makes a duplicate of the current material.
  54103. * @param name - name to use for the new material.
  54104. */
  54105. clone(name: string): PBRMaterial;
  54106. /**
  54107. * Serializes this PBR Material.
  54108. * @returns - An object with the serialized material.
  54109. */
  54110. serialize(): any;
  54111. /**
  54112. * Parses a PBR Material from a serialized object.
  54113. * @param source - Serialized object.
  54114. * @param scene - BJS scene instance.
  54115. * @param rootUrl - url for the scene object
  54116. * @returns - PBRMaterial
  54117. */
  54118. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54119. }
  54120. }
  54121. declare module "babylonjs/Misc/dds" {
  54122. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54123. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54124. import { Nullable } from "babylonjs/types";
  54125. import { Scene } from "babylonjs/scene";
  54126. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54127. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54128. /**
  54129. * Direct draw surface info
  54130. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54131. */
  54132. export interface DDSInfo {
  54133. /**
  54134. * Width of the texture
  54135. */
  54136. width: number;
  54137. /**
  54138. * Width of the texture
  54139. */
  54140. height: number;
  54141. /**
  54142. * Number of Mipmaps for the texture
  54143. * @see https://en.wikipedia.org/wiki/Mipmap
  54144. */
  54145. mipmapCount: number;
  54146. /**
  54147. * If the textures format is a known fourCC format
  54148. * @see https://www.fourcc.org/
  54149. */
  54150. isFourCC: boolean;
  54151. /**
  54152. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54153. */
  54154. isRGB: boolean;
  54155. /**
  54156. * If the texture is a lumincance format
  54157. */
  54158. isLuminance: boolean;
  54159. /**
  54160. * If this is a cube texture
  54161. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54162. */
  54163. isCube: boolean;
  54164. /**
  54165. * If the texture is a compressed format eg. FOURCC_DXT1
  54166. */
  54167. isCompressed: boolean;
  54168. /**
  54169. * The dxgiFormat of the texture
  54170. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54171. */
  54172. dxgiFormat: number;
  54173. /**
  54174. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54175. */
  54176. textureType: number;
  54177. /**
  54178. * Sphericle polynomial created for the dds texture
  54179. */
  54180. sphericalPolynomial?: SphericalPolynomial;
  54181. }
  54182. /**
  54183. * Class used to provide DDS decompression tools
  54184. */
  54185. export class DDSTools {
  54186. /**
  54187. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54188. */
  54189. static StoreLODInAlphaChannel: boolean;
  54190. /**
  54191. * Gets DDS information from an array buffer
  54192. * @param data defines the array buffer view to read data from
  54193. * @returns the DDS information
  54194. */
  54195. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54196. private static _FloatView;
  54197. private static _Int32View;
  54198. private static _ToHalfFloat;
  54199. private static _FromHalfFloat;
  54200. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54201. private static _GetHalfFloatRGBAArrayBuffer;
  54202. private static _GetFloatRGBAArrayBuffer;
  54203. private static _GetFloatAsUIntRGBAArrayBuffer;
  54204. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54205. private static _GetRGBAArrayBuffer;
  54206. private static _ExtractLongWordOrder;
  54207. private static _GetRGBArrayBuffer;
  54208. private static _GetLuminanceArrayBuffer;
  54209. /**
  54210. * Uploads DDS Levels to a Babylon Texture
  54211. * @hidden
  54212. */
  54213. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54214. }
  54215. module "babylonjs/Engines/thinEngine" {
  54216. interface ThinEngine {
  54217. /**
  54218. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54219. * @param rootUrl defines the url where the file to load is located
  54220. * @param scene defines the current scene
  54221. * @param lodScale defines scale to apply to the mip map selection
  54222. * @param lodOffset defines offset to apply to the mip map selection
  54223. * @param onLoad defines an optional callback raised when the texture is loaded
  54224. * @param onError defines an optional callback raised if there is an issue to load the texture
  54225. * @param format defines the format of the data
  54226. * @param forcedExtension defines the extension to use to pick the right loader
  54227. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54228. * @returns the cube texture as an InternalTexture
  54229. */
  54230. 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;
  54231. }
  54232. }
  54233. }
  54234. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54235. import { Nullable } from "babylonjs/types";
  54236. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54237. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54238. /**
  54239. * Implementation of the DDS Texture Loader.
  54240. * @hidden
  54241. */
  54242. export class _DDSTextureLoader implements IInternalTextureLoader {
  54243. /**
  54244. * Defines wether the loader supports cascade loading the different faces.
  54245. */
  54246. readonly supportCascades: boolean;
  54247. /**
  54248. * This returns if the loader support the current file information.
  54249. * @param extension defines the file extension of the file being loaded
  54250. * @returns true if the loader can load the specified file
  54251. */
  54252. canLoad(extension: string): boolean;
  54253. /**
  54254. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54255. * @param data contains the texture data
  54256. * @param texture defines the BabylonJS internal texture
  54257. * @param createPolynomials will be true if polynomials have been requested
  54258. * @param onLoad defines the callback to trigger once the texture is ready
  54259. * @param onError defines the callback to trigger in case of error
  54260. */
  54261. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54262. /**
  54263. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54264. * @param data contains the texture data
  54265. * @param texture defines the BabylonJS internal texture
  54266. * @param callback defines the method to call once ready to upload
  54267. */
  54268. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54269. }
  54270. }
  54271. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54272. import { Nullable } from "babylonjs/types";
  54273. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54274. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54275. /**
  54276. * Implementation of the ENV Texture Loader.
  54277. * @hidden
  54278. */
  54279. export class _ENVTextureLoader implements IInternalTextureLoader {
  54280. /**
  54281. * Defines wether the loader supports cascade loading the different faces.
  54282. */
  54283. readonly supportCascades: boolean;
  54284. /**
  54285. * This returns if the loader support the current file information.
  54286. * @param extension defines the file extension of the file being loaded
  54287. * @returns true if the loader can load the specified file
  54288. */
  54289. canLoad(extension: string): boolean;
  54290. /**
  54291. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54292. * @param data contains the texture data
  54293. * @param texture defines the BabylonJS internal texture
  54294. * @param createPolynomials will be true if polynomials have been requested
  54295. * @param onLoad defines the callback to trigger once the texture is ready
  54296. * @param onError defines the callback to trigger in case of error
  54297. */
  54298. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54299. /**
  54300. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54301. * @param data contains the texture data
  54302. * @param texture defines the BabylonJS internal texture
  54303. * @param callback defines the method to call once ready to upload
  54304. */
  54305. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54306. }
  54307. }
  54308. declare module "babylonjs/Misc/khronosTextureContainer" {
  54309. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54310. /**
  54311. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54312. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54313. */
  54314. export class KhronosTextureContainer {
  54315. /** contents of the KTX container file */
  54316. data: ArrayBufferView;
  54317. private static HEADER_LEN;
  54318. private static COMPRESSED_2D;
  54319. private static COMPRESSED_3D;
  54320. private static TEX_2D;
  54321. private static TEX_3D;
  54322. /**
  54323. * Gets the openGL type
  54324. */
  54325. glType: number;
  54326. /**
  54327. * Gets the openGL type size
  54328. */
  54329. glTypeSize: number;
  54330. /**
  54331. * Gets the openGL format
  54332. */
  54333. glFormat: number;
  54334. /**
  54335. * Gets the openGL internal format
  54336. */
  54337. glInternalFormat: number;
  54338. /**
  54339. * Gets the base internal format
  54340. */
  54341. glBaseInternalFormat: number;
  54342. /**
  54343. * Gets image width in pixel
  54344. */
  54345. pixelWidth: number;
  54346. /**
  54347. * Gets image height in pixel
  54348. */
  54349. pixelHeight: number;
  54350. /**
  54351. * Gets image depth in pixels
  54352. */
  54353. pixelDepth: number;
  54354. /**
  54355. * Gets the number of array elements
  54356. */
  54357. numberOfArrayElements: number;
  54358. /**
  54359. * Gets the number of faces
  54360. */
  54361. numberOfFaces: number;
  54362. /**
  54363. * Gets the number of mipmap levels
  54364. */
  54365. numberOfMipmapLevels: number;
  54366. /**
  54367. * Gets the bytes of key value data
  54368. */
  54369. bytesOfKeyValueData: number;
  54370. /**
  54371. * Gets the load type
  54372. */
  54373. loadType: number;
  54374. /**
  54375. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54376. */
  54377. isInvalid: boolean;
  54378. /**
  54379. * Creates a new KhronosTextureContainer
  54380. * @param data contents of the KTX container file
  54381. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54382. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54383. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54384. */
  54385. constructor(
  54386. /** contents of the KTX container file */
  54387. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54388. /**
  54389. * Uploads KTX content to a Babylon Texture.
  54390. * It is assumed that the texture has already been created & is currently bound
  54391. * @hidden
  54392. */
  54393. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54394. private _upload2DCompressedLevels;
  54395. /**
  54396. * Checks if the given data starts with a KTX file identifier.
  54397. * @param data the data to check
  54398. * @returns true if the data is a KTX file or false otherwise
  54399. */
  54400. static IsValid(data: ArrayBufferView): boolean;
  54401. }
  54402. }
  54403. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54404. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54405. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54406. /**
  54407. * Class for loading KTX2 files
  54408. * !!! Experimental Extension Subject to Changes !!!
  54409. * @hidden
  54410. */
  54411. export class KhronosTextureContainer2 {
  54412. private static _ModulePromise;
  54413. private static _TranscodeFormat;
  54414. constructor(engine: ThinEngine);
  54415. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54416. private _determineTranscodeFormat;
  54417. /**
  54418. * Checks if the given data starts with a KTX2 file identifier.
  54419. * @param data the data to check
  54420. * @returns true if the data is a KTX2 file or false otherwise
  54421. */
  54422. static IsValid(data: ArrayBufferView): boolean;
  54423. }
  54424. }
  54425. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54426. import { Nullable } from "babylonjs/types";
  54427. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54428. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54429. /**
  54430. * Implementation of the KTX Texture Loader.
  54431. * @hidden
  54432. */
  54433. export class _KTXTextureLoader implements IInternalTextureLoader {
  54434. /**
  54435. * Defines wether the loader supports cascade loading the different faces.
  54436. */
  54437. readonly supportCascades: boolean;
  54438. /**
  54439. * This returns if the loader support the current file information.
  54440. * @param extension defines the file extension of the file being loaded
  54441. * @returns true if the loader can load the specified file
  54442. */
  54443. canLoad(extension: string): boolean;
  54444. /**
  54445. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54446. * @param data contains the texture data
  54447. * @param texture defines the BabylonJS internal texture
  54448. * @param createPolynomials will be true if polynomials have been requested
  54449. * @param onLoad defines the callback to trigger once the texture is ready
  54450. * @param onError defines the callback to trigger in case of error
  54451. */
  54452. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54453. /**
  54454. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54455. * @param data contains the texture data
  54456. * @param texture defines the BabylonJS internal texture
  54457. * @param callback defines the method to call once ready to upload
  54458. */
  54459. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54460. }
  54461. }
  54462. declare module "babylonjs/Helpers/sceneHelpers" {
  54463. import { Nullable } from "babylonjs/types";
  54464. import { Mesh } from "babylonjs/Meshes/mesh";
  54465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54466. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54467. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54468. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54469. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54470. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54471. import "babylonjs/Meshes/Builders/boxBuilder";
  54472. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54473. /** @hidden */
  54474. export var _forceSceneHelpersToBundle: boolean;
  54475. module "babylonjs/scene" {
  54476. interface Scene {
  54477. /**
  54478. * Creates a default light for the scene.
  54479. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54480. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54481. */
  54482. createDefaultLight(replace?: boolean): void;
  54483. /**
  54484. * Creates a default camera for the scene.
  54485. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54486. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54487. * @param replace has default false, when true replaces the active camera in the scene
  54488. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54489. */
  54490. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54491. /**
  54492. * Creates a default camera and a default light.
  54493. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54494. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54495. * @param replace has the default false, when true replaces the active camera/light in the scene
  54496. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54497. */
  54498. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54499. /**
  54500. * Creates a new sky box
  54501. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54502. * @param environmentTexture defines the texture to use as environment texture
  54503. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54504. * @param scale defines the overall scale of the skybox
  54505. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54506. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54507. * @returns a new mesh holding the sky box
  54508. */
  54509. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54510. /**
  54511. * Creates a new environment
  54512. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54513. * @param options defines the options you can use to configure the environment
  54514. * @returns the new EnvironmentHelper
  54515. */
  54516. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54517. /**
  54518. * Creates a new VREXperienceHelper
  54519. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54520. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54521. * @returns a new VREXperienceHelper
  54522. */
  54523. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54524. /**
  54525. * Creates a new WebXRDefaultExperience
  54526. * @see http://doc.babylonjs.com/how_to/webxr
  54527. * @param options experience options
  54528. * @returns a promise for a new WebXRDefaultExperience
  54529. */
  54530. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54531. }
  54532. }
  54533. }
  54534. declare module "babylonjs/Helpers/videoDome" {
  54535. import { Scene } from "babylonjs/scene";
  54536. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54537. import { Mesh } from "babylonjs/Meshes/mesh";
  54538. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54539. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54540. import "babylonjs/Meshes/Builders/sphereBuilder";
  54541. /**
  54542. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54543. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54544. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54545. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54546. */
  54547. export class VideoDome extends TransformNode {
  54548. /**
  54549. * Define the video source as a Monoscopic panoramic 360 video.
  54550. */
  54551. static readonly MODE_MONOSCOPIC: number;
  54552. /**
  54553. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54554. */
  54555. static readonly MODE_TOPBOTTOM: number;
  54556. /**
  54557. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54558. */
  54559. static readonly MODE_SIDEBYSIDE: number;
  54560. private _halfDome;
  54561. private _useDirectMapping;
  54562. /**
  54563. * The video texture being displayed on the sphere
  54564. */
  54565. protected _videoTexture: VideoTexture;
  54566. /**
  54567. * Gets the video texture being displayed on the sphere
  54568. */
  54569. get videoTexture(): VideoTexture;
  54570. /**
  54571. * The skybox material
  54572. */
  54573. protected _material: BackgroundMaterial;
  54574. /**
  54575. * The surface used for the skybox
  54576. */
  54577. protected _mesh: Mesh;
  54578. /**
  54579. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54580. */
  54581. private _halfDomeMask;
  54582. /**
  54583. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54584. * Also see the options.resolution property.
  54585. */
  54586. get fovMultiplier(): number;
  54587. set fovMultiplier(value: number);
  54588. private _videoMode;
  54589. /**
  54590. * Gets or set the current video mode for the video. It can be:
  54591. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54592. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54593. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54594. */
  54595. get videoMode(): number;
  54596. set videoMode(value: number);
  54597. /**
  54598. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54599. *
  54600. */
  54601. get halfDome(): boolean;
  54602. /**
  54603. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54604. */
  54605. set halfDome(enabled: boolean);
  54606. /**
  54607. * Oberserver used in Stereoscopic VR Mode.
  54608. */
  54609. private _onBeforeCameraRenderObserver;
  54610. /**
  54611. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54612. * @param name Element's name, child elements will append suffixes for their own names.
  54613. * @param urlsOrVideo defines the url(s) or the video element to use
  54614. * @param options An object containing optional or exposed sub element properties
  54615. */
  54616. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54617. resolution?: number;
  54618. clickToPlay?: boolean;
  54619. autoPlay?: boolean;
  54620. loop?: boolean;
  54621. size?: number;
  54622. poster?: string;
  54623. faceForward?: boolean;
  54624. useDirectMapping?: boolean;
  54625. halfDomeMode?: boolean;
  54626. }, scene: Scene);
  54627. private _changeVideoMode;
  54628. /**
  54629. * Releases resources associated with this node.
  54630. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54631. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54632. */
  54633. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54634. }
  54635. }
  54636. declare module "babylonjs/Helpers/index" {
  54637. export * from "babylonjs/Helpers/environmentHelper";
  54638. export * from "babylonjs/Helpers/photoDome";
  54639. export * from "babylonjs/Helpers/sceneHelpers";
  54640. export * from "babylonjs/Helpers/videoDome";
  54641. }
  54642. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54643. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54644. import { IDisposable } from "babylonjs/scene";
  54645. import { Engine } from "babylonjs/Engines/engine";
  54646. /**
  54647. * This class can be used to get instrumentation data from a Babylon engine
  54648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54649. */
  54650. export class EngineInstrumentation implements IDisposable {
  54651. /**
  54652. * Define the instrumented engine.
  54653. */
  54654. engine: Engine;
  54655. private _captureGPUFrameTime;
  54656. private _gpuFrameTimeToken;
  54657. private _gpuFrameTime;
  54658. private _captureShaderCompilationTime;
  54659. private _shaderCompilationTime;
  54660. private _onBeginFrameObserver;
  54661. private _onEndFrameObserver;
  54662. private _onBeforeShaderCompilationObserver;
  54663. private _onAfterShaderCompilationObserver;
  54664. /**
  54665. * Gets the perf counter used for GPU frame time
  54666. */
  54667. get gpuFrameTimeCounter(): PerfCounter;
  54668. /**
  54669. * Gets the GPU frame time capture status
  54670. */
  54671. get captureGPUFrameTime(): boolean;
  54672. /**
  54673. * Enable or disable the GPU frame time capture
  54674. */
  54675. set captureGPUFrameTime(value: boolean);
  54676. /**
  54677. * Gets the perf counter used for shader compilation time
  54678. */
  54679. get shaderCompilationTimeCounter(): PerfCounter;
  54680. /**
  54681. * Gets the shader compilation time capture status
  54682. */
  54683. get captureShaderCompilationTime(): boolean;
  54684. /**
  54685. * Enable or disable the shader compilation time capture
  54686. */
  54687. set captureShaderCompilationTime(value: boolean);
  54688. /**
  54689. * Instantiates a new engine instrumentation.
  54690. * This class can be used to get instrumentation data from a Babylon engine
  54691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54692. * @param engine Defines the engine to instrument
  54693. */
  54694. constructor(
  54695. /**
  54696. * Define the instrumented engine.
  54697. */
  54698. engine: Engine);
  54699. /**
  54700. * Dispose and release associated resources.
  54701. */
  54702. dispose(): void;
  54703. }
  54704. }
  54705. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54706. import { Scene, IDisposable } from "babylonjs/scene";
  54707. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54708. /**
  54709. * This class can be used to get instrumentation data from a Babylon engine
  54710. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54711. */
  54712. export class SceneInstrumentation implements IDisposable {
  54713. /**
  54714. * Defines the scene to instrument
  54715. */
  54716. scene: Scene;
  54717. private _captureActiveMeshesEvaluationTime;
  54718. private _activeMeshesEvaluationTime;
  54719. private _captureRenderTargetsRenderTime;
  54720. private _renderTargetsRenderTime;
  54721. private _captureFrameTime;
  54722. private _frameTime;
  54723. private _captureRenderTime;
  54724. private _renderTime;
  54725. private _captureInterFrameTime;
  54726. private _interFrameTime;
  54727. private _captureParticlesRenderTime;
  54728. private _particlesRenderTime;
  54729. private _captureSpritesRenderTime;
  54730. private _spritesRenderTime;
  54731. private _capturePhysicsTime;
  54732. private _physicsTime;
  54733. private _captureAnimationsTime;
  54734. private _animationsTime;
  54735. private _captureCameraRenderTime;
  54736. private _cameraRenderTime;
  54737. private _onBeforeActiveMeshesEvaluationObserver;
  54738. private _onAfterActiveMeshesEvaluationObserver;
  54739. private _onBeforeRenderTargetsRenderObserver;
  54740. private _onAfterRenderTargetsRenderObserver;
  54741. private _onAfterRenderObserver;
  54742. private _onBeforeDrawPhaseObserver;
  54743. private _onAfterDrawPhaseObserver;
  54744. private _onBeforeAnimationsObserver;
  54745. private _onBeforeParticlesRenderingObserver;
  54746. private _onAfterParticlesRenderingObserver;
  54747. private _onBeforeSpritesRenderingObserver;
  54748. private _onAfterSpritesRenderingObserver;
  54749. private _onBeforePhysicsObserver;
  54750. private _onAfterPhysicsObserver;
  54751. private _onAfterAnimationsObserver;
  54752. private _onBeforeCameraRenderObserver;
  54753. private _onAfterCameraRenderObserver;
  54754. /**
  54755. * Gets the perf counter used for active meshes evaluation time
  54756. */
  54757. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54758. /**
  54759. * Gets the active meshes evaluation time capture status
  54760. */
  54761. get captureActiveMeshesEvaluationTime(): boolean;
  54762. /**
  54763. * Enable or disable the active meshes evaluation time capture
  54764. */
  54765. set captureActiveMeshesEvaluationTime(value: boolean);
  54766. /**
  54767. * Gets the perf counter used for render targets render time
  54768. */
  54769. get renderTargetsRenderTimeCounter(): PerfCounter;
  54770. /**
  54771. * Gets the render targets render time capture status
  54772. */
  54773. get captureRenderTargetsRenderTime(): boolean;
  54774. /**
  54775. * Enable or disable the render targets render time capture
  54776. */
  54777. set captureRenderTargetsRenderTime(value: boolean);
  54778. /**
  54779. * Gets the perf counter used for particles render time
  54780. */
  54781. get particlesRenderTimeCounter(): PerfCounter;
  54782. /**
  54783. * Gets the particles render time capture status
  54784. */
  54785. get captureParticlesRenderTime(): boolean;
  54786. /**
  54787. * Enable or disable the particles render time capture
  54788. */
  54789. set captureParticlesRenderTime(value: boolean);
  54790. /**
  54791. * Gets the perf counter used for sprites render time
  54792. */
  54793. get spritesRenderTimeCounter(): PerfCounter;
  54794. /**
  54795. * Gets the sprites render time capture status
  54796. */
  54797. get captureSpritesRenderTime(): boolean;
  54798. /**
  54799. * Enable or disable the sprites render time capture
  54800. */
  54801. set captureSpritesRenderTime(value: boolean);
  54802. /**
  54803. * Gets the perf counter used for physics time
  54804. */
  54805. get physicsTimeCounter(): PerfCounter;
  54806. /**
  54807. * Gets the physics time capture status
  54808. */
  54809. get capturePhysicsTime(): boolean;
  54810. /**
  54811. * Enable or disable the physics time capture
  54812. */
  54813. set capturePhysicsTime(value: boolean);
  54814. /**
  54815. * Gets the perf counter used for animations time
  54816. */
  54817. get animationsTimeCounter(): PerfCounter;
  54818. /**
  54819. * Gets the animations time capture status
  54820. */
  54821. get captureAnimationsTime(): boolean;
  54822. /**
  54823. * Enable or disable the animations time capture
  54824. */
  54825. set captureAnimationsTime(value: boolean);
  54826. /**
  54827. * Gets the perf counter used for frame time capture
  54828. */
  54829. get frameTimeCounter(): PerfCounter;
  54830. /**
  54831. * Gets the frame time capture status
  54832. */
  54833. get captureFrameTime(): boolean;
  54834. /**
  54835. * Enable or disable the frame time capture
  54836. */
  54837. set captureFrameTime(value: boolean);
  54838. /**
  54839. * Gets the perf counter used for inter-frames time capture
  54840. */
  54841. get interFrameTimeCounter(): PerfCounter;
  54842. /**
  54843. * Gets the inter-frames time capture status
  54844. */
  54845. get captureInterFrameTime(): boolean;
  54846. /**
  54847. * Enable or disable the inter-frames time capture
  54848. */
  54849. set captureInterFrameTime(value: boolean);
  54850. /**
  54851. * Gets the perf counter used for render time capture
  54852. */
  54853. get renderTimeCounter(): PerfCounter;
  54854. /**
  54855. * Gets the render time capture status
  54856. */
  54857. get captureRenderTime(): boolean;
  54858. /**
  54859. * Enable or disable the render time capture
  54860. */
  54861. set captureRenderTime(value: boolean);
  54862. /**
  54863. * Gets the perf counter used for camera render time capture
  54864. */
  54865. get cameraRenderTimeCounter(): PerfCounter;
  54866. /**
  54867. * Gets the camera render time capture status
  54868. */
  54869. get captureCameraRenderTime(): boolean;
  54870. /**
  54871. * Enable or disable the camera render time capture
  54872. */
  54873. set captureCameraRenderTime(value: boolean);
  54874. /**
  54875. * Gets the perf counter used for draw calls
  54876. */
  54877. get drawCallsCounter(): PerfCounter;
  54878. /**
  54879. * Instantiates a new scene instrumentation.
  54880. * This class can be used to get instrumentation data from a Babylon engine
  54881. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54882. * @param scene Defines the scene to instrument
  54883. */
  54884. constructor(
  54885. /**
  54886. * Defines the scene to instrument
  54887. */
  54888. scene: Scene);
  54889. /**
  54890. * Dispose and release associated resources.
  54891. */
  54892. dispose(): void;
  54893. }
  54894. }
  54895. declare module "babylonjs/Instrumentation/index" {
  54896. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54897. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54898. export * from "babylonjs/Instrumentation/timeToken";
  54899. }
  54900. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54901. /** @hidden */
  54902. export var glowMapGenerationPixelShader: {
  54903. name: string;
  54904. shader: string;
  54905. };
  54906. }
  54907. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54908. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54909. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54910. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54911. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54912. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54913. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54914. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54915. /** @hidden */
  54916. export var glowMapGenerationVertexShader: {
  54917. name: string;
  54918. shader: string;
  54919. };
  54920. }
  54921. declare module "babylonjs/Layers/effectLayer" {
  54922. import { Observable } from "babylonjs/Misc/observable";
  54923. import { Nullable } from "babylonjs/types";
  54924. import { Camera } from "babylonjs/Cameras/camera";
  54925. import { Scene } from "babylonjs/scene";
  54926. import { ISize } from "babylonjs/Maths/math.size";
  54927. import { Color4 } from "babylonjs/Maths/math.color";
  54928. import { Engine } from "babylonjs/Engines/engine";
  54929. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54931. import { Mesh } from "babylonjs/Meshes/mesh";
  54932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54933. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54934. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54935. import { Effect } from "babylonjs/Materials/effect";
  54936. import { Material } from "babylonjs/Materials/material";
  54937. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54938. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54939. /**
  54940. * Effect layer options. This helps customizing the behaviour
  54941. * of the effect layer.
  54942. */
  54943. export interface IEffectLayerOptions {
  54944. /**
  54945. * Multiplication factor apply to the canvas size to compute the render target size
  54946. * used to generated the objects (the smaller the faster).
  54947. */
  54948. mainTextureRatio: number;
  54949. /**
  54950. * Enforces a fixed size texture to ensure effect stability across devices.
  54951. */
  54952. mainTextureFixedSize?: number;
  54953. /**
  54954. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54955. */
  54956. alphaBlendingMode: number;
  54957. /**
  54958. * The camera attached to the layer.
  54959. */
  54960. camera: Nullable<Camera>;
  54961. /**
  54962. * The rendering group to draw the layer in.
  54963. */
  54964. renderingGroupId: number;
  54965. }
  54966. /**
  54967. * The effect layer Helps adding post process effect blended with the main pass.
  54968. *
  54969. * This can be for instance use to generate glow or higlight effects on the scene.
  54970. *
  54971. * The effect layer class can not be used directly and is intented to inherited from to be
  54972. * customized per effects.
  54973. */
  54974. export abstract class EffectLayer {
  54975. private _vertexBuffers;
  54976. private _indexBuffer;
  54977. private _cachedDefines;
  54978. private _effectLayerMapGenerationEffect;
  54979. private _effectLayerOptions;
  54980. private _mergeEffect;
  54981. protected _scene: Scene;
  54982. protected _engine: Engine;
  54983. protected _maxSize: number;
  54984. protected _mainTextureDesiredSize: ISize;
  54985. protected _mainTexture: RenderTargetTexture;
  54986. protected _shouldRender: boolean;
  54987. protected _postProcesses: PostProcess[];
  54988. protected _textures: BaseTexture[];
  54989. protected _emissiveTextureAndColor: {
  54990. texture: Nullable<BaseTexture>;
  54991. color: Color4;
  54992. };
  54993. /**
  54994. * The name of the layer
  54995. */
  54996. name: string;
  54997. /**
  54998. * The clear color of the texture used to generate the glow map.
  54999. */
  55000. neutralColor: Color4;
  55001. /**
  55002. * Specifies whether the highlight layer is enabled or not.
  55003. */
  55004. isEnabled: boolean;
  55005. /**
  55006. * Gets the camera attached to the layer.
  55007. */
  55008. get camera(): Nullable<Camera>;
  55009. /**
  55010. * Gets the rendering group id the layer should render in.
  55011. */
  55012. get renderingGroupId(): number;
  55013. set renderingGroupId(renderingGroupId: number);
  55014. /**
  55015. * An event triggered when the effect layer has been disposed.
  55016. */
  55017. onDisposeObservable: Observable<EffectLayer>;
  55018. /**
  55019. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55020. */
  55021. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55022. /**
  55023. * An event triggered when the generated texture is being merged in the scene.
  55024. */
  55025. onBeforeComposeObservable: Observable<EffectLayer>;
  55026. /**
  55027. * An event triggered when the mesh is rendered into the effect render target.
  55028. */
  55029. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55030. /**
  55031. * An event triggered after the mesh has been rendered into the effect render target.
  55032. */
  55033. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55034. /**
  55035. * An event triggered when the generated texture has been merged in the scene.
  55036. */
  55037. onAfterComposeObservable: Observable<EffectLayer>;
  55038. /**
  55039. * An event triggered when the efffect layer changes its size.
  55040. */
  55041. onSizeChangedObservable: Observable<EffectLayer>;
  55042. /** @hidden */
  55043. static _SceneComponentInitialization: (scene: Scene) => void;
  55044. /**
  55045. * Instantiates a new effect Layer and references it in the scene.
  55046. * @param name The name of the layer
  55047. * @param scene The scene to use the layer in
  55048. */
  55049. constructor(
  55050. /** The Friendly of the effect in the scene */
  55051. name: string, scene: Scene);
  55052. /**
  55053. * Get the effect name of the layer.
  55054. * @return The effect name
  55055. */
  55056. abstract getEffectName(): string;
  55057. /**
  55058. * Checks for the readiness of the element composing the layer.
  55059. * @param subMesh the mesh to check for
  55060. * @param useInstances specify whether or not to use instances to render the mesh
  55061. * @return true if ready otherwise, false
  55062. */
  55063. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55064. /**
  55065. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55066. * @returns true if the effect requires stencil during the main canvas render pass.
  55067. */
  55068. abstract needStencil(): boolean;
  55069. /**
  55070. * Create the merge effect. This is the shader use to blit the information back
  55071. * to the main canvas at the end of the scene rendering.
  55072. * @returns The effect containing the shader used to merge the effect on the main canvas
  55073. */
  55074. protected abstract _createMergeEffect(): Effect;
  55075. /**
  55076. * Creates the render target textures and post processes used in the effect layer.
  55077. */
  55078. protected abstract _createTextureAndPostProcesses(): void;
  55079. /**
  55080. * Implementation specific of rendering the generating effect on the main canvas.
  55081. * @param effect The effect used to render through
  55082. */
  55083. protected abstract _internalRender(effect: Effect): void;
  55084. /**
  55085. * Sets the required values for both the emissive texture and and the main color.
  55086. */
  55087. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55088. /**
  55089. * Free any resources and references associated to a mesh.
  55090. * Internal use
  55091. * @param mesh The mesh to free.
  55092. */
  55093. abstract _disposeMesh(mesh: Mesh): void;
  55094. /**
  55095. * Serializes this layer (Glow or Highlight for example)
  55096. * @returns a serialized layer object
  55097. */
  55098. abstract serialize?(): any;
  55099. /**
  55100. * Initializes the effect layer with the required options.
  55101. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55102. */
  55103. protected _init(options: Partial<IEffectLayerOptions>): void;
  55104. /**
  55105. * Generates the index buffer of the full screen quad blending to the main canvas.
  55106. */
  55107. private _generateIndexBuffer;
  55108. /**
  55109. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55110. */
  55111. private _generateVertexBuffer;
  55112. /**
  55113. * Sets the main texture desired size which is the closest power of two
  55114. * of the engine canvas size.
  55115. */
  55116. private _setMainTextureSize;
  55117. /**
  55118. * Creates the main texture for the effect layer.
  55119. */
  55120. protected _createMainTexture(): void;
  55121. /**
  55122. * Adds specific effects defines.
  55123. * @param defines The defines to add specifics to.
  55124. */
  55125. protected _addCustomEffectDefines(defines: string[]): void;
  55126. /**
  55127. * Checks for the readiness of the element composing the layer.
  55128. * @param subMesh the mesh to check for
  55129. * @param useInstances specify whether or not to use instances to render the mesh
  55130. * @param emissiveTexture the associated emissive texture used to generate the glow
  55131. * @return true if ready otherwise, false
  55132. */
  55133. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55134. /**
  55135. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55136. */
  55137. render(): void;
  55138. /**
  55139. * Determine if a given mesh will be used in the current effect.
  55140. * @param mesh mesh to test
  55141. * @returns true if the mesh will be used
  55142. */
  55143. hasMesh(mesh: AbstractMesh): boolean;
  55144. /**
  55145. * Returns true if the layer contains information to display, otherwise false.
  55146. * @returns true if the glow layer should be rendered
  55147. */
  55148. shouldRender(): boolean;
  55149. /**
  55150. * Returns true if the mesh should render, otherwise false.
  55151. * @param mesh The mesh to render
  55152. * @returns true if it should render otherwise false
  55153. */
  55154. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55155. /**
  55156. * Returns true if the mesh can be rendered, otherwise false.
  55157. * @param mesh The mesh to render
  55158. * @param material The material used on the mesh
  55159. * @returns true if it can be rendered otherwise false
  55160. */
  55161. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55162. /**
  55163. * Returns true if the mesh should render, otherwise false.
  55164. * @param mesh The mesh to render
  55165. * @returns true if it should render otherwise false
  55166. */
  55167. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55168. /**
  55169. * Renders the submesh passed in parameter to the generation map.
  55170. */
  55171. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55172. /**
  55173. * Defines whether the current material of the mesh should be use to render the effect.
  55174. * @param mesh defines the current mesh to render
  55175. */
  55176. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55177. /**
  55178. * Rebuild the required buffers.
  55179. * @hidden Internal use only.
  55180. */
  55181. _rebuild(): void;
  55182. /**
  55183. * Dispose only the render target textures and post process.
  55184. */
  55185. private _disposeTextureAndPostProcesses;
  55186. /**
  55187. * Dispose the highlight layer and free resources.
  55188. */
  55189. dispose(): void;
  55190. /**
  55191. * Gets the class name of the effect layer
  55192. * @returns the string with the class name of the effect layer
  55193. */
  55194. getClassName(): string;
  55195. /**
  55196. * Creates an effect layer from parsed effect layer data
  55197. * @param parsedEffectLayer defines effect layer data
  55198. * @param scene defines the current scene
  55199. * @param rootUrl defines the root URL containing the effect layer information
  55200. * @returns a parsed effect Layer
  55201. */
  55202. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55203. }
  55204. }
  55205. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55206. import { Scene } from "babylonjs/scene";
  55207. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55208. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55209. import { AbstractScene } from "babylonjs/abstractScene";
  55210. module "babylonjs/abstractScene" {
  55211. interface AbstractScene {
  55212. /**
  55213. * The list of effect layers (highlights/glow) added to the scene
  55214. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55215. * @see http://doc.babylonjs.com/how_to/glow_layer
  55216. */
  55217. effectLayers: Array<EffectLayer>;
  55218. /**
  55219. * Removes the given effect layer from this scene.
  55220. * @param toRemove defines the effect layer to remove
  55221. * @returns the index of the removed effect layer
  55222. */
  55223. removeEffectLayer(toRemove: EffectLayer): number;
  55224. /**
  55225. * Adds the given effect layer to this scene
  55226. * @param newEffectLayer defines the effect layer to add
  55227. */
  55228. addEffectLayer(newEffectLayer: EffectLayer): void;
  55229. }
  55230. }
  55231. /**
  55232. * Defines the layer scene component responsible to manage any effect layers
  55233. * in a given scene.
  55234. */
  55235. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55236. /**
  55237. * The component name helpfull to identify the component in the list of scene components.
  55238. */
  55239. readonly name: string;
  55240. /**
  55241. * The scene the component belongs to.
  55242. */
  55243. scene: Scene;
  55244. private _engine;
  55245. private _renderEffects;
  55246. private _needStencil;
  55247. private _previousStencilState;
  55248. /**
  55249. * Creates a new instance of the component for the given scene
  55250. * @param scene Defines the scene to register the component in
  55251. */
  55252. constructor(scene: Scene);
  55253. /**
  55254. * Registers the component in a given scene
  55255. */
  55256. register(): void;
  55257. /**
  55258. * Rebuilds the elements related to this component in case of
  55259. * context lost for instance.
  55260. */
  55261. rebuild(): void;
  55262. /**
  55263. * Serializes the component data to the specified json object
  55264. * @param serializationObject The object to serialize to
  55265. */
  55266. serialize(serializationObject: any): void;
  55267. /**
  55268. * Adds all the elements from the container to the scene
  55269. * @param container the container holding the elements
  55270. */
  55271. addFromContainer(container: AbstractScene): void;
  55272. /**
  55273. * Removes all the elements in the container from the scene
  55274. * @param container contains the elements to remove
  55275. * @param dispose if the removed element should be disposed (default: false)
  55276. */
  55277. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55278. /**
  55279. * Disposes the component and the associated ressources.
  55280. */
  55281. dispose(): void;
  55282. private _isReadyForMesh;
  55283. private _renderMainTexture;
  55284. private _setStencil;
  55285. private _setStencilBack;
  55286. private _draw;
  55287. private _drawCamera;
  55288. private _drawRenderingGroup;
  55289. }
  55290. }
  55291. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55292. /** @hidden */
  55293. export var glowMapMergePixelShader: {
  55294. name: string;
  55295. shader: string;
  55296. };
  55297. }
  55298. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55299. /** @hidden */
  55300. export var glowMapMergeVertexShader: {
  55301. name: string;
  55302. shader: string;
  55303. };
  55304. }
  55305. declare module "babylonjs/Layers/glowLayer" {
  55306. import { Nullable } from "babylonjs/types";
  55307. import { Camera } from "babylonjs/Cameras/camera";
  55308. import { Scene } from "babylonjs/scene";
  55309. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55311. import { Mesh } from "babylonjs/Meshes/mesh";
  55312. import { Texture } from "babylonjs/Materials/Textures/texture";
  55313. import { Effect } from "babylonjs/Materials/effect";
  55314. import { Material } from "babylonjs/Materials/material";
  55315. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55316. import { Color4 } from "babylonjs/Maths/math.color";
  55317. import "babylonjs/Shaders/glowMapMerge.fragment";
  55318. import "babylonjs/Shaders/glowMapMerge.vertex";
  55319. import "babylonjs/Layers/effectLayerSceneComponent";
  55320. module "babylonjs/abstractScene" {
  55321. interface AbstractScene {
  55322. /**
  55323. * Return a the first highlight layer of the scene with a given name.
  55324. * @param name The name of the highlight layer to look for.
  55325. * @return The highlight layer if found otherwise null.
  55326. */
  55327. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55328. }
  55329. }
  55330. /**
  55331. * Glow layer options. This helps customizing the behaviour
  55332. * of the glow layer.
  55333. */
  55334. export interface IGlowLayerOptions {
  55335. /**
  55336. * Multiplication factor apply to the canvas size to compute the render target size
  55337. * used to generated the glowing objects (the smaller the faster).
  55338. */
  55339. mainTextureRatio: number;
  55340. /**
  55341. * Enforces a fixed size texture to ensure resize independant blur.
  55342. */
  55343. mainTextureFixedSize?: number;
  55344. /**
  55345. * How big is the kernel of the blur texture.
  55346. */
  55347. blurKernelSize: number;
  55348. /**
  55349. * The camera attached to the layer.
  55350. */
  55351. camera: Nullable<Camera>;
  55352. /**
  55353. * Enable MSAA by chosing the number of samples.
  55354. */
  55355. mainTextureSamples?: number;
  55356. /**
  55357. * The rendering group to draw the layer in.
  55358. */
  55359. renderingGroupId: number;
  55360. }
  55361. /**
  55362. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55363. *
  55364. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55365. *
  55366. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55367. */
  55368. export class GlowLayer extends EffectLayer {
  55369. /**
  55370. * Effect Name of the layer.
  55371. */
  55372. static readonly EffectName: string;
  55373. /**
  55374. * The default blur kernel size used for the glow.
  55375. */
  55376. static DefaultBlurKernelSize: number;
  55377. /**
  55378. * The default texture size ratio used for the glow.
  55379. */
  55380. static DefaultTextureRatio: number;
  55381. /**
  55382. * Sets the kernel size of the blur.
  55383. */
  55384. set blurKernelSize(value: number);
  55385. /**
  55386. * Gets the kernel size of the blur.
  55387. */
  55388. get blurKernelSize(): number;
  55389. /**
  55390. * Sets the glow intensity.
  55391. */
  55392. set intensity(value: number);
  55393. /**
  55394. * Gets the glow intensity.
  55395. */
  55396. get intensity(): number;
  55397. private _options;
  55398. private _intensity;
  55399. private _horizontalBlurPostprocess1;
  55400. private _verticalBlurPostprocess1;
  55401. private _horizontalBlurPostprocess2;
  55402. private _verticalBlurPostprocess2;
  55403. private _blurTexture1;
  55404. private _blurTexture2;
  55405. private _postProcesses1;
  55406. private _postProcesses2;
  55407. private _includedOnlyMeshes;
  55408. private _excludedMeshes;
  55409. private _meshesUsingTheirOwnMaterials;
  55410. /**
  55411. * Callback used to let the user override the color selection on a per mesh basis
  55412. */
  55413. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55414. /**
  55415. * Callback used to let the user override the texture selection on a per mesh basis
  55416. */
  55417. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55418. /**
  55419. * Instantiates a new glow Layer and references it to the scene.
  55420. * @param name The name of the layer
  55421. * @param scene The scene to use the layer in
  55422. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55423. */
  55424. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55425. /**
  55426. * Get the effect name of the layer.
  55427. * @return The effect name
  55428. */
  55429. getEffectName(): string;
  55430. /**
  55431. * Create the merge effect. This is the shader use to blit the information back
  55432. * to the main canvas at the end of the scene rendering.
  55433. */
  55434. protected _createMergeEffect(): Effect;
  55435. /**
  55436. * Creates the render target textures and post processes used in the glow layer.
  55437. */
  55438. protected _createTextureAndPostProcesses(): void;
  55439. /**
  55440. * Checks for the readiness of the element composing the layer.
  55441. * @param subMesh the mesh to check for
  55442. * @param useInstances specify wether or not to use instances to render the mesh
  55443. * @param emissiveTexture the associated emissive texture used to generate the glow
  55444. * @return true if ready otherwise, false
  55445. */
  55446. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55447. /**
  55448. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55449. */
  55450. needStencil(): boolean;
  55451. /**
  55452. * Returns true if the mesh can be rendered, otherwise false.
  55453. * @param mesh The mesh to render
  55454. * @param material The material used on the mesh
  55455. * @returns true if it can be rendered otherwise false
  55456. */
  55457. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55458. /**
  55459. * Implementation specific of rendering the generating effect on the main canvas.
  55460. * @param effect The effect used to render through
  55461. */
  55462. protected _internalRender(effect: Effect): void;
  55463. /**
  55464. * Sets the required values for both the emissive texture and and the main color.
  55465. */
  55466. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55467. /**
  55468. * Returns true if the mesh should render, otherwise false.
  55469. * @param mesh The mesh to render
  55470. * @returns true if it should render otherwise false
  55471. */
  55472. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55473. /**
  55474. * Adds specific effects defines.
  55475. * @param defines The defines to add specifics to.
  55476. */
  55477. protected _addCustomEffectDefines(defines: string[]): void;
  55478. /**
  55479. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55480. * @param mesh The mesh to exclude from the glow layer
  55481. */
  55482. addExcludedMesh(mesh: Mesh): void;
  55483. /**
  55484. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55485. * @param mesh The mesh to remove
  55486. */
  55487. removeExcludedMesh(mesh: Mesh): void;
  55488. /**
  55489. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55490. * @param mesh The mesh to include in the glow layer
  55491. */
  55492. addIncludedOnlyMesh(mesh: Mesh): void;
  55493. /**
  55494. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55495. * @param mesh The mesh to remove
  55496. */
  55497. removeIncludedOnlyMesh(mesh: Mesh): void;
  55498. /**
  55499. * Determine if a given mesh will be used in the glow layer
  55500. * @param mesh The mesh to test
  55501. * @returns true if the mesh will be highlighted by the current glow layer
  55502. */
  55503. hasMesh(mesh: AbstractMesh): boolean;
  55504. /**
  55505. * Defines whether the current material of the mesh should be use to render the effect.
  55506. * @param mesh defines the current mesh to render
  55507. */
  55508. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55509. /**
  55510. * Add a mesh to be rendered through its own material and not with emissive only.
  55511. * @param mesh The mesh for which we need to use its material
  55512. */
  55513. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55514. /**
  55515. * Remove a mesh from being rendered through its own material and not with emissive only.
  55516. * @param mesh The mesh for which we need to not use its material
  55517. */
  55518. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55519. /**
  55520. * Free any resources and references associated to a mesh.
  55521. * Internal use
  55522. * @param mesh The mesh to free.
  55523. * @hidden
  55524. */
  55525. _disposeMesh(mesh: Mesh): void;
  55526. /**
  55527. * Gets the class name of the effect layer
  55528. * @returns the string with the class name of the effect layer
  55529. */
  55530. getClassName(): string;
  55531. /**
  55532. * Serializes this glow layer
  55533. * @returns a serialized glow layer object
  55534. */
  55535. serialize(): any;
  55536. /**
  55537. * Creates a Glow Layer from parsed glow layer data
  55538. * @param parsedGlowLayer defines glow layer data
  55539. * @param scene defines the current scene
  55540. * @param rootUrl defines the root URL containing the glow layer information
  55541. * @returns a parsed Glow Layer
  55542. */
  55543. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55544. }
  55545. }
  55546. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55547. /** @hidden */
  55548. export var glowBlurPostProcessPixelShader: {
  55549. name: string;
  55550. shader: string;
  55551. };
  55552. }
  55553. declare module "babylonjs/Layers/highlightLayer" {
  55554. import { Observable } from "babylonjs/Misc/observable";
  55555. import { Nullable } from "babylonjs/types";
  55556. import { Camera } from "babylonjs/Cameras/camera";
  55557. import { Scene } from "babylonjs/scene";
  55558. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55560. import { Mesh } from "babylonjs/Meshes/mesh";
  55561. import { Effect } from "babylonjs/Materials/effect";
  55562. import { Material } from "babylonjs/Materials/material";
  55563. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55564. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55565. import "babylonjs/Shaders/glowMapMerge.fragment";
  55566. import "babylonjs/Shaders/glowMapMerge.vertex";
  55567. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55568. module "babylonjs/abstractScene" {
  55569. interface AbstractScene {
  55570. /**
  55571. * Return a the first highlight layer of the scene with a given name.
  55572. * @param name The name of the highlight layer to look for.
  55573. * @return The highlight layer if found otherwise null.
  55574. */
  55575. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55576. }
  55577. }
  55578. /**
  55579. * Highlight layer options. This helps customizing the behaviour
  55580. * of the highlight layer.
  55581. */
  55582. export interface IHighlightLayerOptions {
  55583. /**
  55584. * Multiplication factor apply to the canvas size to compute the render target size
  55585. * used to generated the glowing objects (the smaller the faster).
  55586. */
  55587. mainTextureRatio: number;
  55588. /**
  55589. * Enforces a fixed size texture to ensure resize independant blur.
  55590. */
  55591. mainTextureFixedSize?: number;
  55592. /**
  55593. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55594. * of the picture to blur (the smaller the faster).
  55595. */
  55596. blurTextureSizeRatio: number;
  55597. /**
  55598. * How big in texel of the blur texture is the vertical blur.
  55599. */
  55600. blurVerticalSize: number;
  55601. /**
  55602. * How big in texel of the blur texture is the horizontal blur.
  55603. */
  55604. blurHorizontalSize: number;
  55605. /**
  55606. * Alpha blending mode used to apply the blur. Default is combine.
  55607. */
  55608. alphaBlendingMode: number;
  55609. /**
  55610. * The camera attached to the layer.
  55611. */
  55612. camera: Nullable<Camera>;
  55613. /**
  55614. * Should we display highlight as a solid stroke?
  55615. */
  55616. isStroke?: boolean;
  55617. /**
  55618. * The rendering group to draw the layer in.
  55619. */
  55620. renderingGroupId: number;
  55621. }
  55622. /**
  55623. * The highlight layer Helps adding a glow effect around a mesh.
  55624. *
  55625. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55626. * glowy meshes to your scene.
  55627. *
  55628. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55629. */
  55630. export class HighlightLayer extends EffectLayer {
  55631. name: string;
  55632. /**
  55633. * Effect Name of the highlight layer.
  55634. */
  55635. static readonly EffectName: string;
  55636. /**
  55637. * The neutral color used during the preparation of the glow effect.
  55638. * This is black by default as the blend operation is a blend operation.
  55639. */
  55640. static NeutralColor: Color4;
  55641. /**
  55642. * Stencil value used for glowing meshes.
  55643. */
  55644. static GlowingMeshStencilReference: number;
  55645. /**
  55646. * Stencil value used for the other meshes in the scene.
  55647. */
  55648. static NormalMeshStencilReference: number;
  55649. /**
  55650. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55651. */
  55652. innerGlow: boolean;
  55653. /**
  55654. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55655. */
  55656. outerGlow: boolean;
  55657. /**
  55658. * Specifies the horizontal size of the blur.
  55659. */
  55660. set blurHorizontalSize(value: number);
  55661. /**
  55662. * Specifies the vertical size of the blur.
  55663. */
  55664. set blurVerticalSize(value: number);
  55665. /**
  55666. * Gets the horizontal size of the blur.
  55667. */
  55668. get blurHorizontalSize(): number;
  55669. /**
  55670. * Gets the vertical size of the blur.
  55671. */
  55672. get blurVerticalSize(): number;
  55673. /**
  55674. * An event triggered when the highlight layer is being blurred.
  55675. */
  55676. onBeforeBlurObservable: Observable<HighlightLayer>;
  55677. /**
  55678. * An event triggered when the highlight layer has been blurred.
  55679. */
  55680. onAfterBlurObservable: Observable<HighlightLayer>;
  55681. private _instanceGlowingMeshStencilReference;
  55682. private _options;
  55683. private _downSamplePostprocess;
  55684. private _horizontalBlurPostprocess;
  55685. private _verticalBlurPostprocess;
  55686. private _blurTexture;
  55687. private _meshes;
  55688. private _excludedMeshes;
  55689. /**
  55690. * Instantiates a new highlight Layer and references it to the scene..
  55691. * @param name The name of the layer
  55692. * @param scene The scene to use the layer in
  55693. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55694. */
  55695. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55696. /**
  55697. * Get the effect name of the layer.
  55698. * @return The effect name
  55699. */
  55700. getEffectName(): string;
  55701. /**
  55702. * Create the merge effect. This is the shader use to blit the information back
  55703. * to the main canvas at the end of the scene rendering.
  55704. */
  55705. protected _createMergeEffect(): Effect;
  55706. /**
  55707. * Creates the render target textures and post processes used in the highlight layer.
  55708. */
  55709. protected _createTextureAndPostProcesses(): void;
  55710. /**
  55711. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55712. */
  55713. needStencil(): boolean;
  55714. /**
  55715. * Checks for the readiness of the element composing the layer.
  55716. * @param subMesh the mesh to check for
  55717. * @param useInstances specify wether or not to use instances to render the mesh
  55718. * @param emissiveTexture the associated emissive texture used to generate the glow
  55719. * @return true if ready otherwise, false
  55720. */
  55721. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55722. /**
  55723. * Implementation specific of rendering the generating effect on the main canvas.
  55724. * @param effect The effect used to render through
  55725. */
  55726. protected _internalRender(effect: Effect): void;
  55727. /**
  55728. * Returns true if the layer contains information to display, otherwise false.
  55729. */
  55730. shouldRender(): boolean;
  55731. /**
  55732. * Returns true if the mesh should render, otherwise false.
  55733. * @param mesh The mesh to render
  55734. * @returns true if it should render otherwise false
  55735. */
  55736. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55737. /**
  55738. * Sets the required values for both the emissive texture and and the main color.
  55739. */
  55740. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55741. /**
  55742. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55743. * @param mesh The mesh to exclude from the highlight layer
  55744. */
  55745. addExcludedMesh(mesh: Mesh): void;
  55746. /**
  55747. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55748. * @param mesh The mesh to highlight
  55749. */
  55750. removeExcludedMesh(mesh: Mesh): void;
  55751. /**
  55752. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55753. * @param mesh mesh to test
  55754. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55755. */
  55756. hasMesh(mesh: AbstractMesh): boolean;
  55757. /**
  55758. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55759. * @param mesh The mesh to highlight
  55760. * @param color The color of the highlight
  55761. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55762. */
  55763. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55764. /**
  55765. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55766. * @param mesh The mesh to highlight
  55767. */
  55768. removeMesh(mesh: Mesh): void;
  55769. /**
  55770. * Remove all the meshes currently referenced in the highlight layer
  55771. */
  55772. removeAllMeshes(): void;
  55773. /**
  55774. * Force the stencil to the normal expected value for none glowing parts
  55775. */
  55776. private _defaultStencilReference;
  55777. /**
  55778. * Free any resources and references associated to a mesh.
  55779. * Internal use
  55780. * @param mesh The mesh to free.
  55781. * @hidden
  55782. */
  55783. _disposeMesh(mesh: Mesh): void;
  55784. /**
  55785. * Dispose the highlight layer and free resources.
  55786. */
  55787. dispose(): void;
  55788. /**
  55789. * Gets the class name of the effect layer
  55790. * @returns the string with the class name of the effect layer
  55791. */
  55792. getClassName(): string;
  55793. /**
  55794. * Serializes this Highlight layer
  55795. * @returns a serialized Highlight layer object
  55796. */
  55797. serialize(): any;
  55798. /**
  55799. * Creates a Highlight layer from parsed Highlight layer data
  55800. * @param parsedHightlightLayer defines the Highlight layer data
  55801. * @param scene defines the current scene
  55802. * @param rootUrl defines the root URL containing the Highlight layer information
  55803. * @returns a parsed Highlight layer
  55804. */
  55805. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55806. }
  55807. }
  55808. declare module "babylonjs/Layers/layerSceneComponent" {
  55809. import { Scene } from "babylonjs/scene";
  55810. import { ISceneComponent } from "babylonjs/sceneComponent";
  55811. import { Layer } from "babylonjs/Layers/layer";
  55812. import { AbstractScene } from "babylonjs/abstractScene";
  55813. module "babylonjs/abstractScene" {
  55814. interface AbstractScene {
  55815. /**
  55816. * The list of layers (background and foreground) of the scene
  55817. */
  55818. layers: Array<Layer>;
  55819. }
  55820. }
  55821. /**
  55822. * Defines the layer scene component responsible to manage any layers
  55823. * in a given scene.
  55824. */
  55825. export class LayerSceneComponent implements ISceneComponent {
  55826. /**
  55827. * The component name helpfull to identify the component in the list of scene components.
  55828. */
  55829. readonly name: string;
  55830. /**
  55831. * The scene the component belongs to.
  55832. */
  55833. scene: Scene;
  55834. private _engine;
  55835. /**
  55836. * Creates a new instance of the component for the given scene
  55837. * @param scene Defines the scene to register the component in
  55838. */
  55839. constructor(scene: Scene);
  55840. /**
  55841. * Registers the component in a given scene
  55842. */
  55843. register(): void;
  55844. /**
  55845. * Rebuilds the elements related to this component in case of
  55846. * context lost for instance.
  55847. */
  55848. rebuild(): void;
  55849. /**
  55850. * Disposes the component and the associated ressources.
  55851. */
  55852. dispose(): void;
  55853. private _draw;
  55854. private _drawCameraPredicate;
  55855. private _drawCameraBackground;
  55856. private _drawCameraForeground;
  55857. private _drawRenderTargetPredicate;
  55858. private _drawRenderTargetBackground;
  55859. private _drawRenderTargetForeground;
  55860. /**
  55861. * Adds all the elements from the container to the scene
  55862. * @param container the container holding the elements
  55863. */
  55864. addFromContainer(container: AbstractScene): void;
  55865. /**
  55866. * Removes all the elements in the container from the scene
  55867. * @param container contains the elements to remove
  55868. * @param dispose if the removed element should be disposed (default: false)
  55869. */
  55870. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55871. }
  55872. }
  55873. declare module "babylonjs/Shaders/layer.fragment" {
  55874. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55875. /** @hidden */
  55876. export var layerPixelShader: {
  55877. name: string;
  55878. shader: string;
  55879. };
  55880. }
  55881. declare module "babylonjs/Shaders/layer.vertex" {
  55882. /** @hidden */
  55883. export var layerVertexShader: {
  55884. name: string;
  55885. shader: string;
  55886. };
  55887. }
  55888. declare module "babylonjs/Layers/layer" {
  55889. import { Observable } from "babylonjs/Misc/observable";
  55890. import { Nullable } from "babylonjs/types";
  55891. import { Scene } from "babylonjs/scene";
  55892. import { Vector2 } from "babylonjs/Maths/math.vector";
  55893. import { Color4 } from "babylonjs/Maths/math.color";
  55894. import { Texture } from "babylonjs/Materials/Textures/texture";
  55895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55896. import "babylonjs/Shaders/layer.fragment";
  55897. import "babylonjs/Shaders/layer.vertex";
  55898. /**
  55899. * This represents a full screen 2d layer.
  55900. * This can be useful to display a picture in the background of your scene for instance.
  55901. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55902. */
  55903. export class Layer {
  55904. /**
  55905. * Define the name of the layer.
  55906. */
  55907. name: string;
  55908. /**
  55909. * Define the texture the layer should display.
  55910. */
  55911. texture: Nullable<Texture>;
  55912. /**
  55913. * Is the layer in background or foreground.
  55914. */
  55915. isBackground: boolean;
  55916. /**
  55917. * Define the color of the layer (instead of texture).
  55918. */
  55919. color: Color4;
  55920. /**
  55921. * Define the scale of the layer in order to zoom in out of the texture.
  55922. */
  55923. scale: Vector2;
  55924. /**
  55925. * Define an offset for the layer in order to shift the texture.
  55926. */
  55927. offset: Vector2;
  55928. /**
  55929. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55930. */
  55931. alphaBlendingMode: number;
  55932. /**
  55933. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55934. * Alpha test will not mix with the background color in case of transparency.
  55935. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55936. */
  55937. alphaTest: boolean;
  55938. /**
  55939. * Define a mask to restrict the layer to only some of the scene cameras.
  55940. */
  55941. layerMask: number;
  55942. /**
  55943. * Define the list of render target the layer is visible into.
  55944. */
  55945. renderTargetTextures: RenderTargetTexture[];
  55946. /**
  55947. * Define if the layer is only used in renderTarget or if it also
  55948. * renders in the main frame buffer of the canvas.
  55949. */
  55950. renderOnlyInRenderTargetTextures: boolean;
  55951. private _scene;
  55952. private _vertexBuffers;
  55953. private _indexBuffer;
  55954. private _effect;
  55955. private _previousDefines;
  55956. /**
  55957. * An event triggered when the layer is disposed.
  55958. */
  55959. onDisposeObservable: Observable<Layer>;
  55960. private _onDisposeObserver;
  55961. /**
  55962. * Back compatibility with callback before the onDisposeObservable existed.
  55963. * The set callback will be triggered when the layer has been disposed.
  55964. */
  55965. set onDispose(callback: () => void);
  55966. /**
  55967. * An event triggered before rendering the scene
  55968. */
  55969. onBeforeRenderObservable: Observable<Layer>;
  55970. private _onBeforeRenderObserver;
  55971. /**
  55972. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55973. * The set callback will be triggered just before rendering the layer.
  55974. */
  55975. set onBeforeRender(callback: () => void);
  55976. /**
  55977. * An event triggered after rendering the scene
  55978. */
  55979. onAfterRenderObservable: Observable<Layer>;
  55980. private _onAfterRenderObserver;
  55981. /**
  55982. * Back compatibility with callback before the onAfterRenderObservable existed.
  55983. * The set callback will be triggered just after rendering the layer.
  55984. */
  55985. set onAfterRender(callback: () => void);
  55986. /**
  55987. * Instantiates a new layer.
  55988. * This represents a full screen 2d layer.
  55989. * This can be useful to display a picture in the background of your scene for instance.
  55990. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55991. * @param name Define the name of the layer in the scene
  55992. * @param imgUrl Define the url of the texture to display in the layer
  55993. * @param scene Define the scene the layer belongs to
  55994. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55995. * @param color Defines a color for the layer
  55996. */
  55997. constructor(
  55998. /**
  55999. * Define the name of the layer.
  56000. */
  56001. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56002. private _createIndexBuffer;
  56003. /** @hidden */
  56004. _rebuild(): void;
  56005. /**
  56006. * Renders the layer in the scene.
  56007. */
  56008. render(): void;
  56009. /**
  56010. * Disposes and releases the associated ressources.
  56011. */
  56012. dispose(): void;
  56013. }
  56014. }
  56015. declare module "babylonjs/Layers/index" {
  56016. export * from "babylonjs/Layers/effectLayer";
  56017. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56018. export * from "babylonjs/Layers/glowLayer";
  56019. export * from "babylonjs/Layers/highlightLayer";
  56020. export * from "babylonjs/Layers/layer";
  56021. export * from "babylonjs/Layers/layerSceneComponent";
  56022. }
  56023. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56024. /** @hidden */
  56025. export var lensFlarePixelShader: {
  56026. name: string;
  56027. shader: string;
  56028. };
  56029. }
  56030. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56031. /** @hidden */
  56032. export var lensFlareVertexShader: {
  56033. name: string;
  56034. shader: string;
  56035. };
  56036. }
  56037. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56038. import { Scene } from "babylonjs/scene";
  56039. import { Vector3 } from "babylonjs/Maths/math.vector";
  56040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56041. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56042. import "babylonjs/Shaders/lensFlare.fragment";
  56043. import "babylonjs/Shaders/lensFlare.vertex";
  56044. import { Viewport } from "babylonjs/Maths/math.viewport";
  56045. /**
  56046. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56047. * It is usually composed of several `lensFlare`.
  56048. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56049. */
  56050. export class LensFlareSystem {
  56051. /**
  56052. * Define the name of the lens flare system
  56053. */
  56054. name: string;
  56055. /**
  56056. * List of lens flares used in this system.
  56057. */
  56058. lensFlares: LensFlare[];
  56059. /**
  56060. * Define a limit from the border the lens flare can be visible.
  56061. */
  56062. borderLimit: number;
  56063. /**
  56064. * Define a viewport border we do not want to see the lens flare in.
  56065. */
  56066. viewportBorder: number;
  56067. /**
  56068. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56069. */
  56070. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56071. /**
  56072. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56073. */
  56074. layerMask: number;
  56075. /**
  56076. * Define the id of the lens flare system in the scene.
  56077. * (equal to name by default)
  56078. */
  56079. id: string;
  56080. private _scene;
  56081. private _emitter;
  56082. private _vertexBuffers;
  56083. private _indexBuffer;
  56084. private _effect;
  56085. private _positionX;
  56086. private _positionY;
  56087. private _isEnabled;
  56088. /** @hidden */
  56089. static _SceneComponentInitialization: (scene: Scene) => void;
  56090. /**
  56091. * Instantiates a lens flare system.
  56092. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56093. * It is usually composed of several `lensFlare`.
  56094. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56095. * @param name Define the name of the lens flare system in the scene
  56096. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56097. * @param scene Define the scene the lens flare system belongs to
  56098. */
  56099. constructor(
  56100. /**
  56101. * Define the name of the lens flare system
  56102. */
  56103. name: string, emitter: any, scene: Scene);
  56104. /**
  56105. * Define if the lens flare system is enabled.
  56106. */
  56107. get isEnabled(): boolean;
  56108. set isEnabled(value: boolean);
  56109. /**
  56110. * Get the scene the effects belongs to.
  56111. * @returns the scene holding the lens flare system
  56112. */
  56113. getScene(): Scene;
  56114. /**
  56115. * Get the emitter of the lens flare system.
  56116. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56117. * @returns the emitter of the lens flare system
  56118. */
  56119. getEmitter(): any;
  56120. /**
  56121. * Set the emitter of the lens flare system.
  56122. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56123. * @param newEmitter Define the new emitter of the system
  56124. */
  56125. setEmitter(newEmitter: any): void;
  56126. /**
  56127. * Get the lens flare system emitter position.
  56128. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56129. * @returns the position
  56130. */
  56131. getEmitterPosition(): Vector3;
  56132. /**
  56133. * @hidden
  56134. */
  56135. computeEffectivePosition(globalViewport: Viewport): boolean;
  56136. /** @hidden */
  56137. _isVisible(): boolean;
  56138. /**
  56139. * @hidden
  56140. */
  56141. render(): boolean;
  56142. /**
  56143. * Dispose and release the lens flare with its associated resources.
  56144. */
  56145. dispose(): void;
  56146. /**
  56147. * Parse a lens flare system from a JSON repressentation
  56148. * @param parsedLensFlareSystem Define the JSON to parse
  56149. * @param scene Define the scene the parsed system should be instantiated in
  56150. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56151. * @returns the parsed system
  56152. */
  56153. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56154. /**
  56155. * Serialize the current Lens Flare System into a JSON representation.
  56156. * @returns the serialized JSON
  56157. */
  56158. serialize(): any;
  56159. }
  56160. }
  56161. declare module "babylonjs/LensFlares/lensFlare" {
  56162. import { Nullable } from "babylonjs/types";
  56163. import { Color3 } from "babylonjs/Maths/math.color";
  56164. import { Texture } from "babylonjs/Materials/Textures/texture";
  56165. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56166. /**
  56167. * This represents one of the lens effect in a `lensFlareSystem`.
  56168. * It controls one of the indiviual texture used in the effect.
  56169. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56170. */
  56171. export class LensFlare {
  56172. /**
  56173. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56174. */
  56175. size: number;
  56176. /**
  56177. * 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.
  56178. */
  56179. position: number;
  56180. /**
  56181. * Define the lens color.
  56182. */
  56183. color: Color3;
  56184. /**
  56185. * Define the lens texture.
  56186. */
  56187. texture: Nullable<Texture>;
  56188. /**
  56189. * Define the alpha mode to render this particular lens.
  56190. */
  56191. alphaMode: number;
  56192. private _system;
  56193. /**
  56194. * Creates a new Lens Flare.
  56195. * This represents one of the lens effect in a `lensFlareSystem`.
  56196. * It controls one of the indiviual texture used in the effect.
  56197. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56198. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56199. * @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.
  56200. * @param color Define the lens color
  56201. * @param imgUrl Define the lens texture url
  56202. * @param system Define the `lensFlareSystem` this flare is part of
  56203. * @returns The newly created Lens Flare
  56204. */
  56205. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56206. /**
  56207. * Instantiates a new Lens Flare.
  56208. * This represents one of the lens effect in a `lensFlareSystem`.
  56209. * It controls one of the indiviual texture used in the effect.
  56210. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56211. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56212. * @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.
  56213. * @param color Define the lens color
  56214. * @param imgUrl Define the lens texture url
  56215. * @param system Define the `lensFlareSystem` this flare is part of
  56216. */
  56217. constructor(
  56218. /**
  56219. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56220. */
  56221. size: number,
  56222. /**
  56223. * 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.
  56224. */
  56225. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56226. /**
  56227. * Dispose and release the lens flare with its associated resources.
  56228. */
  56229. dispose(): void;
  56230. }
  56231. }
  56232. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56233. import { Nullable } from "babylonjs/types";
  56234. import { Scene } from "babylonjs/scene";
  56235. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56236. import { AbstractScene } from "babylonjs/abstractScene";
  56237. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56238. module "babylonjs/abstractScene" {
  56239. interface AbstractScene {
  56240. /**
  56241. * The list of lens flare system added to the scene
  56242. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56243. */
  56244. lensFlareSystems: Array<LensFlareSystem>;
  56245. /**
  56246. * Removes the given lens flare system from this scene.
  56247. * @param toRemove The lens flare system to remove
  56248. * @returns The index of the removed lens flare system
  56249. */
  56250. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56251. /**
  56252. * Adds the given lens flare system to this scene
  56253. * @param newLensFlareSystem The lens flare system to add
  56254. */
  56255. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56256. /**
  56257. * Gets a lens flare system using its name
  56258. * @param name defines the name to look for
  56259. * @returns the lens flare system or null if not found
  56260. */
  56261. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56262. /**
  56263. * Gets a lens flare system using its id
  56264. * @param id defines the id to look for
  56265. * @returns the lens flare system or null if not found
  56266. */
  56267. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56268. }
  56269. }
  56270. /**
  56271. * Defines the lens flare scene component responsible to manage any lens flares
  56272. * in a given scene.
  56273. */
  56274. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56275. /**
  56276. * The component name helpfull to identify the component in the list of scene components.
  56277. */
  56278. readonly name: string;
  56279. /**
  56280. * The scene the component belongs to.
  56281. */
  56282. scene: Scene;
  56283. /**
  56284. * Creates a new instance of the component for the given scene
  56285. * @param scene Defines the scene to register the component in
  56286. */
  56287. constructor(scene: Scene);
  56288. /**
  56289. * Registers the component in a given scene
  56290. */
  56291. register(): void;
  56292. /**
  56293. * Rebuilds the elements related to this component in case of
  56294. * context lost for instance.
  56295. */
  56296. rebuild(): void;
  56297. /**
  56298. * Adds all the elements from the container to the scene
  56299. * @param container the container holding the elements
  56300. */
  56301. addFromContainer(container: AbstractScene): void;
  56302. /**
  56303. * Removes all the elements in the container from the scene
  56304. * @param container contains the elements to remove
  56305. * @param dispose if the removed element should be disposed (default: false)
  56306. */
  56307. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56308. /**
  56309. * Serializes the component data to the specified json object
  56310. * @param serializationObject The object to serialize to
  56311. */
  56312. serialize(serializationObject: any): void;
  56313. /**
  56314. * Disposes the component and the associated ressources.
  56315. */
  56316. dispose(): void;
  56317. private _draw;
  56318. }
  56319. }
  56320. declare module "babylonjs/LensFlares/index" {
  56321. export * from "babylonjs/LensFlares/lensFlare";
  56322. export * from "babylonjs/LensFlares/lensFlareSystem";
  56323. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56324. }
  56325. declare module "babylonjs/Shaders/depth.fragment" {
  56326. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56327. /** @hidden */
  56328. export var depthPixelShader: {
  56329. name: string;
  56330. shader: string;
  56331. };
  56332. }
  56333. declare module "babylonjs/Shaders/depth.vertex" {
  56334. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56335. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56336. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56337. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56338. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56339. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56340. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56341. /** @hidden */
  56342. export var depthVertexShader: {
  56343. name: string;
  56344. shader: string;
  56345. };
  56346. }
  56347. declare module "babylonjs/Rendering/depthRenderer" {
  56348. import { Nullable } from "babylonjs/types";
  56349. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56350. import { Scene } from "babylonjs/scene";
  56351. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56352. import { Camera } from "babylonjs/Cameras/camera";
  56353. import "babylonjs/Shaders/depth.fragment";
  56354. import "babylonjs/Shaders/depth.vertex";
  56355. /**
  56356. * This represents a depth renderer in Babylon.
  56357. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56358. */
  56359. export class DepthRenderer {
  56360. private _scene;
  56361. private _depthMap;
  56362. private _effect;
  56363. private readonly _storeNonLinearDepth;
  56364. private readonly _clearColor;
  56365. /** Get if the depth renderer is using packed depth or not */
  56366. readonly isPacked: boolean;
  56367. private _cachedDefines;
  56368. private _camera;
  56369. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56370. enabled: boolean;
  56371. /**
  56372. * Specifiess that the depth renderer will only be used within
  56373. * the camera it is created for.
  56374. * This can help forcing its rendering during the camera processing.
  56375. */
  56376. useOnlyInActiveCamera: boolean;
  56377. /** @hidden */
  56378. static _SceneComponentInitialization: (scene: Scene) => void;
  56379. /**
  56380. * Instantiates a depth renderer
  56381. * @param scene The scene the renderer belongs to
  56382. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56383. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56384. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56385. */
  56386. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56387. /**
  56388. * Creates the depth rendering effect and checks if the effect is ready.
  56389. * @param subMesh The submesh to be used to render the depth map of
  56390. * @param useInstances If multiple world instances should be used
  56391. * @returns if the depth renderer is ready to render the depth map
  56392. */
  56393. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56394. /**
  56395. * Gets the texture which the depth map will be written to.
  56396. * @returns The depth map texture
  56397. */
  56398. getDepthMap(): RenderTargetTexture;
  56399. /**
  56400. * Disposes of the depth renderer.
  56401. */
  56402. dispose(): void;
  56403. }
  56404. }
  56405. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56406. /** @hidden */
  56407. export var minmaxReduxPixelShader: {
  56408. name: string;
  56409. shader: string;
  56410. };
  56411. }
  56412. declare module "babylonjs/Misc/minMaxReducer" {
  56413. import { Nullable } from "babylonjs/types";
  56414. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56415. import { Camera } from "babylonjs/Cameras/camera";
  56416. import { Observer } from "babylonjs/Misc/observable";
  56417. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56418. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56419. import { Observable } from "babylonjs/Misc/observable";
  56420. import "babylonjs/Shaders/minmaxRedux.fragment";
  56421. /**
  56422. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56423. * and maximum values from all values of the texture.
  56424. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56425. * The source values are read from the red channel of the texture.
  56426. */
  56427. export class MinMaxReducer {
  56428. /**
  56429. * Observable triggered when the computation has been performed
  56430. */
  56431. onAfterReductionPerformed: Observable<{
  56432. min: number;
  56433. max: number;
  56434. }>;
  56435. protected _camera: Camera;
  56436. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56437. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56438. protected _postProcessManager: PostProcessManager;
  56439. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56440. protected _forceFullscreenViewport: boolean;
  56441. /**
  56442. * Creates a min/max reducer
  56443. * @param camera The camera to use for the post processes
  56444. */
  56445. constructor(camera: Camera);
  56446. /**
  56447. * Gets the texture used to read the values from.
  56448. */
  56449. get sourceTexture(): Nullable<RenderTargetTexture>;
  56450. /**
  56451. * Sets the source texture to read the values from.
  56452. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56453. * because in such textures '1' value must not be taken into account to compute the maximum
  56454. * as this value is used to clear the texture.
  56455. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56456. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56457. * @param depthRedux Indicates if the texture is a depth texture or not
  56458. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56459. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56460. */
  56461. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56462. /**
  56463. * Defines the refresh rate of the computation.
  56464. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56465. */
  56466. get refreshRate(): number;
  56467. set refreshRate(value: number);
  56468. protected _activated: boolean;
  56469. /**
  56470. * Gets the activation status of the reducer
  56471. */
  56472. get activated(): boolean;
  56473. /**
  56474. * Activates the reduction computation.
  56475. * When activated, the observers registered in onAfterReductionPerformed are
  56476. * called after the compuation is performed
  56477. */
  56478. activate(): void;
  56479. /**
  56480. * Deactivates the reduction computation.
  56481. */
  56482. deactivate(): void;
  56483. /**
  56484. * Disposes the min/max reducer
  56485. * @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.
  56486. */
  56487. dispose(disposeAll?: boolean): void;
  56488. }
  56489. }
  56490. declare module "babylonjs/Misc/depthReducer" {
  56491. import { Nullable } from "babylonjs/types";
  56492. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56493. import { Camera } from "babylonjs/Cameras/camera";
  56494. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56495. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56496. /**
  56497. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56498. */
  56499. export class DepthReducer extends MinMaxReducer {
  56500. private _depthRenderer;
  56501. private _depthRendererId;
  56502. /**
  56503. * Gets the depth renderer used for the computation.
  56504. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56505. */
  56506. get depthRenderer(): Nullable<DepthRenderer>;
  56507. /**
  56508. * Creates a depth reducer
  56509. * @param camera The camera used to render the depth texture
  56510. */
  56511. constructor(camera: Camera);
  56512. /**
  56513. * Sets the depth renderer to use to generate the depth map
  56514. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56515. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56516. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56517. */
  56518. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56519. /** @hidden */
  56520. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56521. /**
  56522. * Activates the reduction computation.
  56523. * When activated, the observers registered in onAfterReductionPerformed are
  56524. * called after the compuation is performed
  56525. */
  56526. activate(): void;
  56527. /**
  56528. * Deactivates the reduction computation.
  56529. */
  56530. deactivate(): void;
  56531. /**
  56532. * Disposes the depth reducer
  56533. * @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.
  56534. */
  56535. dispose(disposeAll?: boolean): void;
  56536. }
  56537. }
  56538. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56539. import { Nullable } from "babylonjs/types";
  56540. import { Scene } from "babylonjs/scene";
  56541. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56542. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56543. import { Effect } from "babylonjs/Materials/effect";
  56544. import "babylonjs/Shaders/shadowMap.fragment";
  56545. import "babylonjs/Shaders/shadowMap.vertex";
  56546. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56547. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56548. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56549. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56550. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56551. /**
  56552. * A CSM implementation allowing casting shadows on large scenes.
  56553. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56554. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56555. */
  56556. export class CascadedShadowGenerator extends ShadowGenerator {
  56557. private static readonly frustumCornersNDCSpace;
  56558. /**
  56559. * Name of the CSM class
  56560. */
  56561. static CLASSNAME: string;
  56562. /**
  56563. * Defines the default number of cascades used by the CSM.
  56564. */
  56565. static readonly DEFAULT_CASCADES_COUNT: number;
  56566. /**
  56567. * Defines the minimum number of cascades used by the CSM.
  56568. */
  56569. static readonly MIN_CASCADES_COUNT: number;
  56570. /**
  56571. * Defines the maximum number of cascades used by the CSM.
  56572. */
  56573. static readonly MAX_CASCADES_COUNT: number;
  56574. protected _validateFilter(filter: number): number;
  56575. /**
  56576. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56577. */
  56578. penumbraDarkness: number;
  56579. private _numCascades;
  56580. /**
  56581. * Gets or set the number of cascades used by the CSM.
  56582. */
  56583. get numCascades(): number;
  56584. set numCascades(value: number);
  56585. /**
  56586. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56587. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56588. */
  56589. stabilizeCascades: boolean;
  56590. private _freezeShadowCastersBoundingInfo;
  56591. private _freezeShadowCastersBoundingInfoObservable;
  56592. /**
  56593. * Enables or disables the shadow casters bounding info computation.
  56594. * If your shadow casters don't move, you can disable this feature.
  56595. * If it is enabled, the bounding box computation is done every frame.
  56596. */
  56597. get freezeShadowCastersBoundingInfo(): boolean;
  56598. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56599. private _scbiMin;
  56600. private _scbiMax;
  56601. protected _computeShadowCastersBoundingInfo(): void;
  56602. protected _shadowCastersBoundingInfo: BoundingInfo;
  56603. /**
  56604. * Gets or sets the shadow casters bounding info.
  56605. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56606. * so that the system won't overwrite the bounds you provide
  56607. */
  56608. get shadowCastersBoundingInfo(): BoundingInfo;
  56609. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56610. protected _breaksAreDirty: boolean;
  56611. protected _minDistance: number;
  56612. protected _maxDistance: number;
  56613. /**
  56614. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56615. *
  56616. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56617. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56618. * @param min minimal distance for the breaks (default to 0.)
  56619. * @param max maximal distance for the breaks (default to 1.)
  56620. */
  56621. setMinMaxDistance(min: number, max: number): void;
  56622. /** Gets the minimal distance used in the cascade break computation */
  56623. get minDistance(): number;
  56624. /** Gets the maximal distance used in the cascade break computation */
  56625. get maxDistance(): number;
  56626. /**
  56627. * Gets the class name of that object
  56628. * @returns "CascadedShadowGenerator"
  56629. */
  56630. getClassName(): string;
  56631. private _cascadeMinExtents;
  56632. private _cascadeMaxExtents;
  56633. /**
  56634. * Gets a cascade minimum extents
  56635. * @param cascadeIndex index of the cascade
  56636. * @returns the minimum cascade extents
  56637. */
  56638. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56639. /**
  56640. * Gets a cascade maximum extents
  56641. * @param cascadeIndex index of the cascade
  56642. * @returns the maximum cascade extents
  56643. */
  56644. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56645. private _cascades;
  56646. private _currentLayer;
  56647. private _viewSpaceFrustumsZ;
  56648. private _viewMatrices;
  56649. private _projectionMatrices;
  56650. private _transformMatrices;
  56651. private _transformMatricesAsArray;
  56652. private _frustumLengths;
  56653. private _lightSizeUVCorrection;
  56654. private _depthCorrection;
  56655. private _frustumCornersWorldSpace;
  56656. private _frustumCenter;
  56657. private _shadowCameraPos;
  56658. private _shadowMaxZ;
  56659. /**
  56660. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56661. * It defaults to camera.maxZ
  56662. */
  56663. get shadowMaxZ(): number;
  56664. /**
  56665. * Sets the shadow max z distance.
  56666. */
  56667. set shadowMaxZ(value: number);
  56668. protected _debug: boolean;
  56669. /**
  56670. * Gets or sets the debug flag.
  56671. * When enabled, the cascades are materialized by different colors on the screen.
  56672. */
  56673. get debug(): boolean;
  56674. set debug(dbg: boolean);
  56675. private _depthClamp;
  56676. /**
  56677. * Gets or sets the depth clamping value.
  56678. *
  56679. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56680. * to account for the shadow casters far away.
  56681. *
  56682. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56683. */
  56684. get depthClamp(): boolean;
  56685. set depthClamp(value: boolean);
  56686. private _cascadeBlendPercentage;
  56687. /**
  56688. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56689. * It defaults to 0.1 (10% blending).
  56690. */
  56691. get cascadeBlendPercentage(): number;
  56692. set cascadeBlendPercentage(value: number);
  56693. private _lambda;
  56694. /**
  56695. * Gets or set the lambda parameter.
  56696. * This parameter is used to split the camera frustum and create the cascades.
  56697. * 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.
  56698. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56699. */
  56700. get lambda(): number;
  56701. set lambda(value: number);
  56702. /**
  56703. * Gets the view matrix corresponding to a given cascade
  56704. * @param cascadeNum cascade to retrieve the view matrix from
  56705. * @returns the cascade view matrix
  56706. */
  56707. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56708. /**
  56709. * Gets the projection matrix corresponding to a given cascade
  56710. * @param cascadeNum cascade to retrieve the projection matrix from
  56711. * @returns the cascade projection matrix
  56712. */
  56713. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56714. /**
  56715. * Gets the transformation matrix corresponding to a given cascade
  56716. * @param cascadeNum cascade to retrieve the transformation matrix from
  56717. * @returns the cascade transformation matrix
  56718. */
  56719. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56720. private _depthRenderer;
  56721. /**
  56722. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56723. *
  56724. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56725. *
  56726. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56727. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56728. * @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
  56729. */
  56730. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56731. private _depthReducer;
  56732. private _autoCalcDepthBounds;
  56733. /**
  56734. * Gets or sets the autoCalcDepthBounds property.
  56735. *
  56736. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56737. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56738. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56739. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56740. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56741. */
  56742. get autoCalcDepthBounds(): boolean;
  56743. set autoCalcDepthBounds(value: boolean);
  56744. /**
  56745. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56746. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56747. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56748. * for setting the refresh rate on the renderer yourself!
  56749. */
  56750. get autoCalcDepthBoundsRefreshRate(): number;
  56751. set autoCalcDepthBoundsRefreshRate(value: number);
  56752. /**
  56753. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56754. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56755. * you change the camera near/far planes!
  56756. */
  56757. splitFrustum(): void;
  56758. private _splitFrustum;
  56759. private _computeMatrices;
  56760. private _computeFrustumInWorldSpace;
  56761. private _computeCascadeFrustum;
  56762. /** @hidden */
  56763. static _SceneComponentInitialization: (scene: Scene) => void;
  56764. /**
  56765. * Creates a Cascaded Shadow Generator object.
  56766. * A ShadowGenerator is the required tool to use the shadows.
  56767. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56768. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56769. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56770. * @param light The directional light object generating the shadows.
  56771. * @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.
  56772. */
  56773. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56774. protected _initializeGenerator(): void;
  56775. protected _createTargetRenderTexture(): void;
  56776. protected _initializeShadowMap(): void;
  56777. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56778. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56779. /**
  56780. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56781. * @param defines Defines of the material we want to update
  56782. * @param lightIndex Index of the light in the enabled light list of the material
  56783. */
  56784. prepareDefines(defines: any, lightIndex: number): void;
  56785. /**
  56786. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56787. * defined in the generator but impacting the effect).
  56788. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56789. * @param effect The effect we are binfing the information for
  56790. */
  56791. bindShadowLight(lightIndex: string, effect: Effect): void;
  56792. /**
  56793. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56794. * (eq to view projection * shadow projection matrices)
  56795. * @returns The transform matrix used to create the shadow map
  56796. */
  56797. getTransformMatrix(): Matrix;
  56798. /**
  56799. * Disposes the ShadowGenerator.
  56800. * Returns nothing.
  56801. */
  56802. dispose(): void;
  56803. /**
  56804. * Serializes the shadow generator setup to a json object.
  56805. * @returns The serialized JSON object
  56806. */
  56807. serialize(): any;
  56808. /**
  56809. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56810. * @param parsedShadowGenerator The JSON object to parse
  56811. * @param scene The scene to create the shadow map for
  56812. * @returns The parsed shadow generator
  56813. */
  56814. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56815. }
  56816. }
  56817. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56818. import { Scene } from "babylonjs/scene";
  56819. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56820. import { AbstractScene } from "babylonjs/abstractScene";
  56821. /**
  56822. * Defines the shadow generator component responsible to manage any shadow generators
  56823. * in a given scene.
  56824. */
  56825. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56826. /**
  56827. * The component name helpfull to identify the component in the list of scene components.
  56828. */
  56829. readonly name: string;
  56830. /**
  56831. * The scene the component belongs to.
  56832. */
  56833. scene: Scene;
  56834. /**
  56835. * Creates a new instance of the component for the given scene
  56836. * @param scene Defines the scene to register the component in
  56837. */
  56838. constructor(scene: Scene);
  56839. /**
  56840. * Registers the component in a given scene
  56841. */
  56842. register(): void;
  56843. /**
  56844. * Rebuilds the elements related to this component in case of
  56845. * context lost for instance.
  56846. */
  56847. rebuild(): void;
  56848. /**
  56849. * Serializes the component data to the specified json object
  56850. * @param serializationObject The object to serialize to
  56851. */
  56852. serialize(serializationObject: any): void;
  56853. /**
  56854. * Adds all the elements from the container to the scene
  56855. * @param container the container holding the elements
  56856. */
  56857. addFromContainer(container: AbstractScene): void;
  56858. /**
  56859. * Removes all the elements in the container from the scene
  56860. * @param container contains the elements to remove
  56861. * @param dispose if the removed element should be disposed (default: false)
  56862. */
  56863. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56864. /**
  56865. * Rebuilds the elements related to this component in case of
  56866. * context lost for instance.
  56867. */
  56868. dispose(): void;
  56869. private _gatherRenderTargets;
  56870. }
  56871. }
  56872. declare module "babylonjs/Lights/Shadows/index" {
  56873. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56874. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56875. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56876. }
  56877. declare module "babylonjs/Lights/pointLight" {
  56878. import { Scene } from "babylonjs/scene";
  56879. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56881. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56882. import { Effect } from "babylonjs/Materials/effect";
  56883. /**
  56884. * A point light is a light defined by an unique point in world space.
  56885. * The light is emitted in every direction from this point.
  56886. * A good example of a point light is a standard light bulb.
  56887. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56888. */
  56889. export class PointLight extends ShadowLight {
  56890. private _shadowAngle;
  56891. /**
  56892. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56893. * This specifies what angle the shadow will use to be created.
  56894. *
  56895. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56896. */
  56897. get shadowAngle(): number;
  56898. /**
  56899. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56900. * This specifies what angle the shadow will use to be created.
  56901. *
  56902. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56903. */
  56904. set shadowAngle(value: number);
  56905. /**
  56906. * Gets the direction if it has been set.
  56907. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56908. */
  56909. get direction(): Vector3;
  56910. /**
  56911. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56912. */
  56913. set direction(value: Vector3);
  56914. /**
  56915. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56916. * A PointLight emits the light in every direction.
  56917. * It can cast shadows.
  56918. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56919. * ```javascript
  56920. * var pointLight = new PointLight("pl", camera.position, scene);
  56921. * ```
  56922. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56923. * @param name The light friendly name
  56924. * @param position The position of the point light in the scene
  56925. * @param scene The scene the lights belongs to
  56926. */
  56927. constructor(name: string, position: Vector3, scene: Scene);
  56928. /**
  56929. * Returns the string "PointLight"
  56930. * @returns the class name
  56931. */
  56932. getClassName(): string;
  56933. /**
  56934. * Returns the integer 0.
  56935. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56936. */
  56937. getTypeID(): number;
  56938. /**
  56939. * Specifies wether or not the shadowmap should be a cube texture.
  56940. * @returns true if the shadowmap needs to be a cube texture.
  56941. */
  56942. needCube(): boolean;
  56943. /**
  56944. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56945. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56946. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56947. */
  56948. getShadowDirection(faceIndex?: number): Vector3;
  56949. /**
  56950. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56951. * - fov = PI / 2
  56952. * - aspect ratio : 1.0
  56953. * - z-near and far equal to the active camera minZ and maxZ.
  56954. * Returns the PointLight.
  56955. */
  56956. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56957. protected _buildUniformLayout(): void;
  56958. /**
  56959. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56960. * @param effect The effect to update
  56961. * @param lightIndex The index of the light in the effect to update
  56962. * @returns The point light
  56963. */
  56964. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56965. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56966. /**
  56967. * Prepares the list of defines specific to the light type.
  56968. * @param defines the list of defines
  56969. * @param lightIndex defines the index of the light for the effect
  56970. */
  56971. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56972. }
  56973. }
  56974. declare module "babylonjs/Lights/index" {
  56975. export * from "babylonjs/Lights/light";
  56976. export * from "babylonjs/Lights/shadowLight";
  56977. export * from "babylonjs/Lights/Shadows/index";
  56978. export * from "babylonjs/Lights/directionalLight";
  56979. export * from "babylonjs/Lights/hemisphericLight";
  56980. export * from "babylonjs/Lights/pointLight";
  56981. export * from "babylonjs/Lights/spotLight";
  56982. }
  56983. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56984. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56985. /**
  56986. * Header information of HDR texture files.
  56987. */
  56988. export interface HDRInfo {
  56989. /**
  56990. * The height of the texture in pixels.
  56991. */
  56992. height: number;
  56993. /**
  56994. * The width of the texture in pixels.
  56995. */
  56996. width: number;
  56997. /**
  56998. * The index of the beginning of the data in the binary file.
  56999. */
  57000. dataPosition: number;
  57001. }
  57002. /**
  57003. * This groups tools to convert HDR texture to native colors array.
  57004. */
  57005. export class HDRTools {
  57006. private static Ldexp;
  57007. private static Rgbe2float;
  57008. private static readStringLine;
  57009. /**
  57010. * Reads header information from an RGBE texture stored in a native array.
  57011. * More information on this format are available here:
  57012. * https://en.wikipedia.org/wiki/RGBE_image_format
  57013. *
  57014. * @param uint8array The binary file stored in native array.
  57015. * @return The header information.
  57016. */
  57017. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57018. /**
  57019. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57020. * This RGBE texture needs to store the information as a panorama.
  57021. *
  57022. * More information on this format are available here:
  57023. * https://en.wikipedia.org/wiki/RGBE_image_format
  57024. *
  57025. * @param buffer The binary file stored in an array buffer.
  57026. * @param size The expected size of the extracted cubemap.
  57027. * @return The Cube Map information.
  57028. */
  57029. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57030. /**
  57031. * Returns the pixels data extracted from an RGBE texture.
  57032. * This pixels will be stored left to right up to down in the R G B order in one array.
  57033. *
  57034. * More information on this format are available here:
  57035. * https://en.wikipedia.org/wiki/RGBE_image_format
  57036. *
  57037. * @param uint8array The binary file stored in an array buffer.
  57038. * @param hdrInfo The header information of the file.
  57039. * @return The pixels data in RGB right to left up to down order.
  57040. */
  57041. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57042. private static RGBE_ReadPixels_RLE;
  57043. }
  57044. }
  57045. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57046. import { Nullable } from "babylonjs/types";
  57047. import { Scene } from "babylonjs/scene";
  57048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57050. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57051. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57052. /**
  57053. * This represents a texture coming from an HDR input.
  57054. *
  57055. * The only supported format is currently panorama picture stored in RGBE format.
  57056. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57057. */
  57058. export class HDRCubeTexture extends BaseTexture {
  57059. private static _facesMapping;
  57060. private _generateHarmonics;
  57061. private _noMipmap;
  57062. private _textureMatrix;
  57063. private _size;
  57064. private _onLoad;
  57065. private _onError;
  57066. /**
  57067. * The texture URL.
  57068. */
  57069. url: string;
  57070. /**
  57071. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57072. */
  57073. coordinatesMode: number;
  57074. protected _isBlocking: boolean;
  57075. /**
  57076. * Sets wether or not the texture is blocking during loading.
  57077. */
  57078. set isBlocking(value: boolean);
  57079. /**
  57080. * Gets wether or not the texture is blocking during loading.
  57081. */
  57082. get isBlocking(): boolean;
  57083. protected _rotationY: number;
  57084. /**
  57085. * Sets texture matrix rotation angle around Y axis in radians.
  57086. */
  57087. set rotationY(value: number);
  57088. /**
  57089. * Gets texture matrix rotation angle around Y axis radians.
  57090. */
  57091. get rotationY(): number;
  57092. /**
  57093. * Gets or sets the center of the bounding box associated with the cube texture
  57094. * It must define where the camera used to render the texture was set
  57095. */
  57096. boundingBoxPosition: Vector3;
  57097. private _boundingBoxSize;
  57098. /**
  57099. * Gets or sets the size of the bounding box associated with the cube texture
  57100. * When defined, the cubemap will switch to local mode
  57101. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57102. * @example https://www.babylonjs-playground.com/#RNASML
  57103. */
  57104. set boundingBoxSize(value: Vector3);
  57105. get boundingBoxSize(): Vector3;
  57106. /**
  57107. * Instantiates an HDRTexture from the following parameters.
  57108. *
  57109. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57110. * @param scene The scene the texture will be used in
  57111. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57112. * @param noMipmap Forces to not generate the mipmap if true
  57113. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57114. * @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)
  57115. * @param reserved Reserved flag for internal use.
  57116. */
  57117. 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>);
  57118. /**
  57119. * Get the current class name of the texture useful for serialization or dynamic coding.
  57120. * @returns "HDRCubeTexture"
  57121. */
  57122. getClassName(): string;
  57123. /**
  57124. * Occurs when the file is raw .hdr file.
  57125. */
  57126. private loadTexture;
  57127. clone(): HDRCubeTexture;
  57128. delayLoad(): void;
  57129. /**
  57130. * Get the texture reflection matrix used to rotate/transform the reflection.
  57131. * @returns the reflection matrix
  57132. */
  57133. getReflectionTextureMatrix(): Matrix;
  57134. /**
  57135. * Set the texture reflection matrix used to rotate/transform the reflection.
  57136. * @param value Define the reflection matrix to set
  57137. */
  57138. setReflectionTextureMatrix(value: Matrix): void;
  57139. /**
  57140. * Parses a JSON representation of an HDR Texture in order to create the texture
  57141. * @param parsedTexture Define the JSON representation
  57142. * @param scene Define the scene the texture should be created in
  57143. * @param rootUrl Define the root url in case we need to load relative dependencies
  57144. * @returns the newly created texture after parsing
  57145. */
  57146. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57147. serialize(): any;
  57148. }
  57149. }
  57150. declare module "babylonjs/Physics/physicsEngine" {
  57151. import { Nullable } from "babylonjs/types";
  57152. import { Vector3 } from "babylonjs/Maths/math.vector";
  57153. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57154. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57155. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57156. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57157. /**
  57158. * Class used to control physics engine
  57159. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57160. */
  57161. export class PhysicsEngine implements IPhysicsEngine {
  57162. private _physicsPlugin;
  57163. /**
  57164. * Global value used to control the smallest number supported by the simulation
  57165. */
  57166. static Epsilon: number;
  57167. private _impostors;
  57168. private _joints;
  57169. private _subTimeStep;
  57170. /**
  57171. * Gets the gravity vector used by the simulation
  57172. */
  57173. gravity: Vector3;
  57174. /**
  57175. * Factory used to create the default physics plugin.
  57176. * @returns The default physics plugin
  57177. */
  57178. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57179. /**
  57180. * Creates a new Physics Engine
  57181. * @param gravity defines the gravity vector used by the simulation
  57182. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57183. */
  57184. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57185. /**
  57186. * Sets the gravity vector used by the simulation
  57187. * @param gravity defines the gravity vector to use
  57188. */
  57189. setGravity(gravity: Vector3): void;
  57190. /**
  57191. * Set the time step of the physics engine.
  57192. * Default is 1/60.
  57193. * To slow it down, enter 1/600 for example.
  57194. * To speed it up, 1/30
  57195. * @param newTimeStep defines the new timestep to apply to this world.
  57196. */
  57197. setTimeStep(newTimeStep?: number): void;
  57198. /**
  57199. * Get the time step of the physics engine.
  57200. * @returns the current time step
  57201. */
  57202. getTimeStep(): number;
  57203. /**
  57204. * Set the sub time step of the physics engine.
  57205. * Default is 0 meaning there is no sub steps
  57206. * To increase physics resolution precision, set a small value (like 1 ms)
  57207. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57208. */
  57209. setSubTimeStep(subTimeStep?: number): void;
  57210. /**
  57211. * Get the sub time step of the physics engine.
  57212. * @returns the current sub time step
  57213. */
  57214. getSubTimeStep(): number;
  57215. /**
  57216. * Release all resources
  57217. */
  57218. dispose(): void;
  57219. /**
  57220. * Gets the name of the current physics plugin
  57221. * @returns the name of the plugin
  57222. */
  57223. getPhysicsPluginName(): string;
  57224. /**
  57225. * Adding a new impostor for the impostor tracking.
  57226. * This will be done by the impostor itself.
  57227. * @param impostor the impostor to add
  57228. */
  57229. addImpostor(impostor: PhysicsImpostor): void;
  57230. /**
  57231. * Remove an impostor from the engine.
  57232. * This impostor and its mesh will not longer be updated by the physics engine.
  57233. * @param impostor the impostor to remove
  57234. */
  57235. removeImpostor(impostor: PhysicsImpostor): void;
  57236. /**
  57237. * Add a joint to the physics engine
  57238. * @param mainImpostor defines the main impostor to which the joint is added.
  57239. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57240. * @param joint defines the joint that will connect both impostors.
  57241. */
  57242. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57243. /**
  57244. * Removes a joint from the simulation
  57245. * @param mainImpostor defines the impostor used with the joint
  57246. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57247. * @param joint defines the joint to remove
  57248. */
  57249. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57250. /**
  57251. * Called by the scene. No need to call it.
  57252. * @param delta defines the timespam between frames
  57253. */
  57254. _step(delta: number): void;
  57255. /**
  57256. * Gets the current plugin used to run the simulation
  57257. * @returns current plugin
  57258. */
  57259. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57260. /**
  57261. * Gets the list of physic impostors
  57262. * @returns an array of PhysicsImpostor
  57263. */
  57264. getImpostors(): Array<PhysicsImpostor>;
  57265. /**
  57266. * Gets the impostor for a physics enabled object
  57267. * @param object defines the object impersonated by the impostor
  57268. * @returns the PhysicsImpostor or null if not found
  57269. */
  57270. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57271. /**
  57272. * Gets the impostor for a physics body object
  57273. * @param body defines physics body used by the impostor
  57274. * @returns the PhysicsImpostor or null if not found
  57275. */
  57276. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57277. /**
  57278. * Does a raycast in the physics world
  57279. * @param from when should the ray start?
  57280. * @param to when should the ray end?
  57281. * @returns PhysicsRaycastResult
  57282. */
  57283. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57284. }
  57285. }
  57286. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57287. import { Nullable } from "babylonjs/types";
  57288. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57290. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57291. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57292. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57293. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57294. /** @hidden */
  57295. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57296. private _useDeltaForWorldStep;
  57297. world: any;
  57298. name: string;
  57299. private _physicsMaterials;
  57300. private _fixedTimeStep;
  57301. private _cannonRaycastResult;
  57302. private _raycastResult;
  57303. private _physicsBodysToRemoveAfterStep;
  57304. BJSCANNON: any;
  57305. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57306. setGravity(gravity: Vector3): void;
  57307. setTimeStep(timeStep: number): void;
  57308. getTimeStep(): number;
  57309. executeStep(delta: number): void;
  57310. private _removeMarkedPhysicsBodiesFromWorld;
  57311. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57312. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57313. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57314. private _processChildMeshes;
  57315. removePhysicsBody(impostor: PhysicsImpostor): void;
  57316. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57317. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57318. private _addMaterial;
  57319. private _checkWithEpsilon;
  57320. private _createShape;
  57321. private _createHeightmap;
  57322. private _minus90X;
  57323. private _plus90X;
  57324. private _tmpPosition;
  57325. private _tmpDeltaPosition;
  57326. private _tmpUnityRotation;
  57327. private _updatePhysicsBodyTransformation;
  57328. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57329. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57330. isSupported(): boolean;
  57331. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57332. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57333. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57334. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57335. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57336. getBodyMass(impostor: PhysicsImpostor): number;
  57337. getBodyFriction(impostor: PhysicsImpostor): number;
  57338. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57339. getBodyRestitution(impostor: PhysicsImpostor): number;
  57340. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57341. sleepBody(impostor: PhysicsImpostor): void;
  57342. wakeUpBody(impostor: PhysicsImpostor): void;
  57343. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57344. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57345. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57346. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57347. getRadius(impostor: PhysicsImpostor): number;
  57348. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57349. dispose(): void;
  57350. private _extendNamespace;
  57351. /**
  57352. * Does a raycast in the physics world
  57353. * @param from when should the ray start?
  57354. * @param to when should the ray end?
  57355. * @returns PhysicsRaycastResult
  57356. */
  57357. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57358. }
  57359. }
  57360. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57361. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57362. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57363. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57365. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57366. import { Nullable } from "babylonjs/types";
  57367. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57368. /** @hidden */
  57369. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57370. world: any;
  57371. name: string;
  57372. BJSOIMO: any;
  57373. private _raycastResult;
  57374. constructor(iterations?: number, oimoInjection?: any);
  57375. setGravity(gravity: Vector3): void;
  57376. setTimeStep(timeStep: number): void;
  57377. getTimeStep(): number;
  57378. private _tmpImpostorsArray;
  57379. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57380. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57381. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57382. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57383. private _tmpPositionVector;
  57384. removePhysicsBody(impostor: PhysicsImpostor): void;
  57385. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57386. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57387. isSupported(): boolean;
  57388. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57389. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57390. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57391. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57392. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57393. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57394. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57395. getBodyMass(impostor: PhysicsImpostor): number;
  57396. getBodyFriction(impostor: PhysicsImpostor): number;
  57397. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57398. getBodyRestitution(impostor: PhysicsImpostor): number;
  57399. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57400. sleepBody(impostor: PhysicsImpostor): void;
  57401. wakeUpBody(impostor: PhysicsImpostor): void;
  57402. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57403. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57404. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57405. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57406. getRadius(impostor: PhysicsImpostor): number;
  57407. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57408. dispose(): void;
  57409. /**
  57410. * Does a raycast in the physics world
  57411. * @param from when should the ray start?
  57412. * @param to when should the ray end?
  57413. * @returns PhysicsRaycastResult
  57414. */
  57415. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57416. }
  57417. }
  57418. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57419. import { Nullable } from "babylonjs/types";
  57420. import { Scene } from "babylonjs/scene";
  57421. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57422. import { Color4 } from "babylonjs/Maths/math.color";
  57423. import { Mesh } from "babylonjs/Meshes/mesh";
  57424. /**
  57425. * Class containing static functions to help procedurally build meshes
  57426. */
  57427. export class RibbonBuilder {
  57428. /**
  57429. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57430. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57431. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57432. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57433. * * 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
  57434. * * 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
  57435. * * 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
  57436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57438. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57439. * * 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
  57440. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57441. * * 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
  57442. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57444. * @param name defines the name of the mesh
  57445. * @param options defines the options used to create the mesh
  57446. * @param scene defines the hosting scene
  57447. * @returns the ribbon mesh
  57448. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57449. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57450. */
  57451. static CreateRibbon(name: string, options: {
  57452. pathArray: Vector3[][];
  57453. closeArray?: boolean;
  57454. closePath?: boolean;
  57455. offset?: number;
  57456. updatable?: boolean;
  57457. sideOrientation?: number;
  57458. frontUVs?: Vector4;
  57459. backUVs?: Vector4;
  57460. instance?: Mesh;
  57461. invertUV?: boolean;
  57462. uvs?: Vector2[];
  57463. colors?: Color4[];
  57464. }, scene?: Nullable<Scene>): Mesh;
  57465. }
  57466. }
  57467. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57468. import { Nullable } from "babylonjs/types";
  57469. import { Scene } from "babylonjs/scene";
  57470. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57471. import { Mesh } from "babylonjs/Meshes/mesh";
  57472. /**
  57473. * Class containing static functions to help procedurally build meshes
  57474. */
  57475. export class ShapeBuilder {
  57476. /**
  57477. * 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.
  57478. * * 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.
  57479. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57480. * * 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.
  57481. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57482. * * 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
  57483. * * 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
  57484. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57487. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57489. * @param name defines the name of the mesh
  57490. * @param options defines the options used to create the mesh
  57491. * @param scene defines the hosting scene
  57492. * @returns the extruded shape mesh
  57493. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57495. */
  57496. static ExtrudeShape(name: string, options: {
  57497. shape: Vector3[];
  57498. path: Vector3[];
  57499. scale?: number;
  57500. rotation?: number;
  57501. cap?: number;
  57502. updatable?: boolean;
  57503. sideOrientation?: number;
  57504. frontUVs?: Vector4;
  57505. backUVs?: Vector4;
  57506. instance?: Mesh;
  57507. invertUV?: boolean;
  57508. }, scene?: Nullable<Scene>): Mesh;
  57509. /**
  57510. * Creates an custom extruded shape mesh.
  57511. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57512. * * 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.
  57513. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57514. * * 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
  57515. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57516. * * 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
  57517. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57518. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57519. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57520. * * 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
  57521. * * 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
  57522. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57525. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57527. * @param name defines the name of the mesh
  57528. * @param options defines the options used to create the mesh
  57529. * @param scene defines the hosting scene
  57530. * @returns the custom extruded shape mesh
  57531. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57532. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57533. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57534. */
  57535. static ExtrudeShapeCustom(name: string, options: {
  57536. shape: Vector3[];
  57537. path: Vector3[];
  57538. scaleFunction?: any;
  57539. rotationFunction?: any;
  57540. ribbonCloseArray?: boolean;
  57541. ribbonClosePath?: boolean;
  57542. cap?: number;
  57543. updatable?: boolean;
  57544. sideOrientation?: number;
  57545. frontUVs?: Vector4;
  57546. backUVs?: Vector4;
  57547. instance?: Mesh;
  57548. invertUV?: boolean;
  57549. }, scene?: Nullable<Scene>): Mesh;
  57550. private static _ExtrudeShapeGeneric;
  57551. }
  57552. }
  57553. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57554. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57555. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57556. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57557. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57558. import { Nullable } from "babylonjs/types";
  57559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57560. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57561. /**
  57562. * AmmoJS Physics plugin
  57563. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57564. * @see https://github.com/kripken/ammo.js/
  57565. */
  57566. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57567. private _useDeltaForWorldStep;
  57568. /**
  57569. * Reference to the Ammo library
  57570. */
  57571. bjsAMMO: any;
  57572. /**
  57573. * Created ammoJS world which physics bodies are added to
  57574. */
  57575. world: any;
  57576. /**
  57577. * Name of the plugin
  57578. */
  57579. name: string;
  57580. private _timeStep;
  57581. private _fixedTimeStep;
  57582. private _maxSteps;
  57583. private _tmpQuaternion;
  57584. private _tmpAmmoTransform;
  57585. private _tmpAmmoQuaternion;
  57586. private _tmpAmmoConcreteContactResultCallback;
  57587. private _collisionConfiguration;
  57588. private _dispatcher;
  57589. private _overlappingPairCache;
  57590. private _solver;
  57591. private _softBodySolver;
  57592. private _tmpAmmoVectorA;
  57593. private _tmpAmmoVectorB;
  57594. private _tmpAmmoVectorC;
  57595. private _tmpAmmoVectorD;
  57596. private _tmpContactCallbackResult;
  57597. private _tmpAmmoVectorRCA;
  57598. private _tmpAmmoVectorRCB;
  57599. private _raycastResult;
  57600. private static readonly DISABLE_COLLISION_FLAG;
  57601. private static readonly KINEMATIC_FLAG;
  57602. private static readonly DISABLE_DEACTIVATION_FLAG;
  57603. /**
  57604. * Initializes the ammoJS plugin
  57605. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57606. * @param ammoInjection can be used to inject your own ammo reference
  57607. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57608. */
  57609. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57610. /**
  57611. * Sets the gravity of the physics world (m/(s^2))
  57612. * @param gravity Gravity to set
  57613. */
  57614. setGravity(gravity: Vector3): void;
  57615. /**
  57616. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57617. * @param timeStep timestep to use in seconds
  57618. */
  57619. setTimeStep(timeStep: number): void;
  57620. /**
  57621. * 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)
  57622. * @param fixedTimeStep fixedTimeStep to use in seconds
  57623. */
  57624. setFixedTimeStep(fixedTimeStep: number): void;
  57625. /**
  57626. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57627. * @param maxSteps the maximum number of steps by the physics engine per frame
  57628. */
  57629. setMaxSteps(maxSteps: number): void;
  57630. /**
  57631. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57632. * @returns the current timestep in seconds
  57633. */
  57634. getTimeStep(): number;
  57635. /**
  57636. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57637. */
  57638. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57639. private _isImpostorInContact;
  57640. private _isImpostorPairInContact;
  57641. private _stepSimulation;
  57642. /**
  57643. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57644. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57645. * After the step the babylon meshes are set to the position of the physics imposters
  57646. * @param delta amount of time to step forward
  57647. * @param impostors array of imposters to update before/after the step
  57648. */
  57649. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57650. /**
  57651. * Update babylon mesh to match physics world object
  57652. * @param impostor imposter to match
  57653. */
  57654. private _afterSoftStep;
  57655. /**
  57656. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57657. * @param impostor imposter to match
  57658. */
  57659. private _ropeStep;
  57660. /**
  57661. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57662. * @param impostor imposter to match
  57663. */
  57664. private _softbodyOrClothStep;
  57665. private _tmpVector;
  57666. private _tmpMatrix;
  57667. /**
  57668. * Applies an impulse on the imposter
  57669. * @param impostor imposter to apply impulse to
  57670. * @param force amount of force to be applied to the imposter
  57671. * @param contactPoint the location to apply the impulse on the imposter
  57672. */
  57673. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57674. /**
  57675. * Applies a force on the imposter
  57676. * @param impostor imposter to apply force
  57677. * @param force amount of force to be applied to the imposter
  57678. * @param contactPoint the location to apply the force on the imposter
  57679. */
  57680. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57681. /**
  57682. * Creates a physics body using the plugin
  57683. * @param impostor the imposter to create the physics body on
  57684. */
  57685. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57686. /**
  57687. * Removes the physics body from the imposter and disposes of the body's memory
  57688. * @param impostor imposter to remove the physics body from
  57689. */
  57690. removePhysicsBody(impostor: PhysicsImpostor): void;
  57691. /**
  57692. * Generates a joint
  57693. * @param impostorJoint the imposter joint to create the joint with
  57694. */
  57695. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57696. /**
  57697. * Removes a joint
  57698. * @param impostorJoint the imposter joint to remove the joint from
  57699. */
  57700. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57701. private _addMeshVerts;
  57702. /**
  57703. * Initialise the soft body vertices to match its object's (mesh) vertices
  57704. * Softbody vertices (nodes) are in world space and to match this
  57705. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57706. * @param impostor to create the softbody for
  57707. */
  57708. private _softVertexData;
  57709. /**
  57710. * Create an impostor's soft body
  57711. * @param impostor to create the softbody for
  57712. */
  57713. private _createSoftbody;
  57714. /**
  57715. * Create cloth for an impostor
  57716. * @param impostor to create the softbody for
  57717. */
  57718. private _createCloth;
  57719. /**
  57720. * Create rope for an impostor
  57721. * @param impostor to create the softbody for
  57722. */
  57723. private _createRope;
  57724. /**
  57725. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57726. * @param impostor to create the custom physics shape for
  57727. */
  57728. private _createCustom;
  57729. private _addHullVerts;
  57730. private _createShape;
  57731. /**
  57732. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57733. * @param impostor imposter containing the physics body and babylon object
  57734. */
  57735. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57736. /**
  57737. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57738. * @param impostor imposter containing the physics body and babylon object
  57739. * @param newPosition new position
  57740. * @param newRotation new rotation
  57741. */
  57742. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57743. /**
  57744. * If this plugin is supported
  57745. * @returns true if its supported
  57746. */
  57747. isSupported(): boolean;
  57748. /**
  57749. * Sets the linear velocity of the physics body
  57750. * @param impostor imposter to set the velocity on
  57751. * @param velocity velocity to set
  57752. */
  57753. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57754. /**
  57755. * Sets the angular velocity of the physics body
  57756. * @param impostor imposter to set the velocity on
  57757. * @param velocity velocity to set
  57758. */
  57759. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57760. /**
  57761. * gets the linear velocity
  57762. * @param impostor imposter to get linear velocity from
  57763. * @returns linear velocity
  57764. */
  57765. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57766. /**
  57767. * gets the angular velocity
  57768. * @param impostor imposter to get angular velocity from
  57769. * @returns angular velocity
  57770. */
  57771. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57772. /**
  57773. * Sets the mass of physics body
  57774. * @param impostor imposter to set the mass on
  57775. * @param mass mass to set
  57776. */
  57777. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57778. /**
  57779. * Gets the mass of the physics body
  57780. * @param impostor imposter to get the mass from
  57781. * @returns mass
  57782. */
  57783. getBodyMass(impostor: PhysicsImpostor): number;
  57784. /**
  57785. * Gets friction of the impostor
  57786. * @param impostor impostor to get friction from
  57787. * @returns friction value
  57788. */
  57789. getBodyFriction(impostor: PhysicsImpostor): number;
  57790. /**
  57791. * Sets friction of the impostor
  57792. * @param impostor impostor to set friction on
  57793. * @param friction friction value
  57794. */
  57795. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57796. /**
  57797. * Gets restitution of the impostor
  57798. * @param impostor impostor to get restitution from
  57799. * @returns restitution value
  57800. */
  57801. getBodyRestitution(impostor: PhysicsImpostor): number;
  57802. /**
  57803. * Sets resitution of the impostor
  57804. * @param impostor impostor to set resitution on
  57805. * @param restitution resitution value
  57806. */
  57807. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57808. /**
  57809. * Gets pressure inside the impostor
  57810. * @param impostor impostor to get pressure from
  57811. * @returns pressure value
  57812. */
  57813. getBodyPressure(impostor: PhysicsImpostor): number;
  57814. /**
  57815. * Sets pressure inside a soft body impostor
  57816. * Cloth and rope must remain 0 pressure
  57817. * @param impostor impostor to set pressure on
  57818. * @param pressure pressure value
  57819. */
  57820. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57821. /**
  57822. * Gets stiffness of the impostor
  57823. * @param impostor impostor to get stiffness from
  57824. * @returns pressure value
  57825. */
  57826. getBodyStiffness(impostor: PhysicsImpostor): number;
  57827. /**
  57828. * Sets stiffness of the impostor
  57829. * @param impostor impostor to set stiffness on
  57830. * @param stiffness stiffness value from 0 to 1
  57831. */
  57832. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57833. /**
  57834. * Gets velocityIterations of the impostor
  57835. * @param impostor impostor to get velocity iterations from
  57836. * @returns velocityIterations value
  57837. */
  57838. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57839. /**
  57840. * Sets velocityIterations of the impostor
  57841. * @param impostor impostor to set velocity iterations on
  57842. * @param velocityIterations velocityIterations value
  57843. */
  57844. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57845. /**
  57846. * Gets positionIterations of the impostor
  57847. * @param impostor impostor to get position iterations from
  57848. * @returns positionIterations value
  57849. */
  57850. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57851. /**
  57852. * Sets positionIterations of the impostor
  57853. * @param impostor impostor to set position on
  57854. * @param positionIterations positionIterations value
  57855. */
  57856. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57857. /**
  57858. * Append an anchor to a cloth object
  57859. * @param impostor is the cloth impostor to add anchor to
  57860. * @param otherImpostor is the rigid impostor to anchor to
  57861. * @param width ratio across width from 0 to 1
  57862. * @param height ratio up height from 0 to 1
  57863. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57864. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57865. */
  57866. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57867. /**
  57868. * Append an hook to a rope object
  57869. * @param impostor is the rope impostor to add hook to
  57870. * @param otherImpostor is the rigid impostor to hook to
  57871. * @param length ratio along the rope from 0 to 1
  57872. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57873. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57874. */
  57875. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57876. /**
  57877. * Sleeps the physics body and stops it from being active
  57878. * @param impostor impostor to sleep
  57879. */
  57880. sleepBody(impostor: PhysicsImpostor): void;
  57881. /**
  57882. * Activates the physics body
  57883. * @param impostor impostor to activate
  57884. */
  57885. wakeUpBody(impostor: PhysicsImpostor): void;
  57886. /**
  57887. * Updates the distance parameters of the joint
  57888. * @param joint joint to update
  57889. * @param maxDistance maximum distance of the joint
  57890. * @param minDistance minimum distance of the joint
  57891. */
  57892. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57893. /**
  57894. * Sets a motor on the joint
  57895. * @param joint joint to set motor on
  57896. * @param speed speed of the motor
  57897. * @param maxForce maximum force of the motor
  57898. * @param motorIndex index of the motor
  57899. */
  57900. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57901. /**
  57902. * Sets the motors limit
  57903. * @param joint joint to set limit on
  57904. * @param upperLimit upper limit
  57905. * @param lowerLimit lower limit
  57906. */
  57907. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57908. /**
  57909. * Syncs the position and rotation of a mesh with the impostor
  57910. * @param mesh mesh to sync
  57911. * @param impostor impostor to update the mesh with
  57912. */
  57913. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57914. /**
  57915. * Gets the radius of the impostor
  57916. * @param impostor impostor to get radius from
  57917. * @returns the radius
  57918. */
  57919. getRadius(impostor: PhysicsImpostor): number;
  57920. /**
  57921. * Gets the box size of the impostor
  57922. * @param impostor impostor to get box size from
  57923. * @param result the resulting box size
  57924. */
  57925. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57926. /**
  57927. * Disposes of the impostor
  57928. */
  57929. dispose(): void;
  57930. /**
  57931. * Does a raycast in the physics world
  57932. * @param from when should the ray start?
  57933. * @param to when should the ray end?
  57934. * @returns PhysicsRaycastResult
  57935. */
  57936. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57937. }
  57938. }
  57939. declare module "babylonjs/Probes/reflectionProbe" {
  57940. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57941. import { Vector3 } from "babylonjs/Maths/math.vector";
  57942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57943. import { Nullable } from "babylonjs/types";
  57944. import { Scene } from "babylonjs/scene";
  57945. module "babylonjs/abstractScene" {
  57946. interface AbstractScene {
  57947. /**
  57948. * The list of reflection probes added to the scene
  57949. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57950. */
  57951. reflectionProbes: Array<ReflectionProbe>;
  57952. /**
  57953. * Removes the given reflection probe from this scene.
  57954. * @param toRemove The reflection probe to remove
  57955. * @returns The index of the removed reflection probe
  57956. */
  57957. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57958. /**
  57959. * Adds the given reflection probe to this scene.
  57960. * @param newReflectionProbe The reflection probe to add
  57961. */
  57962. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57963. }
  57964. }
  57965. /**
  57966. * Class used to generate realtime reflection / refraction cube textures
  57967. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57968. */
  57969. export class ReflectionProbe {
  57970. /** defines the name of the probe */
  57971. name: string;
  57972. private _scene;
  57973. private _renderTargetTexture;
  57974. private _projectionMatrix;
  57975. private _viewMatrix;
  57976. private _target;
  57977. private _add;
  57978. private _attachedMesh;
  57979. private _invertYAxis;
  57980. /** Gets or sets probe position (center of the cube map) */
  57981. position: Vector3;
  57982. /**
  57983. * Creates a new reflection probe
  57984. * @param name defines the name of the probe
  57985. * @param size defines the texture resolution (for each face)
  57986. * @param scene defines the hosting scene
  57987. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57988. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57989. */
  57990. constructor(
  57991. /** defines the name of the probe */
  57992. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57993. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57994. get samples(): number;
  57995. set samples(value: number);
  57996. /** Gets or sets the refresh rate to use (on every frame by default) */
  57997. get refreshRate(): number;
  57998. set refreshRate(value: number);
  57999. /**
  58000. * Gets the hosting scene
  58001. * @returns a Scene
  58002. */
  58003. getScene(): Scene;
  58004. /** Gets the internal CubeTexture used to render to */
  58005. get cubeTexture(): RenderTargetTexture;
  58006. /** Gets the list of meshes to render */
  58007. get renderList(): Nullable<AbstractMesh[]>;
  58008. /**
  58009. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58010. * @param mesh defines the mesh to attach to
  58011. */
  58012. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58013. /**
  58014. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58015. * @param renderingGroupId The rendering group id corresponding to its index
  58016. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58017. */
  58018. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58019. /**
  58020. * Clean all associated resources
  58021. */
  58022. dispose(): void;
  58023. /**
  58024. * Converts the reflection probe information to a readable string for debug purpose.
  58025. * @param fullDetails Supports for multiple levels of logging within scene loading
  58026. * @returns the human readable reflection probe info
  58027. */
  58028. toString(fullDetails?: boolean): string;
  58029. /**
  58030. * Get the class name of the relfection probe.
  58031. * @returns "ReflectionProbe"
  58032. */
  58033. getClassName(): string;
  58034. /**
  58035. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58036. * @returns The JSON representation of the texture
  58037. */
  58038. serialize(): any;
  58039. /**
  58040. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58041. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58042. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58043. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58044. * @returns The parsed reflection probe if successful
  58045. */
  58046. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58047. }
  58048. }
  58049. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58050. /** @hidden */
  58051. export var _BabylonLoaderRegistered: boolean;
  58052. /**
  58053. * Helps setting up some configuration for the babylon file loader.
  58054. */
  58055. export class BabylonFileLoaderConfiguration {
  58056. /**
  58057. * The loader does not allow injecting custom physix engine into the plugins.
  58058. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58059. * So you could set this variable to your engine import to make it work.
  58060. */
  58061. static LoaderInjectedPhysicsEngine: any;
  58062. }
  58063. }
  58064. declare module "babylonjs/Loading/Plugins/index" {
  58065. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58066. }
  58067. declare module "babylonjs/Loading/index" {
  58068. export * from "babylonjs/Loading/loadingScreen";
  58069. export * from "babylonjs/Loading/Plugins/index";
  58070. export * from "babylonjs/Loading/sceneLoader";
  58071. export * from "babylonjs/Loading/sceneLoaderFlags";
  58072. }
  58073. declare module "babylonjs/Materials/Background/index" {
  58074. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58075. }
  58076. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58077. import { Scene } from "babylonjs/scene";
  58078. import { Color3 } from "babylonjs/Maths/math.color";
  58079. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58081. /**
  58082. * The Physically based simple base material of BJS.
  58083. *
  58084. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58085. * It is used as the base class for both the specGloss and metalRough conventions.
  58086. */
  58087. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58088. /**
  58089. * Number of Simultaneous lights allowed on the material.
  58090. */
  58091. maxSimultaneousLights: number;
  58092. /**
  58093. * If sets to true, disables all the lights affecting the material.
  58094. */
  58095. disableLighting: boolean;
  58096. /**
  58097. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58098. */
  58099. environmentTexture: BaseTexture;
  58100. /**
  58101. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58102. */
  58103. invertNormalMapX: boolean;
  58104. /**
  58105. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58106. */
  58107. invertNormalMapY: boolean;
  58108. /**
  58109. * Normal map used in the model.
  58110. */
  58111. normalTexture: BaseTexture;
  58112. /**
  58113. * Emissivie color used to self-illuminate the model.
  58114. */
  58115. emissiveColor: Color3;
  58116. /**
  58117. * Emissivie texture used to self-illuminate the model.
  58118. */
  58119. emissiveTexture: BaseTexture;
  58120. /**
  58121. * Occlusion Channel Strenght.
  58122. */
  58123. occlusionStrength: number;
  58124. /**
  58125. * Occlusion Texture of the material (adding extra occlusion effects).
  58126. */
  58127. occlusionTexture: BaseTexture;
  58128. /**
  58129. * Defines the alpha limits in alpha test mode.
  58130. */
  58131. alphaCutOff: number;
  58132. /**
  58133. * Gets the current double sided mode.
  58134. */
  58135. get doubleSided(): boolean;
  58136. /**
  58137. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58138. */
  58139. set doubleSided(value: boolean);
  58140. /**
  58141. * Stores the pre-calculated light information of a mesh in a texture.
  58142. */
  58143. lightmapTexture: BaseTexture;
  58144. /**
  58145. * If true, the light map contains occlusion information instead of lighting info.
  58146. */
  58147. useLightmapAsShadowmap: boolean;
  58148. /**
  58149. * Instantiates a new PBRMaterial instance.
  58150. *
  58151. * @param name The material name
  58152. * @param scene The scene the material will be use in.
  58153. */
  58154. constructor(name: string, scene: Scene);
  58155. getClassName(): string;
  58156. }
  58157. }
  58158. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58159. import { Scene } from "babylonjs/scene";
  58160. import { Color3 } from "babylonjs/Maths/math.color";
  58161. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58162. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58163. /**
  58164. * The PBR material of BJS following the metal roughness convention.
  58165. *
  58166. * This fits to the PBR convention in the GLTF definition:
  58167. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58168. */
  58169. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58170. /**
  58171. * The base color has two different interpretations depending on the value of metalness.
  58172. * When the material is a metal, the base color is the specific measured reflectance value
  58173. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58174. * of the material.
  58175. */
  58176. baseColor: Color3;
  58177. /**
  58178. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58179. * well as opacity information in the alpha channel.
  58180. */
  58181. baseTexture: BaseTexture;
  58182. /**
  58183. * Specifies the metallic scalar value of the material.
  58184. * Can also be used to scale the metalness values of the metallic texture.
  58185. */
  58186. metallic: number;
  58187. /**
  58188. * Specifies the roughness scalar value of the material.
  58189. * Can also be used to scale the roughness values of the metallic texture.
  58190. */
  58191. roughness: number;
  58192. /**
  58193. * Texture containing both the metallic value in the B channel and the
  58194. * roughness value in the G channel to keep better precision.
  58195. */
  58196. metallicRoughnessTexture: BaseTexture;
  58197. /**
  58198. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58199. *
  58200. * @param name The material name
  58201. * @param scene The scene the material will be use in.
  58202. */
  58203. constructor(name: string, scene: Scene);
  58204. /**
  58205. * Return the currrent class name of the material.
  58206. */
  58207. getClassName(): string;
  58208. /**
  58209. * Makes a duplicate of the current material.
  58210. * @param name - name to use for the new material.
  58211. */
  58212. clone(name: string): PBRMetallicRoughnessMaterial;
  58213. /**
  58214. * Serialize the material to a parsable JSON object.
  58215. */
  58216. serialize(): any;
  58217. /**
  58218. * Parses a JSON object correponding to the serialize function.
  58219. */
  58220. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58221. }
  58222. }
  58223. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58224. import { Scene } from "babylonjs/scene";
  58225. import { Color3 } from "babylonjs/Maths/math.color";
  58226. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58227. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58228. /**
  58229. * The PBR material of BJS following the specular glossiness convention.
  58230. *
  58231. * This fits to the PBR convention in the GLTF definition:
  58232. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58233. */
  58234. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58235. /**
  58236. * Specifies the diffuse color of the material.
  58237. */
  58238. diffuseColor: Color3;
  58239. /**
  58240. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58241. * channel.
  58242. */
  58243. diffuseTexture: BaseTexture;
  58244. /**
  58245. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58246. */
  58247. specularColor: Color3;
  58248. /**
  58249. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58250. */
  58251. glossiness: number;
  58252. /**
  58253. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58254. */
  58255. specularGlossinessTexture: BaseTexture;
  58256. /**
  58257. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58258. *
  58259. * @param name The material name
  58260. * @param scene The scene the material will be use in.
  58261. */
  58262. constructor(name: string, scene: Scene);
  58263. /**
  58264. * Return the currrent class name of the material.
  58265. */
  58266. getClassName(): string;
  58267. /**
  58268. * Makes a duplicate of the current material.
  58269. * @param name - name to use for the new material.
  58270. */
  58271. clone(name: string): PBRSpecularGlossinessMaterial;
  58272. /**
  58273. * Serialize the material to a parsable JSON object.
  58274. */
  58275. serialize(): any;
  58276. /**
  58277. * Parses a JSON object correponding to the serialize function.
  58278. */
  58279. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58280. }
  58281. }
  58282. declare module "babylonjs/Materials/PBR/index" {
  58283. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58284. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58285. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58286. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58287. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58288. }
  58289. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58290. import { Nullable } from "babylonjs/types";
  58291. import { Scene } from "babylonjs/scene";
  58292. import { Matrix } from "babylonjs/Maths/math.vector";
  58293. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58294. /**
  58295. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58296. * It can help converting any input color in a desired output one. This can then be used to create effects
  58297. * from sepia, black and white to sixties or futuristic rendering...
  58298. *
  58299. * The only supported format is currently 3dl.
  58300. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58301. */
  58302. export class ColorGradingTexture extends BaseTexture {
  58303. /**
  58304. * The current texture matrix. (will always be identity in color grading texture)
  58305. */
  58306. private _textureMatrix;
  58307. /**
  58308. * The texture URL.
  58309. */
  58310. url: string;
  58311. /**
  58312. * Empty line regex stored for GC.
  58313. */
  58314. private static _noneEmptyLineRegex;
  58315. private _engine;
  58316. /**
  58317. * Instantiates a ColorGradingTexture from the following parameters.
  58318. *
  58319. * @param url The location of the color gradind data (currently only supporting 3dl)
  58320. * @param scene The scene the texture will be used in
  58321. */
  58322. constructor(url: string, scene: Scene);
  58323. /**
  58324. * Returns the texture matrix used in most of the material.
  58325. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58326. */
  58327. getTextureMatrix(): Matrix;
  58328. /**
  58329. * Occurs when the file being loaded is a .3dl LUT file.
  58330. */
  58331. private load3dlTexture;
  58332. /**
  58333. * Starts the loading process of the texture.
  58334. */
  58335. private loadTexture;
  58336. /**
  58337. * Clones the color gradind texture.
  58338. */
  58339. clone(): ColorGradingTexture;
  58340. /**
  58341. * Called during delayed load for textures.
  58342. */
  58343. delayLoad(): void;
  58344. /**
  58345. * Parses a color grading texture serialized by Babylon.
  58346. * @param parsedTexture The texture information being parsedTexture
  58347. * @param scene The scene to load the texture in
  58348. * @param rootUrl The root url of the data assets to load
  58349. * @return A color gradind texture
  58350. */
  58351. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58352. /**
  58353. * Serializes the LUT texture to json format.
  58354. */
  58355. serialize(): any;
  58356. }
  58357. }
  58358. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58359. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58360. import { Scene } from "babylonjs/scene";
  58361. import { Nullable } from "babylonjs/types";
  58362. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58363. /**
  58364. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58365. */
  58366. export class EquiRectangularCubeTexture extends BaseTexture {
  58367. /** The six faces of the cube. */
  58368. private static _FacesMapping;
  58369. private _noMipmap;
  58370. private _onLoad;
  58371. private _onError;
  58372. /** The size of the cubemap. */
  58373. private _size;
  58374. /** The buffer of the image. */
  58375. private _buffer;
  58376. /** The width of the input image. */
  58377. private _width;
  58378. /** The height of the input image. */
  58379. private _height;
  58380. /** The URL to the image. */
  58381. url: string;
  58382. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58383. coordinatesMode: number;
  58384. /**
  58385. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58386. * @param url The location of the image
  58387. * @param scene The scene the texture will be used in
  58388. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58389. * @param noMipmap Forces to not generate the mipmap if true
  58390. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58391. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58392. * @param onLoad — defines a callback called when texture is loaded
  58393. * @param onError — defines a callback called if there is an error
  58394. */
  58395. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58396. /**
  58397. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58398. */
  58399. private loadImage;
  58400. /**
  58401. * Convert the image buffer into a cubemap and create a CubeTexture.
  58402. */
  58403. private loadTexture;
  58404. /**
  58405. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58406. * @param buffer The ArrayBuffer that should be converted.
  58407. * @returns The buffer as Float32Array.
  58408. */
  58409. private getFloat32ArrayFromArrayBuffer;
  58410. /**
  58411. * Get the current class name of the texture useful for serialization or dynamic coding.
  58412. * @returns "EquiRectangularCubeTexture"
  58413. */
  58414. getClassName(): string;
  58415. /**
  58416. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58417. * @returns A clone of the current EquiRectangularCubeTexture.
  58418. */
  58419. clone(): EquiRectangularCubeTexture;
  58420. }
  58421. }
  58422. declare module "babylonjs/Misc/tga" {
  58423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58424. /**
  58425. * Based on jsTGALoader - Javascript loader for TGA file
  58426. * By Vincent Thibault
  58427. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58428. */
  58429. export class TGATools {
  58430. private static _TYPE_INDEXED;
  58431. private static _TYPE_RGB;
  58432. private static _TYPE_GREY;
  58433. private static _TYPE_RLE_INDEXED;
  58434. private static _TYPE_RLE_RGB;
  58435. private static _TYPE_RLE_GREY;
  58436. private static _ORIGIN_MASK;
  58437. private static _ORIGIN_SHIFT;
  58438. private static _ORIGIN_BL;
  58439. private static _ORIGIN_BR;
  58440. private static _ORIGIN_UL;
  58441. private static _ORIGIN_UR;
  58442. /**
  58443. * Gets the header of a TGA file
  58444. * @param data defines the TGA data
  58445. * @returns the header
  58446. */
  58447. static GetTGAHeader(data: Uint8Array): any;
  58448. /**
  58449. * Uploads TGA content to a Babylon Texture
  58450. * @hidden
  58451. */
  58452. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58453. /** @hidden */
  58454. 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;
  58455. /** @hidden */
  58456. 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;
  58457. /** @hidden */
  58458. 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;
  58459. /** @hidden */
  58460. 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;
  58461. /** @hidden */
  58462. 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;
  58463. /** @hidden */
  58464. 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;
  58465. }
  58466. }
  58467. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58468. import { Nullable } from "babylonjs/types";
  58469. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58470. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58471. /**
  58472. * Implementation of the TGA Texture Loader.
  58473. * @hidden
  58474. */
  58475. export class _TGATextureLoader implements IInternalTextureLoader {
  58476. /**
  58477. * Defines wether the loader supports cascade loading the different faces.
  58478. */
  58479. readonly supportCascades: boolean;
  58480. /**
  58481. * This returns if the loader support the current file information.
  58482. * @param extension defines the file extension of the file being loaded
  58483. * @returns true if the loader can load the specified file
  58484. */
  58485. canLoad(extension: string): boolean;
  58486. /**
  58487. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58488. * @param data contains the texture data
  58489. * @param texture defines the BabylonJS internal texture
  58490. * @param createPolynomials will be true if polynomials have been requested
  58491. * @param onLoad defines the callback to trigger once the texture is ready
  58492. * @param onError defines the callback to trigger in case of error
  58493. */
  58494. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58495. /**
  58496. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58497. * @param data contains the texture data
  58498. * @param texture defines the BabylonJS internal texture
  58499. * @param callback defines the method to call once ready to upload
  58500. */
  58501. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58502. }
  58503. }
  58504. declare module "babylonjs/Misc/basis" {
  58505. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58506. /**
  58507. * Info about the .basis files
  58508. */
  58509. class BasisFileInfo {
  58510. /**
  58511. * If the file has alpha
  58512. */
  58513. hasAlpha: boolean;
  58514. /**
  58515. * Info about each image of the basis file
  58516. */
  58517. images: Array<{
  58518. levels: Array<{
  58519. width: number;
  58520. height: number;
  58521. transcodedPixels: ArrayBufferView;
  58522. }>;
  58523. }>;
  58524. }
  58525. /**
  58526. * Result of transcoding a basis file
  58527. */
  58528. class TranscodeResult {
  58529. /**
  58530. * Info about the .basis file
  58531. */
  58532. fileInfo: BasisFileInfo;
  58533. /**
  58534. * Format to use when loading the file
  58535. */
  58536. format: number;
  58537. }
  58538. /**
  58539. * Configuration options for the Basis transcoder
  58540. */
  58541. export class BasisTranscodeConfiguration {
  58542. /**
  58543. * Supported compression formats used to determine the supported output format of the transcoder
  58544. */
  58545. supportedCompressionFormats?: {
  58546. /**
  58547. * etc1 compression format
  58548. */
  58549. etc1?: boolean;
  58550. /**
  58551. * s3tc compression format
  58552. */
  58553. s3tc?: boolean;
  58554. /**
  58555. * pvrtc compression format
  58556. */
  58557. pvrtc?: boolean;
  58558. /**
  58559. * etc2 compression format
  58560. */
  58561. etc2?: boolean;
  58562. };
  58563. /**
  58564. * If mipmap levels should be loaded for transcoded images (Default: true)
  58565. */
  58566. loadMipmapLevels?: boolean;
  58567. /**
  58568. * Index of a single image to load (Default: all images)
  58569. */
  58570. loadSingleImage?: number;
  58571. }
  58572. /**
  58573. * Used to load .Basis files
  58574. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58575. */
  58576. export class BasisTools {
  58577. private static _IgnoreSupportedFormats;
  58578. /**
  58579. * URL to use when loading the basis transcoder
  58580. */
  58581. static JSModuleURL: string;
  58582. /**
  58583. * URL to use when loading the wasm module for the transcoder
  58584. */
  58585. static WasmModuleURL: string;
  58586. /**
  58587. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58588. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58589. * @returns internal format corresponding to the Basis format
  58590. */
  58591. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58592. private static _WorkerPromise;
  58593. private static _Worker;
  58594. private static _actionId;
  58595. private static _CreateWorkerAsync;
  58596. /**
  58597. * Transcodes a loaded image file to compressed pixel data
  58598. * @param data image data to transcode
  58599. * @param config configuration options for the transcoding
  58600. * @returns a promise resulting in the transcoded image
  58601. */
  58602. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58603. /**
  58604. * Loads a texture from the transcode result
  58605. * @param texture texture load to
  58606. * @param transcodeResult the result of transcoding the basis file to load from
  58607. */
  58608. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58609. }
  58610. }
  58611. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58612. import { Nullable } from "babylonjs/types";
  58613. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58614. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58615. /**
  58616. * Loader for .basis file format
  58617. */
  58618. export class _BasisTextureLoader implements IInternalTextureLoader {
  58619. /**
  58620. * Defines whether the loader supports cascade loading the different faces.
  58621. */
  58622. readonly supportCascades: boolean;
  58623. /**
  58624. * This returns if the loader support the current file information.
  58625. * @param extension defines the file extension of the file being loaded
  58626. * @returns true if the loader can load the specified file
  58627. */
  58628. canLoad(extension: string): boolean;
  58629. /**
  58630. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58631. * @param data contains the texture data
  58632. * @param texture defines the BabylonJS internal texture
  58633. * @param createPolynomials will be true if polynomials have been requested
  58634. * @param onLoad defines the callback to trigger once the texture is ready
  58635. * @param onError defines the callback to trigger in case of error
  58636. */
  58637. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58638. /**
  58639. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58640. * @param data contains the texture data
  58641. * @param texture defines the BabylonJS internal texture
  58642. * @param callback defines the method to call once ready to upload
  58643. */
  58644. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58645. }
  58646. }
  58647. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58648. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58649. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58650. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58651. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58652. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58653. }
  58654. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58655. import { Scene } from "babylonjs/scene";
  58656. import { Texture } from "babylonjs/Materials/Textures/texture";
  58657. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58658. /**
  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. */
  58663. export class CustomProceduralTexture extends ProceduralTexture {
  58664. private _animate;
  58665. private _time;
  58666. private _config;
  58667. private _texturePath;
  58668. /**
  58669. * Instantiates a new Custom Procedural Texture.
  58670. * 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.
  58671. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58672. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58673. * @param name Define the name of the texture
  58674. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58675. * @param size Define the size of the texture to create
  58676. * @param scene Define the scene the texture belongs to
  58677. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58678. * @param generateMipMaps Define if the texture should creates mip maps or not
  58679. */
  58680. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58681. private _loadJson;
  58682. /**
  58683. * Is the texture ready to be used ? (rendered at least once)
  58684. * @returns true if ready, otherwise, false.
  58685. */
  58686. isReady(): boolean;
  58687. /**
  58688. * Render the texture to its associated render target.
  58689. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58690. */
  58691. render(useCameraPostProcess?: boolean): void;
  58692. /**
  58693. * Update the list of dependant textures samplers in the shader.
  58694. */
  58695. updateTextures(): void;
  58696. /**
  58697. * Update the uniform values of the procedural texture in the shader.
  58698. */
  58699. updateShaderUniforms(): void;
  58700. /**
  58701. * Define if the texture animates or not.
  58702. */
  58703. get animate(): boolean;
  58704. set animate(value: boolean);
  58705. }
  58706. }
  58707. declare module "babylonjs/Shaders/noise.fragment" {
  58708. /** @hidden */
  58709. export var noisePixelShader: {
  58710. name: string;
  58711. shader: string;
  58712. };
  58713. }
  58714. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58715. import { Nullable } from "babylonjs/types";
  58716. import { Scene } from "babylonjs/scene";
  58717. import { Texture } from "babylonjs/Materials/Textures/texture";
  58718. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58719. import "babylonjs/Shaders/noise.fragment";
  58720. /**
  58721. * Class used to generate noise procedural textures
  58722. */
  58723. export class NoiseProceduralTexture extends ProceduralTexture {
  58724. private _time;
  58725. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58726. brightness: number;
  58727. /** Defines the number of octaves to process */
  58728. octaves: number;
  58729. /** Defines the level of persistence (0.8 by default) */
  58730. persistence: number;
  58731. /** Gets or sets animation speed factor (default is 1) */
  58732. animationSpeedFactor: number;
  58733. /**
  58734. * Creates a new NoiseProceduralTexture
  58735. * @param name defines the name fo the texture
  58736. * @param size defines the size of the texture (default is 256)
  58737. * @param scene defines the hosting scene
  58738. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58739. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58740. */
  58741. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58742. private _updateShaderUniforms;
  58743. protected _getDefines(): string;
  58744. /** Generate the current state of the procedural texture */
  58745. render(useCameraPostProcess?: boolean): void;
  58746. /**
  58747. * Serializes this noise procedural texture
  58748. * @returns a serialized noise procedural texture object
  58749. */
  58750. serialize(): any;
  58751. /**
  58752. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58753. * @param parsedTexture defines parsed texture data
  58754. * @param scene defines the current scene
  58755. * @param rootUrl defines the root URL containing noise procedural texture information
  58756. * @returns a parsed NoiseProceduralTexture
  58757. */
  58758. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58759. }
  58760. }
  58761. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58762. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58763. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58764. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58765. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58766. }
  58767. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58768. import { Nullable } from "babylonjs/types";
  58769. import { Scene } from "babylonjs/scene";
  58770. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58771. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58772. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58773. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58774. /**
  58775. * Raw cube texture where the raw buffers are passed in
  58776. */
  58777. export class RawCubeTexture extends CubeTexture {
  58778. /**
  58779. * Creates a cube texture where the raw buffers are passed in.
  58780. * @param scene defines the scene the texture is attached to
  58781. * @param data defines the array of data to use to create each face
  58782. * @param size defines the size of the textures
  58783. * @param format defines the format of the data
  58784. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58785. * @param generateMipMaps defines if the engine should generate the mip levels
  58786. * @param invertY defines if data must be stored with Y axis inverted
  58787. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58788. * @param compression defines the compression used (null by default)
  58789. */
  58790. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58791. /**
  58792. * Updates the raw cube texture.
  58793. * @param data defines the data to store
  58794. * @param format defines the data format
  58795. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58796. * @param invertY defines if data must be stored with Y axis inverted
  58797. * @param compression defines the compression used (null by default)
  58798. * @param level defines which level of the texture to update
  58799. */
  58800. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58801. /**
  58802. * Updates a raw cube texture with RGBD encoded data.
  58803. * @param data defines the array of data [mipmap][face] to use to create each face
  58804. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58805. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58806. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58807. * @returns a promsie that resolves when the operation is complete
  58808. */
  58809. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58810. /**
  58811. * Clones the raw cube texture.
  58812. * @return a new cube texture
  58813. */
  58814. clone(): CubeTexture;
  58815. /** @hidden */
  58816. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58817. }
  58818. }
  58819. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58820. import { Scene } from "babylonjs/scene";
  58821. import { Texture } from "babylonjs/Materials/Textures/texture";
  58822. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58823. /**
  58824. * Class used to store 3D textures containing user data
  58825. */
  58826. export class RawTexture3D extends Texture {
  58827. /** Gets or sets the texture format to use */
  58828. format: number;
  58829. private _engine;
  58830. /**
  58831. * Create a new RawTexture3D
  58832. * @param data defines the data of the texture
  58833. * @param width defines the width of the texture
  58834. * @param height defines the height of the texture
  58835. * @param depth defines the depth of the texture
  58836. * @param format defines the texture format to use
  58837. * @param scene defines the hosting scene
  58838. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58839. * @param invertY defines if texture must be stored with Y axis inverted
  58840. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58841. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58842. */
  58843. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58844. /** Gets or sets the texture format to use */
  58845. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58846. /**
  58847. * Update the texture with new data
  58848. * @param data defines the data to store in the texture
  58849. */
  58850. update(data: ArrayBufferView): void;
  58851. }
  58852. }
  58853. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58854. import { Scene } from "babylonjs/scene";
  58855. import { Texture } from "babylonjs/Materials/Textures/texture";
  58856. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58857. /**
  58858. * Class used to store 2D array textures containing user data
  58859. */
  58860. export class RawTexture2DArray extends Texture {
  58861. /** Gets or sets the texture format to use */
  58862. format: number;
  58863. private _engine;
  58864. /**
  58865. * Create a new RawTexture2DArray
  58866. * @param data defines the data of the texture
  58867. * @param width defines the width of the texture
  58868. * @param height defines the height of the texture
  58869. * @param depth defines the number of layers of the texture
  58870. * @param format defines the texture format to use
  58871. * @param scene defines the hosting scene
  58872. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58873. * @param invertY defines if texture must be stored with Y axis inverted
  58874. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58875. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58876. */
  58877. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58878. /** Gets or sets the texture format to use */
  58879. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58880. /**
  58881. * Update the texture with new data
  58882. * @param data defines the data to store in the texture
  58883. */
  58884. update(data: ArrayBufferView): void;
  58885. }
  58886. }
  58887. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58888. import { Scene } from "babylonjs/scene";
  58889. import { Plane } from "babylonjs/Maths/math.plane";
  58890. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58891. /**
  58892. * Creates a refraction texture used by refraction channel of the standard material.
  58893. * It is like a mirror but to see through a material.
  58894. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58895. */
  58896. export class RefractionTexture extends RenderTargetTexture {
  58897. /**
  58898. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58899. * 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.
  58900. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58901. */
  58902. refractionPlane: Plane;
  58903. /**
  58904. * Define how deep under the surface we should see.
  58905. */
  58906. depth: number;
  58907. /**
  58908. * Creates a refraction texture used by refraction channel of the standard material.
  58909. * It is like a mirror but to see through a material.
  58910. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58911. * @param name Define the texture name
  58912. * @param size Define the size of the underlying texture
  58913. * @param scene Define the scene the refraction belongs to
  58914. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58915. */
  58916. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58917. /**
  58918. * Clone the refraction texture.
  58919. * @returns the cloned texture
  58920. */
  58921. clone(): RefractionTexture;
  58922. /**
  58923. * Serialize the texture to a JSON representation you could use in Parse later on
  58924. * @returns the serialized JSON representation
  58925. */
  58926. serialize(): any;
  58927. }
  58928. }
  58929. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58930. import { Nullable } from "babylonjs/types";
  58931. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58932. import { Matrix } from "babylonjs/Maths/math.vector";
  58933. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58934. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58935. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58936. import { Scene } from "babylonjs/scene";
  58937. /**
  58938. * Defines the options related to the creation of an HtmlElementTexture
  58939. */
  58940. export interface IHtmlElementTextureOptions {
  58941. /**
  58942. * Defines wether mip maps should be created or not.
  58943. */
  58944. generateMipMaps?: boolean;
  58945. /**
  58946. * Defines the sampling mode of the texture.
  58947. */
  58948. samplingMode?: number;
  58949. /**
  58950. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58951. */
  58952. engine: Nullable<ThinEngine>;
  58953. /**
  58954. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58955. */
  58956. scene: Nullable<Scene>;
  58957. }
  58958. /**
  58959. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58960. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58961. * is automatically managed.
  58962. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58963. * in your application.
  58964. *
  58965. * As the update is not automatic, you need to call them manually.
  58966. */
  58967. export class HtmlElementTexture extends BaseTexture {
  58968. /**
  58969. * The texture URL.
  58970. */
  58971. element: HTMLVideoElement | HTMLCanvasElement;
  58972. private static readonly DefaultOptions;
  58973. private _textureMatrix;
  58974. private _engine;
  58975. private _isVideo;
  58976. private _generateMipMaps;
  58977. private _samplingMode;
  58978. /**
  58979. * Instantiates a HtmlElementTexture from the following parameters.
  58980. *
  58981. * @param name Defines the name of the texture
  58982. * @param element Defines the video or canvas the texture is filled with
  58983. * @param options Defines the other none mandatory texture creation options
  58984. */
  58985. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58986. private _createInternalTexture;
  58987. /**
  58988. * Returns the texture matrix used in most of the material.
  58989. */
  58990. getTextureMatrix(): Matrix;
  58991. /**
  58992. * Updates the content of the texture.
  58993. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  58994. */
  58995. update(invertY?: Nullable<boolean>): void;
  58996. }
  58997. }
  58998. declare module "babylonjs/Materials/Textures/Packer/frame" {
  58999. import { Vector2 } from "babylonjs/Maths/math.vector";
  59000. /**
  59001. * Defines the basic options interface of a TexturePacker Frame
  59002. */
  59003. export interface ITexturePackerFrame {
  59004. /**
  59005. * The frame ID
  59006. */
  59007. id: number;
  59008. /**
  59009. * The frames Scale
  59010. */
  59011. scale: Vector2;
  59012. /**
  59013. * The Frames offset
  59014. */
  59015. offset: Vector2;
  59016. }
  59017. /**
  59018. * This is a support class for frame Data on texture packer sets.
  59019. */
  59020. export class TexturePackerFrame implements ITexturePackerFrame {
  59021. /**
  59022. * The frame ID
  59023. */
  59024. id: number;
  59025. /**
  59026. * The frames Scale
  59027. */
  59028. scale: Vector2;
  59029. /**
  59030. * The Frames offset
  59031. */
  59032. offset: Vector2;
  59033. /**
  59034. * Initializes a texture package frame.
  59035. * @param id The numerical frame identifier
  59036. * @param scale Scalar Vector2 for UV frame
  59037. * @param offset Vector2 for the frame position in UV units.
  59038. * @returns TexturePackerFrame
  59039. */
  59040. constructor(id: number, scale: Vector2, offset: Vector2);
  59041. }
  59042. }
  59043. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59045. import { Scene } from "babylonjs/scene";
  59046. import { Nullable } from "babylonjs/types";
  59047. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59048. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59049. /**
  59050. * Defines the basic options interface of a TexturePacker
  59051. */
  59052. export interface ITexturePackerOptions {
  59053. /**
  59054. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59055. */
  59056. map?: string[];
  59057. /**
  59058. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59059. */
  59060. uvsIn?: string;
  59061. /**
  59062. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59063. */
  59064. uvsOut?: string;
  59065. /**
  59066. * number representing the layout style. Defaults to LAYOUT_STRIP
  59067. */
  59068. layout?: number;
  59069. /**
  59070. * number of columns if using custom column count layout(2). This defaults to 4.
  59071. */
  59072. colnum?: number;
  59073. /**
  59074. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59075. */
  59076. updateInputMeshes?: boolean;
  59077. /**
  59078. * boolean flag to dispose all the source textures. Defaults to true.
  59079. */
  59080. disposeSources?: boolean;
  59081. /**
  59082. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59083. */
  59084. fillBlanks?: boolean;
  59085. /**
  59086. * string value representing the context fill style color. Defaults to 'black'.
  59087. */
  59088. customFillColor?: string;
  59089. /**
  59090. * Width and Height Value of each Frame in the TexturePacker Sets
  59091. */
  59092. frameSize?: number;
  59093. /**
  59094. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59095. */
  59096. paddingRatio?: number;
  59097. /**
  59098. * Number that declares the fill method for the padding gutter.
  59099. */
  59100. paddingMode?: number;
  59101. /**
  59102. * If in SUBUV_COLOR padding mode what color to use.
  59103. */
  59104. paddingColor?: Color3 | Color4;
  59105. }
  59106. /**
  59107. * Defines the basic interface of a TexturePacker JSON File
  59108. */
  59109. export interface ITexturePackerJSON {
  59110. /**
  59111. * The frame ID
  59112. */
  59113. name: string;
  59114. /**
  59115. * The base64 channel data
  59116. */
  59117. sets: any;
  59118. /**
  59119. * The options of the Packer
  59120. */
  59121. options: ITexturePackerOptions;
  59122. /**
  59123. * The frame data of the Packer
  59124. */
  59125. frames: Array<number>;
  59126. }
  59127. /**
  59128. * This is a support class that generates a series of packed texture sets.
  59129. * @see https://doc.babylonjs.com/babylon101/materials
  59130. */
  59131. export class TexturePacker {
  59132. /** Packer Layout Constant 0 */
  59133. static readonly LAYOUT_STRIP: number;
  59134. /** Packer Layout Constant 1 */
  59135. static readonly LAYOUT_POWER2: number;
  59136. /** Packer Layout Constant 2 */
  59137. static readonly LAYOUT_COLNUM: number;
  59138. /** Packer Layout Constant 0 */
  59139. static readonly SUBUV_WRAP: number;
  59140. /** Packer Layout Constant 1 */
  59141. static readonly SUBUV_EXTEND: number;
  59142. /** Packer Layout Constant 2 */
  59143. static readonly SUBUV_COLOR: number;
  59144. /** The Name of the Texture Package */
  59145. name: string;
  59146. /** The scene scope of the TexturePacker */
  59147. scene: Scene;
  59148. /** The Meshes to target */
  59149. meshes: AbstractMesh[];
  59150. /** Arguments passed with the Constructor */
  59151. options: ITexturePackerOptions;
  59152. /** The promise that is started upon initialization */
  59153. promise: Nullable<Promise<TexturePacker | string>>;
  59154. /** The Container object for the channel sets that are generated */
  59155. sets: object;
  59156. /** The Container array for the frames that are generated */
  59157. frames: TexturePackerFrame[];
  59158. /** The expected number of textures the system is parsing. */
  59159. private _expecting;
  59160. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59161. private _paddingValue;
  59162. /**
  59163. * Initializes a texture package series from an array of meshes or a single mesh.
  59164. * @param name The name of the package
  59165. * @param meshes The target meshes to compose the package from
  59166. * @param options The arguments that texture packer should follow while building.
  59167. * @param scene The scene which the textures are scoped to.
  59168. * @returns TexturePacker
  59169. */
  59170. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59171. /**
  59172. * Starts the package process
  59173. * @param resolve The promises resolution function
  59174. * @returns TexturePacker
  59175. */
  59176. private _createFrames;
  59177. /**
  59178. * Calculates the Size of the Channel Sets
  59179. * @returns Vector2
  59180. */
  59181. private _calculateSize;
  59182. /**
  59183. * Calculates the UV data for the frames.
  59184. * @param baseSize the base frameSize
  59185. * @param padding the base frame padding
  59186. * @param dtSize size of the Dynamic Texture for that channel
  59187. * @param dtUnits is 1/dtSize
  59188. * @param update flag to update the input meshes
  59189. */
  59190. private _calculateMeshUVFrames;
  59191. /**
  59192. * Calculates the frames Offset.
  59193. * @param index of the frame
  59194. * @returns Vector2
  59195. */
  59196. private _getFrameOffset;
  59197. /**
  59198. * Updates a Mesh to the frame data
  59199. * @param mesh that is the target
  59200. * @param frameID or the frame index
  59201. */
  59202. private _updateMeshUV;
  59203. /**
  59204. * Updates a Meshes materials to use the texture packer channels
  59205. * @param m is the mesh to target
  59206. * @param force all channels on the packer to be set.
  59207. */
  59208. private _updateTextureReferences;
  59209. /**
  59210. * Public method to set a Mesh to a frame
  59211. * @param m that is the target
  59212. * @param frameID or the frame index
  59213. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59214. */
  59215. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59216. /**
  59217. * Starts the async promise to compile the texture packer.
  59218. * @returns Promise<void>
  59219. */
  59220. processAsync(): Promise<void>;
  59221. /**
  59222. * Disposes all textures associated with this packer
  59223. */
  59224. dispose(): void;
  59225. /**
  59226. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59227. * @param imageType is the image type to use.
  59228. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59229. */
  59230. download(imageType?: string, quality?: number): void;
  59231. /**
  59232. * Public method to load a texturePacker JSON file.
  59233. * @param data of the JSON file in string format.
  59234. */
  59235. updateFromJSON(data: string): void;
  59236. }
  59237. }
  59238. declare module "babylonjs/Materials/Textures/Packer/index" {
  59239. export * from "babylonjs/Materials/Textures/Packer/packer";
  59240. export * from "babylonjs/Materials/Textures/Packer/frame";
  59241. }
  59242. declare module "babylonjs/Materials/Textures/index" {
  59243. export * from "babylonjs/Materials/Textures/baseTexture";
  59244. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59245. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59246. export * from "babylonjs/Materials/Textures/cubeTexture";
  59247. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59248. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59249. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59250. export * from "babylonjs/Materials/Textures/internalTexture";
  59251. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59252. export * from "babylonjs/Materials/Textures/Loaders/index";
  59253. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59254. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59255. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59256. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59257. export * from "babylonjs/Materials/Textures/rawTexture";
  59258. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59259. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59260. export * from "babylonjs/Materials/Textures/refractionTexture";
  59261. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59262. export * from "babylonjs/Materials/Textures/texture";
  59263. export * from "babylonjs/Materials/Textures/videoTexture";
  59264. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59265. export * from "babylonjs/Materials/Textures/Packer/index";
  59266. }
  59267. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59268. /**
  59269. * Enum used to define the target of a block
  59270. */
  59271. export enum NodeMaterialBlockTargets {
  59272. /** Vertex shader */
  59273. Vertex = 1,
  59274. /** Fragment shader */
  59275. Fragment = 2,
  59276. /** Neutral */
  59277. Neutral = 4,
  59278. /** Vertex and Fragment */
  59279. VertexAndFragment = 3
  59280. }
  59281. }
  59282. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59283. /**
  59284. * Defines the kind of connection point for node based material
  59285. */
  59286. export enum NodeMaterialBlockConnectionPointTypes {
  59287. /** Float */
  59288. Float = 1,
  59289. /** Int */
  59290. Int = 2,
  59291. /** Vector2 */
  59292. Vector2 = 4,
  59293. /** Vector3 */
  59294. Vector3 = 8,
  59295. /** Vector4 */
  59296. Vector4 = 16,
  59297. /** Color3 */
  59298. Color3 = 32,
  59299. /** Color4 */
  59300. Color4 = 64,
  59301. /** Matrix */
  59302. Matrix = 128,
  59303. /** Detect type based on connection */
  59304. AutoDetect = 1024,
  59305. /** Output type that will be defined by input type */
  59306. BasedOnInput = 2048
  59307. }
  59308. }
  59309. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59310. /**
  59311. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59312. */
  59313. export enum NodeMaterialBlockConnectionPointMode {
  59314. /** Value is an uniform */
  59315. Uniform = 0,
  59316. /** Value is a mesh attribute */
  59317. Attribute = 1,
  59318. /** Value is a varying between vertex and fragment shaders */
  59319. Varying = 2,
  59320. /** Mode is undefined */
  59321. Undefined = 3
  59322. }
  59323. }
  59324. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59325. /**
  59326. * Enum used to define system values e.g. values automatically provided by the system
  59327. */
  59328. export enum NodeMaterialSystemValues {
  59329. /** World */
  59330. World = 1,
  59331. /** View */
  59332. View = 2,
  59333. /** Projection */
  59334. Projection = 3,
  59335. /** ViewProjection */
  59336. ViewProjection = 4,
  59337. /** WorldView */
  59338. WorldView = 5,
  59339. /** WorldViewProjection */
  59340. WorldViewProjection = 6,
  59341. /** CameraPosition */
  59342. CameraPosition = 7,
  59343. /** Fog Color */
  59344. FogColor = 8,
  59345. /** Delta time */
  59346. DeltaTime = 9
  59347. }
  59348. }
  59349. declare module "babylonjs/Materials/Node/Enums/index" {
  59350. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59351. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59352. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59353. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59354. }
  59355. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59357. /**
  59358. * Root class for all node material optimizers
  59359. */
  59360. export class NodeMaterialOptimizer {
  59361. /**
  59362. * Function used to optimize a NodeMaterial graph
  59363. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59364. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59365. */
  59366. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59367. }
  59368. }
  59369. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59370. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59371. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59372. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59373. import { Scene } from "babylonjs/scene";
  59374. /**
  59375. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59376. */
  59377. export class TransformBlock extends NodeMaterialBlock {
  59378. /**
  59379. * Defines the value to use to complement W value to transform it to a Vector4
  59380. */
  59381. complementW: number;
  59382. /**
  59383. * Defines the value to use to complement z value to transform it to a Vector4
  59384. */
  59385. complementZ: number;
  59386. /**
  59387. * Creates a new TransformBlock
  59388. * @param name defines the block name
  59389. */
  59390. constructor(name: string);
  59391. /**
  59392. * Gets the current class name
  59393. * @returns the class name
  59394. */
  59395. getClassName(): string;
  59396. /**
  59397. * Gets the vector input
  59398. */
  59399. get vector(): NodeMaterialConnectionPoint;
  59400. /**
  59401. * Gets the output component
  59402. */
  59403. get output(): NodeMaterialConnectionPoint;
  59404. /**
  59405. * Gets the xyz output component
  59406. */
  59407. get xyz(): NodeMaterialConnectionPoint;
  59408. /**
  59409. * Gets the matrix transform input
  59410. */
  59411. get transform(): NodeMaterialConnectionPoint;
  59412. protected _buildBlock(state: NodeMaterialBuildState): this;
  59413. serialize(): any;
  59414. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59415. protected _dumpPropertiesCode(): string;
  59416. }
  59417. }
  59418. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59422. /**
  59423. * Block used to output the vertex position
  59424. */
  59425. export class VertexOutputBlock extends NodeMaterialBlock {
  59426. /**
  59427. * Creates a new VertexOutputBlock
  59428. * @param name defines the block name
  59429. */
  59430. constructor(name: string);
  59431. /**
  59432. * Gets the current class name
  59433. * @returns the class name
  59434. */
  59435. getClassName(): string;
  59436. /**
  59437. * Gets the vector input component
  59438. */
  59439. get vector(): NodeMaterialConnectionPoint;
  59440. protected _buildBlock(state: NodeMaterialBuildState): this;
  59441. }
  59442. }
  59443. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59447. /**
  59448. * Block used to output the final color
  59449. */
  59450. export class FragmentOutputBlock extends NodeMaterialBlock {
  59451. /**
  59452. * Create a new FragmentOutputBlock
  59453. * @param name defines the block name
  59454. */
  59455. constructor(name: string);
  59456. /**
  59457. * Gets the current class name
  59458. * @returns the class name
  59459. */
  59460. getClassName(): string;
  59461. /**
  59462. * Gets the rgba input component
  59463. */
  59464. get rgba(): NodeMaterialConnectionPoint;
  59465. /**
  59466. * Gets the rgb input component
  59467. */
  59468. get rgb(): NodeMaterialConnectionPoint;
  59469. /**
  59470. * Gets the a input component
  59471. */
  59472. get a(): NodeMaterialConnectionPoint;
  59473. protected _buildBlock(state: NodeMaterialBuildState): this;
  59474. }
  59475. }
  59476. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59478. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59479. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59482. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59483. import { Effect } from "babylonjs/Materials/effect";
  59484. import { Mesh } from "babylonjs/Meshes/mesh";
  59485. import { Nullable } from "babylonjs/types";
  59486. import { Scene } from "babylonjs/scene";
  59487. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59488. /**
  59489. * Block used to read a reflection texture from a sampler
  59490. */
  59491. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59492. private _define3DName;
  59493. private _defineCubicName;
  59494. private _defineExplicitName;
  59495. private _defineProjectionName;
  59496. private _defineLocalCubicName;
  59497. private _defineSphericalName;
  59498. private _definePlanarName;
  59499. private _defineEquirectangularName;
  59500. private _defineMirroredEquirectangularFixedName;
  59501. private _defineEquirectangularFixedName;
  59502. private _defineSkyboxName;
  59503. private _cubeSamplerName;
  59504. private _2DSamplerName;
  59505. private _positionUVWName;
  59506. private _directionWName;
  59507. private _reflectionCoordsName;
  59508. private _reflection2DCoordsName;
  59509. private _reflectionColorName;
  59510. private _reflectionMatrixName;
  59511. /**
  59512. * Gets or sets the texture associated with the node
  59513. */
  59514. texture: Nullable<BaseTexture>;
  59515. /**
  59516. * Create a new TextureBlock
  59517. * @param name defines the block name
  59518. */
  59519. constructor(name: string);
  59520. /**
  59521. * Gets the current class name
  59522. * @returns the class name
  59523. */
  59524. getClassName(): string;
  59525. /**
  59526. * Gets the world position input component
  59527. */
  59528. get position(): NodeMaterialConnectionPoint;
  59529. /**
  59530. * Gets the world position input component
  59531. */
  59532. get worldPosition(): NodeMaterialConnectionPoint;
  59533. /**
  59534. * Gets the world normal input component
  59535. */
  59536. get worldNormal(): NodeMaterialConnectionPoint;
  59537. /**
  59538. * Gets the world input component
  59539. */
  59540. get world(): NodeMaterialConnectionPoint;
  59541. /**
  59542. * Gets the camera (or eye) position component
  59543. */
  59544. get cameraPosition(): NodeMaterialConnectionPoint;
  59545. /**
  59546. * Gets the view input component
  59547. */
  59548. get view(): NodeMaterialConnectionPoint;
  59549. /**
  59550. * Gets the rgb output component
  59551. */
  59552. get rgb(): NodeMaterialConnectionPoint;
  59553. /**
  59554. * Gets the r output component
  59555. */
  59556. get r(): NodeMaterialConnectionPoint;
  59557. /**
  59558. * Gets the g output component
  59559. */
  59560. get g(): NodeMaterialConnectionPoint;
  59561. /**
  59562. * Gets the b output component
  59563. */
  59564. get b(): NodeMaterialConnectionPoint;
  59565. autoConfigure(material: NodeMaterial): void;
  59566. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59567. isReady(): boolean;
  59568. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59569. private _injectVertexCode;
  59570. private _writeOutput;
  59571. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59572. protected _dumpPropertiesCode(): string;
  59573. serialize(): any;
  59574. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59575. }
  59576. }
  59577. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59579. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59580. import { Scene } from "babylonjs/scene";
  59581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59582. import { Matrix } from "babylonjs/Maths/math.vector";
  59583. import { Mesh } from "babylonjs/Meshes/mesh";
  59584. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59585. import { Observable } from "babylonjs/Misc/observable";
  59586. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59587. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59588. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59589. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59590. import { Nullable } from "babylonjs/types";
  59591. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59592. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59593. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59594. /**
  59595. * Interface used to configure the node material editor
  59596. */
  59597. export interface INodeMaterialEditorOptions {
  59598. /** Define the URl to load node editor script */
  59599. editorURL?: string;
  59600. }
  59601. /** @hidden */
  59602. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59603. NORMAL: boolean;
  59604. TANGENT: boolean;
  59605. UV1: boolean;
  59606. /** BONES */
  59607. NUM_BONE_INFLUENCERS: number;
  59608. BonesPerMesh: number;
  59609. BONETEXTURE: boolean;
  59610. /** MORPH TARGETS */
  59611. MORPHTARGETS: boolean;
  59612. MORPHTARGETS_NORMAL: boolean;
  59613. MORPHTARGETS_TANGENT: boolean;
  59614. MORPHTARGETS_UV: boolean;
  59615. NUM_MORPH_INFLUENCERS: number;
  59616. /** IMAGE PROCESSING */
  59617. IMAGEPROCESSING: boolean;
  59618. VIGNETTE: boolean;
  59619. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59620. VIGNETTEBLENDMODEOPAQUE: boolean;
  59621. TONEMAPPING: boolean;
  59622. TONEMAPPING_ACES: boolean;
  59623. CONTRAST: boolean;
  59624. EXPOSURE: boolean;
  59625. COLORCURVES: boolean;
  59626. COLORGRADING: boolean;
  59627. COLORGRADING3D: boolean;
  59628. SAMPLER3DGREENDEPTH: boolean;
  59629. SAMPLER3DBGRMAP: boolean;
  59630. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59631. /** MISC. */
  59632. BUMPDIRECTUV: number;
  59633. constructor();
  59634. setValue(name: string, value: boolean): void;
  59635. }
  59636. /**
  59637. * Class used to configure NodeMaterial
  59638. */
  59639. export interface INodeMaterialOptions {
  59640. /**
  59641. * Defines if blocks should emit comments
  59642. */
  59643. emitComments: boolean;
  59644. }
  59645. /**
  59646. * Class used to create a node based material built by assembling shader blocks
  59647. */
  59648. export class NodeMaterial extends PushMaterial {
  59649. private static _BuildIdGenerator;
  59650. private _options;
  59651. private _vertexCompilationState;
  59652. private _fragmentCompilationState;
  59653. private _sharedData;
  59654. private _buildId;
  59655. private _buildWasSuccessful;
  59656. private _cachedWorldViewMatrix;
  59657. private _cachedWorldViewProjectionMatrix;
  59658. private _optimizers;
  59659. private _animationFrame;
  59660. /** Define the Url to load node editor script */
  59661. static EditorURL: string;
  59662. /** Define the Url to load snippets */
  59663. static SnippetUrl: string;
  59664. private BJSNODEMATERIALEDITOR;
  59665. /** Get the inspector from bundle or global */
  59666. private _getGlobalNodeMaterialEditor;
  59667. /**
  59668. * Gets or sets data used by visual editor
  59669. * @see https://nme.babylonjs.com
  59670. */
  59671. editorData: any;
  59672. /**
  59673. * 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)
  59674. */
  59675. ignoreAlpha: boolean;
  59676. /**
  59677. * Defines the maximum number of lights that can be used in the material
  59678. */
  59679. maxSimultaneousLights: number;
  59680. /**
  59681. * Observable raised when the material is built
  59682. */
  59683. onBuildObservable: Observable<NodeMaterial>;
  59684. /**
  59685. * Gets or sets the root nodes of the material vertex shader
  59686. */
  59687. _vertexOutputNodes: NodeMaterialBlock[];
  59688. /**
  59689. * Gets or sets the root nodes of the material fragment (pixel) shader
  59690. */
  59691. _fragmentOutputNodes: NodeMaterialBlock[];
  59692. /** Gets or sets options to control the node material overall behavior */
  59693. get options(): INodeMaterialOptions;
  59694. set options(options: INodeMaterialOptions);
  59695. /**
  59696. * Default configuration related to image processing available in the standard Material.
  59697. */
  59698. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59699. /**
  59700. * Gets the image processing configuration used either in this material.
  59701. */
  59702. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59703. /**
  59704. * Sets the Default image processing configuration used either in the this material.
  59705. *
  59706. * If sets to null, the scene one is in use.
  59707. */
  59708. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59709. /**
  59710. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59711. */
  59712. attachedBlocks: NodeMaterialBlock[];
  59713. /**
  59714. * Create a new node based material
  59715. * @param name defines the material name
  59716. * @param scene defines the hosting scene
  59717. * @param options defines creation option
  59718. */
  59719. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59720. /**
  59721. * Gets the current class name of the material e.g. "NodeMaterial"
  59722. * @returns the class name
  59723. */
  59724. getClassName(): string;
  59725. /**
  59726. * Keep track of the image processing observer to allow dispose and replace.
  59727. */
  59728. private _imageProcessingObserver;
  59729. /**
  59730. * Attaches a new image processing configuration to the Standard Material.
  59731. * @param configuration
  59732. */
  59733. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59734. /**
  59735. * Get a block by its name
  59736. * @param name defines the name of the block to retrieve
  59737. * @returns the required block or null if not found
  59738. */
  59739. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59740. /**
  59741. * Get a block by its name
  59742. * @param predicate defines the predicate used to find the good candidate
  59743. * @returns the required block or null if not found
  59744. */
  59745. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59746. /**
  59747. * Get an input block by its name
  59748. * @param predicate defines the predicate used to find the good candidate
  59749. * @returns the required input block or null if not found
  59750. */
  59751. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59752. /**
  59753. * Gets the list of input blocks attached to this material
  59754. * @returns an array of InputBlocks
  59755. */
  59756. getInputBlocks(): InputBlock[];
  59757. /**
  59758. * Adds a new optimizer to the list of optimizers
  59759. * @param optimizer defines the optimizers to add
  59760. * @returns the current material
  59761. */
  59762. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59763. /**
  59764. * Remove an optimizer from the list of optimizers
  59765. * @param optimizer defines the optimizers to remove
  59766. * @returns the current material
  59767. */
  59768. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59769. /**
  59770. * Add a new block to the list of output nodes
  59771. * @param node defines the node to add
  59772. * @returns the current material
  59773. */
  59774. addOutputNode(node: NodeMaterialBlock): this;
  59775. /**
  59776. * Remove a block from the list of root nodes
  59777. * @param node defines the node to remove
  59778. * @returns the current material
  59779. */
  59780. removeOutputNode(node: NodeMaterialBlock): this;
  59781. private _addVertexOutputNode;
  59782. private _removeVertexOutputNode;
  59783. private _addFragmentOutputNode;
  59784. private _removeFragmentOutputNode;
  59785. /**
  59786. * Specifies if the material will require alpha blending
  59787. * @returns a boolean specifying if alpha blending is needed
  59788. */
  59789. needAlphaBlending(): boolean;
  59790. /**
  59791. * Specifies if this material should be rendered in alpha test mode
  59792. * @returns a boolean specifying if an alpha test is needed.
  59793. */
  59794. needAlphaTesting(): boolean;
  59795. private _initializeBlock;
  59796. private _resetDualBlocks;
  59797. /**
  59798. * Remove a block from the current node material
  59799. * @param block defines the block to remove
  59800. */
  59801. removeBlock(block: NodeMaterialBlock): void;
  59802. /**
  59803. * Build the material and generates the inner effect
  59804. * @param verbose defines if the build should log activity
  59805. */
  59806. build(verbose?: boolean): void;
  59807. /**
  59808. * Runs an otpimization phase to try to improve the shader code
  59809. */
  59810. optimize(): void;
  59811. private _prepareDefinesForAttributes;
  59812. /**
  59813. * Get if the submesh is ready to be used and all its information available.
  59814. * Child classes can use it to update shaders
  59815. * @param mesh defines the mesh to check
  59816. * @param subMesh defines which submesh to check
  59817. * @param useInstances specifies that instances should be used
  59818. * @returns a boolean indicating that the submesh is ready or not
  59819. */
  59820. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59821. /**
  59822. * Get a string representing the shaders built by the current node graph
  59823. */
  59824. get compiledShaders(): string;
  59825. /**
  59826. * Binds the world matrix to the material
  59827. * @param world defines the world transformation matrix
  59828. */
  59829. bindOnlyWorldMatrix(world: Matrix): void;
  59830. /**
  59831. * Binds the submesh to this material by preparing the effect and shader to draw
  59832. * @param world defines the world transformation matrix
  59833. * @param mesh defines the mesh containing the submesh
  59834. * @param subMesh defines the submesh to bind the material to
  59835. */
  59836. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59837. /**
  59838. * Gets the active textures from the material
  59839. * @returns an array of textures
  59840. */
  59841. getActiveTextures(): BaseTexture[];
  59842. /**
  59843. * Gets the list of texture blocks
  59844. * @returns an array of texture blocks
  59845. */
  59846. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59847. /**
  59848. * Specifies if the material uses a texture
  59849. * @param texture defines the texture to check against the material
  59850. * @returns a boolean specifying if the material uses the texture
  59851. */
  59852. hasTexture(texture: BaseTexture): boolean;
  59853. /**
  59854. * Disposes the material
  59855. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59856. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59857. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59858. */
  59859. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59860. /** Creates the node editor window. */
  59861. private _createNodeEditor;
  59862. /**
  59863. * Launch the node material editor
  59864. * @param config Define the configuration of the editor
  59865. * @return a promise fulfilled when the node editor is visible
  59866. */
  59867. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59868. /**
  59869. * Clear the current material
  59870. */
  59871. clear(): void;
  59872. /**
  59873. * Clear the current material and set it to a default state
  59874. */
  59875. setToDefault(): void;
  59876. /**
  59877. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59878. * @param url defines the url to load from
  59879. * @returns a promise that will fullfil when the material is fully loaded
  59880. */
  59881. loadAsync(url: string): Promise<void>;
  59882. private _gatherBlocks;
  59883. /**
  59884. * Generate a string containing the code declaration required to create an equivalent of this material
  59885. * @returns a string
  59886. */
  59887. generateCode(): string;
  59888. /**
  59889. * Serializes this material in a JSON representation
  59890. * @returns the serialized material object
  59891. */
  59892. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59893. private _restoreConnections;
  59894. /**
  59895. * Clear the current graph and load a new one from a serialization object
  59896. * @param source defines the JSON representation of the material
  59897. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59898. */
  59899. loadFromSerialization(source: any, rootUrl?: string): void;
  59900. /**
  59901. * Creates a node material from parsed material data
  59902. * @param source defines the JSON representation of the material
  59903. * @param scene defines the hosting scene
  59904. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59905. * @returns a new node material
  59906. */
  59907. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59908. /**
  59909. * Creates a node material from a snippet saved in a remote file
  59910. * @param name defines the name of the material to create
  59911. * @param url defines the url to load from
  59912. * @param scene defines the hosting scene
  59913. * @returns a promise that will resolve to the new node material
  59914. */
  59915. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59916. /**
  59917. * Creates a node material from a snippet saved by the node material editor
  59918. * @param snippetId defines the snippet to load
  59919. * @param scene defines the hosting scene
  59920. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59921. * @returns a promise that will resolve to the new node material
  59922. */
  59923. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59924. /**
  59925. * Creates a new node material set to default basic configuration
  59926. * @param name defines the name of the material
  59927. * @param scene defines the hosting scene
  59928. * @returns a new NodeMaterial
  59929. */
  59930. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59931. }
  59932. }
  59933. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59934. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59936. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59939. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59940. import { Effect } from "babylonjs/Materials/effect";
  59941. import { Mesh } from "babylonjs/Meshes/mesh";
  59942. import { Nullable } from "babylonjs/types";
  59943. import { Texture } from "babylonjs/Materials/Textures/texture";
  59944. import { Scene } from "babylonjs/scene";
  59945. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59946. /**
  59947. * Block used to read a texture from a sampler
  59948. */
  59949. export class TextureBlock extends NodeMaterialBlock {
  59950. private _defineName;
  59951. private _linearDefineName;
  59952. private _tempTextureRead;
  59953. private _samplerName;
  59954. private _transformedUVName;
  59955. private _textureTransformName;
  59956. private _textureInfoName;
  59957. private _mainUVName;
  59958. private _mainUVDefineName;
  59959. /**
  59960. * Gets or sets the texture associated with the node
  59961. */
  59962. texture: Nullable<Texture>;
  59963. /**
  59964. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59965. */
  59966. convertToGammaSpace: boolean;
  59967. /**
  59968. * Create a new TextureBlock
  59969. * @param name defines the block name
  59970. */
  59971. constructor(name: string);
  59972. /**
  59973. * Gets the current class name
  59974. * @returns the class name
  59975. */
  59976. getClassName(): string;
  59977. /**
  59978. * Gets the uv input component
  59979. */
  59980. get uv(): NodeMaterialConnectionPoint;
  59981. /**
  59982. * Gets the rgba output component
  59983. */
  59984. get rgba(): NodeMaterialConnectionPoint;
  59985. /**
  59986. * Gets the rgb output component
  59987. */
  59988. get rgb(): NodeMaterialConnectionPoint;
  59989. /**
  59990. * Gets the r output component
  59991. */
  59992. get r(): NodeMaterialConnectionPoint;
  59993. /**
  59994. * Gets the g output component
  59995. */
  59996. get g(): NodeMaterialConnectionPoint;
  59997. /**
  59998. * Gets the b output component
  59999. */
  60000. get b(): NodeMaterialConnectionPoint;
  60001. /**
  60002. * Gets the a output component
  60003. */
  60004. get a(): NodeMaterialConnectionPoint;
  60005. get target(): NodeMaterialBlockTargets;
  60006. autoConfigure(material: NodeMaterial): void;
  60007. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60008. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60009. isReady(): boolean;
  60010. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60011. private get _isMixed();
  60012. private _injectVertexCode;
  60013. private _writeTextureRead;
  60014. private _writeOutput;
  60015. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60016. protected _dumpPropertiesCode(): string;
  60017. serialize(): any;
  60018. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60019. }
  60020. }
  60021. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60024. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60025. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60026. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60027. import { Scene } from "babylonjs/scene";
  60028. /**
  60029. * Class used to store shared data between 2 NodeMaterialBuildState
  60030. */
  60031. export class NodeMaterialBuildStateSharedData {
  60032. /**
  60033. * Gets the list of emitted varyings
  60034. */
  60035. temps: string[];
  60036. /**
  60037. * Gets the list of emitted varyings
  60038. */
  60039. varyings: string[];
  60040. /**
  60041. * Gets the varying declaration string
  60042. */
  60043. varyingDeclaration: string;
  60044. /**
  60045. * Input blocks
  60046. */
  60047. inputBlocks: InputBlock[];
  60048. /**
  60049. * Input blocks
  60050. */
  60051. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60052. /**
  60053. * Bindable blocks (Blocks that need to set data to the effect)
  60054. */
  60055. bindableBlocks: NodeMaterialBlock[];
  60056. /**
  60057. * List of blocks that can provide a compilation fallback
  60058. */
  60059. blocksWithFallbacks: NodeMaterialBlock[];
  60060. /**
  60061. * List of blocks that can provide a define update
  60062. */
  60063. blocksWithDefines: NodeMaterialBlock[];
  60064. /**
  60065. * List of blocks that can provide a repeatable content
  60066. */
  60067. repeatableContentBlocks: NodeMaterialBlock[];
  60068. /**
  60069. * List of blocks that can provide a dynamic list of uniforms
  60070. */
  60071. dynamicUniformBlocks: NodeMaterialBlock[];
  60072. /**
  60073. * List of blocks that can block the isReady function for the material
  60074. */
  60075. blockingBlocks: NodeMaterialBlock[];
  60076. /**
  60077. * Gets the list of animated inputs
  60078. */
  60079. animatedInputs: InputBlock[];
  60080. /**
  60081. * Build Id used to avoid multiple recompilations
  60082. */
  60083. buildId: number;
  60084. /** List of emitted variables */
  60085. variableNames: {
  60086. [key: string]: number;
  60087. };
  60088. /** List of emitted defines */
  60089. defineNames: {
  60090. [key: string]: number;
  60091. };
  60092. /** Should emit comments? */
  60093. emitComments: boolean;
  60094. /** Emit build activity */
  60095. verbose: boolean;
  60096. /** Gets or sets the hosting scene */
  60097. scene: Scene;
  60098. /**
  60099. * Gets the compilation hints emitted at compilation time
  60100. */
  60101. hints: {
  60102. needWorldViewMatrix: boolean;
  60103. needWorldViewProjectionMatrix: boolean;
  60104. needAlphaBlending: boolean;
  60105. needAlphaTesting: boolean;
  60106. };
  60107. /**
  60108. * List of compilation checks
  60109. */
  60110. checks: {
  60111. emitVertex: boolean;
  60112. emitFragment: boolean;
  60113. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60114. };
  60115. /** Creates a new shared data */
  60116. constructor();
  60117. /**
  60118. * Emits console errors and exceptions if there is a failing check
  60119. */
  60120. emitErrors(): void;
  60121. }
  60122. }
  60123. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60124. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60125. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60126. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60127. /**
  60128. * Class used to store node based material build state
  60129. */
  60130. export class NodeMaterialBuildState {
  60131. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60132. supportUniformBuffers: boolean;
  60133. /**
  60134. * Gets the list of emitted attributes
  60135. */
  60136. attributes: string[];
  60137. /**
  60138. * Gets the list of emitted uniforms
  60139. */
  60140. uniforms: string[];
  60141. /**
  60142. * Gets the list of emitted constants
  60143. */
  60144. constants: string[];
  60145. /**
  60146. * Gets the list of emitted samplers
  60147. */
  60148. samplers: string[];
  60149. /**
  60150. * Gets the list of emitted functions
  60151. */
  60152. functions: {
  60153. [key: string]: string;
  60154. };
  60155. /**
  60156. * Gets the list of emitted extensions
  60157. */
  60158. extensions: {
  60159. [key: string]: string;
  60160. };
  60161. /**
  60162. * Gets the target of the compilation state
  60163. */
  60164. target: NodeMaterialBlockTargets;
  60165. /**
  60166. * Gets the list of emitted counters
  60167. */
  60168. counters: {
  60169. [key: string]: number;
  60170. };
  60171. /**
  60172. * Shared data between multiple NodeMaterialBuildState instances
  60173. */
  60174. sharedData: NodeMaterialBuildStateSharedData;
  60175. /** @hidden */
  60176. _vertexState: NodeMaterialBuildState;
  60177. /** @hidden */
  60178. _attributeDeclaration: string;
  60179. /** @hidden */
  60180. _uniformDeclaration: string;
  60181. /** @hidden */
  60182. _constantDeclaration: string;
  60183. /** @hidden */
  60184. _samplerDeclaration: string;
  60185. /** @hidden */
  60186. _varyingTransfer: string;
  60187. private _repeatableContentAnchorIndex;
  60188. /** @hidden */
  60189. _builtCompilationString: string;
  60190. /**
  60191. * Gets the emitted compilation strings
  60192. */
  60193. compilationString: string;
  60194. /**
  60195. * Finalize the compilation strings
  60196. * @param state defines the current compilation state
  60197. */
  60198. finalize(state: NodeMaterialBuildState): void;
  60199. /** @hidden */
  60200. get _repeatableContentAnchor(): string;
  60201. /** @hidden */
  60202. _getFreeVariableName(prefix: string): string;
  60203. /** @hidden */
  60204. _getFreeDefineName(prefix: string): string;
  60205. /** @hidden */
  60206. _excludeVariableName(name: string): void;
  60207. /** @hidden */
  60208. _emit2DSampler(name: string): void;
  60209. /** @hidden */
  60210. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60211. /** @hidden */
  60212. _emitExtension(name: string, extension: string): void;
  60213. /** @hidden */
  60214. _emitFunction(name: string, code: string, comments: string): void;
  60215. /** @hidden */
  60216. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60217. replaceStrings?: {
  60218. search: RegExp;
  60219. replace: string;
  60220. }[];
  60221. repeatKey?: string;
  60222. }): string;
  60223. /** @hidden */
  60224. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60225. repeatKey?: string;
  60226. removeAttributes?: boolean;
  60227. removeUniforms?: boolean;
  60228. removeVaryings?: boolean;
  60229. removeIfDef?: boolean;
  60230. replaceStrings?: {
  60231. search: RegExp;
  60232. replace: string;
  60233. }[];
  60234. }, storeKey?: string): void;
  60235. /** @hidden */
  60236. _registerTempVariable(name: string): boolean;
  60237. /** @hidden */
  60238. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60239. /** @hidden */
  60240. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60241. /** @hidden */
  60242. _emitFloat(value: number): string;
  60243. }
  60244. }
  60245. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60246. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60248. import { Nullable } from "babylonjs/types";
  60249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60250. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60251. import { Effect } from "babylonjs/Materials/effect";
  60252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60253. import { Mesh } from "babylonjs/Meshes/mesh";
  60254. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60255. import { Scene } from "babylonjs/scene";
  60256. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60257. /**
  60258. * Defines a block that can be used inside a node based material
  60259. */
  60260. export class NodeMaterialBlock {
  60261. private _buildId;
  60262. private _buildTarget;
  60263. private _target;
  60264. private _isFinalMerger;
  60265. private _isInput;
  60266. protected _isUnique: boolean;
  60267. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60268. inputsAreExclusive: boolean;
  60269. /** @hidden */
  60270. _codeVariableName: string;
  60271. /** @hidden */
  60272. _inputs: NodeMaterialConnectionPoint[];
  60273. /** @hidden */
  60274. _outputs: NodeMaterialConnectionPoint[];
  60275. /** @hidden */
  60276. _preparationId: number;
  60277. /**
  60278. * Gets or sets the name of the block
  60279. */
  60280. name: string;
  60281. /**
  60282. * Gets or sets the unique id of the node
  60283. */
  60284. uniqueId: number;
  60285. /**
  60286. * Gets or sets the comments associated with this block
  60287. */
  60288. comments: string;
  60289. /**
  60290. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60291. */
  60292. get isUnique(): boolean;
  60293. /**
  60294. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60295. */
  60296. get isFinalMerger(): boolean;
  60297. /**
  60298. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60299. */
  60300. get isInput(): boolean;
  60301. /**
  60302. * Gets or sets the build Id
  60303. */
  60304. get buildId(): number;
  60305. set buildId(value: number);
  60306. /**
  60307. * Gets or sets the target of the block
  60308. */
  60309. get target(): NodeMaterialBlockTargets;
  60310. set target(value: NodeMaterialBlockTargets);
  60311. /**
  60312. * Gets the list of input points
  60313. */
  60314. get inputs(): NodeMaterialConnectionPoint[];
  60315. /** Gets the list of output points */
  60316. get outputs(): NodeMaterialConnectionPoint[];
  60317. /**
  60318. * Find an input by its name
  60319. * @param name defines the name of the input to look for
  60320. * @returns the input or null if not found
  60321. */
  60322. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60323. /**
  60324. * Find an output by its name
  60325. * @param name defines the name of the outputto look for
  60326. * @returns the output or null if not found
  60327. */
  60328. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60329. /**
  60330. * Creates a new NodeMaterialBlock
  60331. * @param name defines the block name
  60332. * @param target defines the target of that block (Vertex by default)
  60333. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60334. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60335. */
  60336. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60337. /**
  60338. * Initialize the block and prepare the context for build
  60339. * @param state defines the state that will be used for the build
  60340. */
  60341. initialize(state: NodeMaterialBuildState): void;
  60342. /**
  60343. * Bind data to effect. Will only be called for blocks with isBindable === true
  60344. * @param effect defines the effect to bind data to
  60345. * @param nodeMaterial defines the hosting NodeMaterial
  60346. * @param mesh defines the mesh that will be rendered
  60347. */
  60348. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60349. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60350. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60351. protected _writeFloat(value: number): string;
  60352. /**
  60353. * Gets the current class name e.g. "NodeMaterialBlock"
  60354. * @returns the class name
  60355. */
  60356. getClassName(): string;
  60357. /**
  60358. * Register a new input. Must be called inside a block constructor
  60359. * @param name defines the connection point name
  60360. * @param type defines the connection point type
  60361. * @param isOptional defines a boolean indicating that this input can be omitted
  60362. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60363. * @returns the current block
  60364. */
  60365. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60366. /**
  60367. * Register a new output. Must be called inside a block constructor
  60368. * @param name defines the connection point name
  60369. * @param type defines the connection point type
  60370. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60371. * @returns the current block
  60372. */
  60373. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60374. /**
  60375. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60376. * @param forOutput defines an optional connection point to check compatibility with
  60377. * @returns the first available input or null
  60378. */
  60379. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60380. /**
  60381. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60382. * @param forBlock defines an optional block to check compatibility with
  60383. * @returns the first available input or null
  60384. */
  60385. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60386. /**
  60387. * Gets the sibling of the given output
  60388. * @param current defines the current output
  60389. * @returns the next output in the list or null
  60390. */
  60391. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60392. /**
  60393. * Connect current block with another block
  60394. * @param other defines the block to connect with
  60395. * @param options define the various options to help pick the right connections
  60396. * @returns the current block
  60397. */
  60398. connectTo(other: NodeMaterialBlock, options?: {
  60399. input?: string;
  60400. output?: string;
  60401. outputSwizzle?: string;
  60402. }): this | undefined;
  60403. protected _buildBlock(state: NodeMaterialBuildState): void;
  60404. /**
  60405. * Add uniforms, samplers and uniform buffers at compilation time
  60406. * @param state defines the state to update
  60407. * @param nodeMaterial defines the node material requesting the update
  60408. * @param defines defines the material defines to update
  60409. * @param uniformBuffers defines the list of uniform buffer names
  60410. */
  60411. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60412. /**
  60413. * Add potential fallbacks if shader compilation fails
  60414. * @param mesh defines the mesh to be rendered
  60415. * @param fallbacks defines the current prioritized list of fallbacks
  60416. */
  60417. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60418. /**
  60419. * Initialize defines for shader compilation
  60420. * @param mesh defines the mesh to be rendered
  60421. * @param nodeMaterial defines the node material requesting the update
  60422. * @param defines defines the material defines to update
  60423. * @param useInstances specifies that instances should be used
  60424. */
  60425. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60426. /**
  60427. * Update defines for shader compilation
  60428. * @param mesh defines the mesh to be rendered
  60429. * @param nodeMaterial defines the node material requesting the update
  60430. * @param defines defines the material defines to update
  60431. * @param useInstances specifies that instances should be used
  60432. */
  60433. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60434. /**
  60435. * Lets the block try to connect some inputs automatically
  60436. * @param material defines the hosting NodeMaterial
  60437. */
  60438. autoConfigure(material: NodeMaterial): void;
  60439. /**
  60440. * Function called when a block is declared as repeatable content generator
  60441. * @param vertexShaderState defines the current compilation state for the vertex shader
  60442. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60443. * @param mesh defines the mesh to be rendered
  60444. * @param defines defines the material defines to update
  60445. */
  60446. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60447. /**
  60448. * Checks if the block is ready
  60449. * @param mesh defines the mesh to be rendered
  60450. * @param nodeMaterial defines the node material requesting the update
  60451. * @param defines defines the material defines to update
  60452. * @param useInstances specifies that instances should be used
  60453. * @returns true if the block is ready
  60454. */
  60455. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60456. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60457. private _processBuild;
  60458. /**
  60459. * Compile the current node and generate the shader code
  60460. * @param state defines the current compilation state (uniforms, samplers, current string)
  60461. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60462. * @returns true if already built
  60463. */
  60464. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60465. protected _inputRename(name: string): string;
  60466. protected _outputRename(name: string): string;
  60467. protected _dumpPropertiesCode(): string;
  60468. /** @hidden */
  60469. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60470. /** @hidden */
  60471. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60472. /**
  60473. * Clone the current block to a new identical block
  60474. * @param scene defines the hosting scene
  60475. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60476. * @returns a copy of the current block
  60477. */
  60478. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60479. /**
  60480. * Serializes this block in a JSON representation
  60481. * @returns the serialized block object
  60482. */
  60483. serialize(): any;
  60484. /** @hidden */
  60485. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60486. /**
  60487. * Release resources
  60488. */
  60489. dispose(): void;
  60490. }
  60491. }
  60492. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60493. /**
  60494. * Enum defining the type of animations supported by InputBlock
  60495. */
  60496. export enum AnimatedInputBlockTypes {
  60497. /** No animation */
  60498. None = 0,
  60499. /** Time based animation. Will only work for floats */
  60500. Time = 1
  60501. }
  60502. }
  60503. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60505. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60506. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60507. import { Nullable } from "babylonjs/types";
  60508. import { Effect } from "babylonjs/Materials/effect";
  60509. import { Matrix } from "babylonjs/Maths/math.vector";
  60510. import { Scene } from "babylonjs/scene";
  60511. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60512. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60513. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60514. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60515. import { Observable } from "babylonjs/Misc/observable";
  60516. /**
  60517. * Block used to expose an input value
  60518. */
  60519. export class InputBlock extends NodeMaterialBlock {
  60520. private _mode;
  60521. private _associatedVariableName;
  60522. private _storedValue;
  60523. private _valueCallback;
  60524. private _type;
  60525. private _animationType;
  60526. /** Gets or set a value used to limit the range of float values */
  60527. min: number;
  60528. /** Gets or set a value used to limit the range of float values */
  60529. max: number;
  60530. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60531. isBoolean: boolean;
  60532. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60533. matrixMode: number;
  60534. /** @hidden */
  60535. _systemValue: Nullable<NodeMaterialSystemValues>;
  60536. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60537. visibleInInspector: boolean;
  60538. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60539. isConstant: boolean;
  60540. /** Gets or sets the group to use to display this block in the Inspector */
  60541. groupInInspector: string;
  60542. /** Gets an observable raised when the value is changed */
  60543. onValueChangedObservable: Observable<InputBlock>;
  60544. /**
  60545. * Gets or sets the connection point type (default is float)
  60546. */
  60547. get type(): NodeMaterialBlockConnectionPointTypes;
  60548. /**
  60549. * Creates a new InputBlock
  60550. * @param name defines the block name
  60551. * @param target defines the target of that block (Vertex by default)
  60552. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60553. */
  60554. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60555. /**
  60556. * Gets the output component
  60557. */
  60558. get output(): NodeMaterialConnectionPoint;
  60559. /**
  60560. * Set the source of this connection point to a vertex attribute
  60561. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60562. * @returns the current connection point
  60563. */
  60564. setAsAttribute(attributeName?: string): InputBlock;
  60565. /**
  60566. * Set the source of this connection point to a system value
  60567. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60568. * @returns the current connection point
  60569. */
  60570. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60571. /**
  60572. * Gets or sets the value of that point.
  60573. * Please note that this value will be ignored if valueCallback is defined
  60574. */
  60575. get value(): any;
  60576. set value(value: any);
  60577. /**
  60578. * Gets or sets a callback used to get the value of that point.
  60579. * Please note that setting this value will force the connection point to ignore the value property
  60580. */
  60581. get valueCallback(): () => any;
  60582. set valueCallback(value: () => any);
  60583. /**
  60584. * Gets or sets the associated variable name in the shader
  60585. */
  60586. get associatedVariableName(): string;
  60587. set associatedVariableName(value: string);
  60588. /** Gets or sets the type of animation applied to the input */
  60589. get animationType(): AnimatedInputBlockTypes;
  60590. set animationType(value: AnimatedInputBlockTypes);
  60591. /**
  60592. * Gets a boolean indicating that this connection point not defined yet
  60593. */
  60594. get isUndefined(): boolean;
  60595. /**
  60596. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60597. * In this case the connection point name must be the name of the uniform to use.
  60598. * Can only be set on inputs
  60599. */
  60600. get isUniform(): boolean;
  60601. set isUniform(value: boolean);
  60602. /**
  60603. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60604. * In this case the connection point name must be the name of the attribute to use
  60605. * Can only be set on inputs
  60606. */
  60607. get isAttribute(): boolean;
  60608. set isAttribute(value: boolean);
  60609. /**
  60610. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60611. * Can only be set on exit points
  60612. */
  60613. get isVarying(): boolean;
  60614. set isVarying(value: boolean);
  60615. /**
  60616. * Gets a boolean indicating that the current connection point is a system value
  60617. */
  60618. get isSystemValue(): boolean;
  60619. /**
  60620. * Gets or sets the current well known value or null if not defined as a system value
  60621. */
  60622. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60623. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60624. /**
  60625. * Gets the current class name
  60626. * @returns the class name
  60627. */
  60628. getClassName(): string;
  60629. /**
  60630. * Animate the input if animationType !== None
  60631. * @param scene defines the rendering scene
  60632. */
  60633. animate(scene: Scene): void;
  60634. private _emitDefine;
  60635. initialize(state: NodeMaterialBuildState): void;
  60636. /**
  60637. * Set the input block to its default value (based on its type)
  60638. */
  60639. setDefaultValue(): void;
  60640. private _emitConstant;
  60641. private _emit;
  60642. /** @hidden */
  60643. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60644. /** @hidden */
  60645. _transmit(effect: Effect, scene: Scene): void;
  60646. protected _buildBlock(state: NodeMaterialBuildState): void;
  60647. protected _dumpPropertiesCode(): string;
  60648. dispose(): void;
  60649. serialize(): any;
  60650. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60651. }
  60652. }
  60653. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60654. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60655. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60656. import { Nullable } from "babylonjs/types";
  60657. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60658. import { Observable } from "babylonjs/Misc/observable";
  60659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60660. /**
  60661. * Enum used to define the compatibility state between two connection points
  60662. */
  60663. export enum NodeMaterialConnectionPointCompatibilityStates {
  60664. /** Points are compatibles */
  60665. Compatible = 0,
  60666. /** Points are incompatible because of their types */
  60667. TypeIncompatible = 1,
  60668. /** Points are incompatible because of their targets (vertex vs fragment) */
  60669. TargetIncompatible = 2
  60670. }
  60671. /**
  60672. * Defines the direction of a connection point
  60673. */
  60674. export enum NodeMaterialConnectionPointDirection {
  60675. /** Input */
  60676. Input = 0,
  60677. /** Output */
  60678. Output = 1
  60679. }
  60680. /**
  60681. * Defines a connection point for a block
  60682. */
  60683. export class NodeMaterialConnectionPoint {
  60684. /** @hidden */
  60685. _ownerBlock: NodeMaterialBlock;
  60686. /** @hidden */
  60687. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60688. private _endpoints;
  60689. private _associatedVariableName;
  60690. private _direction;
  60691. /** @hidden */
  60692. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60693. /** @hidden */
  60694. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60695. private _type;
  60696. /** @hidden */
  60697. _enforceAssociatedVariableName: boolean;
  60698. /** Gets the direction of the point */
  60699. get direction(): NodeMaterialConnectionPointDirection;
  60700. /**
  60701. * Gets or sets the additional types supported by this connection point
  60702. */
  60703. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60704. /**
  60705. * Gets or sets the additional types excluded by this connection point
  60706. */
  60707. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60708. /**
  60709. * Observable triggered when this point is connected
  60710. */
  60711. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60712. /**
  60713. * Gets or sets the associated variable name in the shader
  60714. */
  60715. get associatedVariableName(): string;
  60716. set associatedVariableName(value: string);
  60717. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60718. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60719. /**
  60720. * Gets or sets the connection point type (default is float)
  60721. */
  60722. get type(): NodeMaterialBlockConnectionPointTypes;
  60723. set type(value: NodeMaterialBlockConnectionPointTypes);
  60724. /**
  60725. * Gets or sets the connection point name
  60726. */
  60727. name: string;
  60728. /**
  60729. * Gets or sets a boolean indicating that this connection point can be omitted
  60730. */
  60731. isOptional: boolean;
  60732. /**
  60733. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60734. */
  60735. define: string;
  60736. /** @hidden */
  60737. _prioritizeVertex: boolean;
  60738. private _target;
  60739. /** Gets or sets the target of that connection point */
  60740. get target(): NodeMaterialBlockTargets;
  60741. set target(value: NodeMaterialBlockTargets);
  60742. /**
  60743. * Gets a boolean indicating that the current point is connected
  60744. */
  60745. get isConnected(): boolean;
  60746. /**
  60747. * Gets a boolean indicating that the current point is connected to an input block
  60748. */
  60749. get isConnectedToInputBlock(): boolean;
  60750. /**
  60751. * Gets a the connected input block (if any)
  60752. */
  60753. get connectInputBlock(): Nullable<InputBlock>;
  60754. /** Get the other side of the connection (if any) */
  60755. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60756. /** Get the block that owns this connection point */
  60757. get ownerBlock(): NodeMaterialBlock;
  60758. /** Get the block connected on the other side of this connection (if any) */
  60759. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60760. /** Get the block connected on the endpoints of this connection (if any) */
  60761. get connectedBlocks(): Array<NodeMaterialBlock>;
  60762. /** Gets the list of connected endpoints */
  60763. get endpoints(): NodeMaterialConnectionPoint[];
  60764. /** Gets a boolean indicating if that output point is connected to at least one input */
  60765. get hasEndpoints(): boolean;
  60766. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60767. get isConnectedInVertexShader(): boolean;
  60768. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60769. get isConnectedInFragmentShader(): boolean;
  60770. /**
  60771. * Creates a new connection point
  60772. * @param name defines the connection point name
  60773. * @param ownerBlock defines the block hosting this connection point
  60774. * @param direction defines the direction of the connection point
  60775. */
  60776. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60777. /**
  60778. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60779. * @returns the class name
  60780. */
  60781. getClassName(): string;
  60782. /**
  60783. * Gets a boolean indicating if the current point can be connected to another point
  60784. * @param connectionPoint defines the other connection point
  60785. * @returns a boolean
  60786. */
  60787. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60788. /**
  60789. * Gets a number indicating if the current point can be connected to another point
  60790. * @param connectionPoint defines the other connection point
  60791. * @returns a number defining the compatibility state
  60792. */
  60793. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60794. /**
  60795. * Connect this point to another connection point
  60796. * @param connectionPoint defines the other connection point
  60797. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60798. * @returns the current connection point
  60799. */
  60800. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60801. /**
  60802. * Disconnect this point from one of his endpoint
  60803. * @param endpoint defines the other connection point
  60804. * @returns the current connection point
  60805. */
  60806. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60807. /**
  60808. * Serializes this point in a JSON representation
  60809. * @returns the serialized point object
  60810. */
  60811. serialize(): any;
  60812. /**
  60813. * Release resources
  60814. */
  60815. dispose(): void;
  60816. }
  60817. }
  60818. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60819. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60820. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60822. import { Mesh } from "babylonjs/Meshes/mesh";
  60823. import { Effect } from "babylonjs/Materials/effect";
  60824. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60825. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60826. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60827. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60828. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60829. /**
  60830. * Block used to add support for vertex skinning (bones)
  60831. */
  60832. export class BonesBlock extends NodeMaterialBlock {
  60833. /**
  60834. * Creates a new BonesBlock
  60835. * @param name defines the block name
  60836. */
  60837. constructor(name: string);
  60838. /**
  60839. * Initialize the block and prepare the context for build
  60840. * @param state defines the state that will be used for the build
  60841. */
  60842. initialize(state: NodeMaterialBuildState): void;
  60843. /**
  60844. * Gets the current class name
  60845. * @returns the class name
  60846. */
  60847. getClassName(): string;
  60848. /**
  60849. * Gets the matrix indices input component
  60850. */
  60851. get matricesIndices(): NodeMaterialConnectionPoint;
  60852. /**
  60853. * Gets the matrix weights input component
  60854. */
  60855. get matricesWeights(): NodeMaterialConnectionPoint;
  60856. /**
  60857. * Gets the extra matrix indices input component
  60858. */
  60859. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60860. /**
  60861. * Gets the extra matrix weights input component
  60862. */
  60863. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60864. /**
  60865. * Gets the world input component
  60866. */
  60867. get world(): NodeMaterialConnectionPoint;
  60868. /**
  60869. * Gets the output component
  60870. */
  60871. get output(): NodeMaterialConnectionPoint;
  60872. autoConfigure(material: NodeMaterial): void;
  60873. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60874. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60875. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60876. protected _buildBlock(state: NodeMaterialBuildState): this;
  60877. }
  60878. }
  60879. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60880. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60881. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60884. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60885. /**
  60886. * Block used to add support for instances
  60887. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60888. */
  60889. export class InstancesBlock extends NodeMaterialBlock {
  60890. /**
  60891. * Creates a new InstancesBlock
  60892. * @param name defines the block name
  60893. */
  60894. constructor(name: string);
  60895. /**
  60896. * Gets the current class name
  60897. * @returns the class name
  60898. */
  60899. getClassName(): string;
  60900. /**
  60901. * Gets the first world row input component
  60902. */
  60903. get world0(): NodeMaterialConnectionPoint;
  60904. /**
  60905. * Gets the second world row input component
  60906. */
  60907. get world1(): NodeMaterialConnectionPoint;
  60908. /**
  60909. * Gets the third world row input component
  60910. */
  60911. get world2(): NodeMaterialConnectionPoint;
  60912. /**
  60913. * Gets the forth world row input component
  60914. */
  60915. get world3(): NodeMaterialConnectionPoint;
  60916. /**
  60917. * Gets the world input component
  60918. */
  60919. get world(): NodeMaterialConnectionPoint;
  60920. /**
  60921. * Gets the output component
  60922. */
  60923. get output(): NodeMaterialConnectionPoint;
  60924. /**
  60925. * Gets the isntanceID component
  60926. */
  60927. get instanceID(): NodeMaterialConnectionPoint;
  60928. autoConfigure(material: NodeMaterial): void;
  60929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60930. protected _buildBlock(state: NodeMaterialBuildState): this;
  60931. }
  60932. }
  60933. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60934. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60938. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60939. import { Effect } from "babylonjs/Materials/effect";
  60940. import { Mesh } from "babylonjs/Meshes/mesh";
  60941. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60942. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60943. /**
  60944. * Block used to add morph targets support to vertex shader
  60945. */
  60946. export class MorphTargetsBlock extends NodeMaterialBlock {
  60947. private _repeatableContentAnchor;
  60948. /**
  60949. * Create a new MorphTargetsBlock
  60950. * @param name defines the block name
  60951. */
  60952. constructor(name: string);
  60953. /**
  60954. * Gets the current class name
  60955. * @returns the class name
  60956. */
  60957. getClassName(): string;
  60958. /**
  60959. * Gets the position input component
  60960. */
  60961. get position(): NodeMaterialConnectionPoint;
  60962. /**
  60963. * Gets the normal input component
  60964. */
  60965. get normal(): NodeMaterialConnectionPoint;
  60966. /**
  60967. * Gets the tangent input component
  60968. */
  60969. get tangent(): NodeMaterialConnectionPoint;
  60970. /**
  60971. * Gets the tangent input component
  60972. */
  60973. get uv(): NodeMaterialConnectionPoint;
  60974. /**
  60975. * Gets the position output component
  60976. */
  60977. get positionOutput(): NodeMaterialConnectionPoint;
  60978. /**
  60979. * Gets the normal output component
  60980. */
  60981. get normalOutput(): NodeMaterialConnectionPoint;
  60982. /**
  60983. * Gets the tangent output component
  60984. */
  60985. get tangentOutput(): NodeMaterialConnectionPoint;
  60986. /**
  60987. * Gets the tangent output component
  60988. */
  60989. get uvOutput(): NodeMaterialConnectionPoint;
  60990. initialize(state: NodeMaterialBuildState): void;
  60991. autoConfigure(material: NodeMaterial): void;
  60992. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60993. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60994. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60995. protected _buildBlock(state: NodeMaterialBuildState): this;
  60996. }
  60997. }
  60998. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  60999. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61000. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61001. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61002. import { Nullable } from "babylonjs/types";
  61003. import { Scene } from "babylonjs/scene";
  61004. import { Effect } from "babylonjs/Materials/effect";
  61005. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61006. import { Mesh } from "babylonjs/Meshes/mesh";
  61007. import { Light } from "babylonjs/Lights/light";
  61008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61009. /**
  61010. * Block used to get data information from a light
  61011. */
  61012. export class LightInformationBlock extends NodeMaterialBlock {
  61013. private _lightDataUniformName;
  61014. private _lightColorUniformName;
  61015. private _lightTypeDefineName;
  61016. /**
  61017. * Gets or sets the light associated with this block
  61018. */
  61019. light: Nullable<Light>;
  61020. /**
  61021. * Creates a new LightInformationBlock
  61022. * @param name defines the block name
  61023. */
  61024. constructor(name: string);
  61025. /**
  61026. * Gets the current class name
  61027. * @returns the class name
  61028. */
  61029. getClassName(): string;
  61030. /**
  61031. * Gets the world position input component
  61032. */
  61033. get worldPosition(): NodeMaterialConnectionPoint;
  61034. /**
  61035. * Gets the direction output component
  61036. */
  61037. get direction(): NodeMaterialConnectionPoint;
  61038. /**
  61039. * Gets the direction output component
  61040. */
  61041. get color(): NodeMaterialConnectionPoint;
  61042. /**
  61043. * Gets the direction output component
  61044. */
  61045. get intensity(): NodeMaterialConnectionPoint;
  61046. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61047. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61048. protected _buildBlock(state: NodeMaterialBuildState): this;
  61049. serialize(): any;
  61050. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61051. }
  61052. }
  61053. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61054. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61055. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61056. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61057. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61058. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61059. }
  61060. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61065. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61066. import { Effect } from "babylonjs/Materials/effect";
  61067. import { Mesh } from "babylonjs/Meshes/mesh";
  61068. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61069. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61070. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61071. /**
  61072. * Block used to add image processing support to fragment shader
  61073. */
  61074. export class ImageProcessingBlock extends NodeMaterialBlock {
  61075. /**
  61076. * Create a new ImageProcessingBlock
  61077. * @param name defines the block name
  61078. */
  61079. constructor(name: string);
  61080. /**
  61081. * Gets the current class name
  61082. * @returns the class name
  61083. */
  61084. getClassName(): string;
  61085. /**
  61086. * Gets the color input component
  61087. */
  61088. get color(): NodeMaterialConnectionPoint;
  61089. /**
  61090. * Gets the output component
  61091. */
  61092. get output(): NodeMaterialConnectionPoint;
  61093. /**
  61094. * Initialize the block and prepare the context for build
  61095. * @param state defines the state that will be used for the build
  61096. */
  61097. initialize(state: NodeMaterialBuildState): void;
  61098. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61099. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61100. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61101. protected _buildBlock(state: NodeMaterialBuildState): this;
  61102. }
  61103. }
  61104. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61108. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61110. import { Effect } from "babylonjs/Materials/effect";
  61111. import { Mesh } from "babylonjs/Meshes/mesh";
  61112. import { Scene } from "babylonjs/scene";
  61113. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61114. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61115. /**
  61116. * Block used to pertub normals based on a normal map
  61117. */
  61118. export class PerturbNormalBlock extends NodeMaterialBlock {
  61119. private _tangentSpaceParameterName;
  61120. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61121. invertX: boolean;
  61122. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61123. invertY: boolean;
  61124. /**
  61125. * Create a new PerturbNormalBlock
  61126. * @param name defines the block name
  61127. */
  61128. constructor(name: string);
  61129. /**
  61130. * Gets the current class name
  61131. * @returns the class name
  61132. */
  61133. getClassName(): string;
  61134. /**
  61135. * Gets the world position input component
  61136. */
  61137. get worldPosition(): NodeMaterialConnectionPoint;
  61138. /**
  61139. * Gets the world normal input component
  61140. */
  61141. get worldNormal(): NodeMaterialConnectionPoint;
  61142. /**
  61143. * Gets the world tangent input component
  61144. */
  61145. get worldTangent(): NodeMaterialConnectionPoint;
  61146. /**
  61147. * Gets the uv input component
  61148. */
  61149. get uv(): NodeMaterialConnectionPoint;
  61150. /**
  61151. * Gets the normal map color input component
  61152. */
  61153. get normalMapColor(): NodeMaterialConnectionPoint;
  61154. /**
  61155. * Gets the strength input component
  61156. */
  61157. get strength(): NodeMaterialConnectionPoint;
  61158. /**
  61159. * Gets the output component
  61160. */
  61161. get output(): NodeMaterialConnectionPoint;
  61162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61164. autoConfigure(material: NodeMaterial): void;
  61165. protected _buildBlock(state: NodeMaterialBuildState): this;
  61166. protected _dumpPropertiesCode(): string;
  61167. serialize(): any;
  61168. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61169. }
  61170. }
  61171. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61172. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61173. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61174. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61175. /**
  61176. * Block used to discard a pixel if a value is smaller than a cutoff
  61177. */
  61178. export class DiscardBlock extends NodeMaterialBlock {
  61179. /**
  61180. * Create a new DiscardBlock
  61181. * @param name defines the block name
  61182. */
  61183. constructor(name: string);
  61184. /**
  61185. * Gets the current class name
  61186. * @returns the class name
  61187. */
  61188. getClassName(): string;
  61189. /**
  61190. * Gets the color input component
  61191. */
  61192. get value(): NodeMaterialConnectionPoint;
  61193. /**
  61194. * Gets the cutoff input component
  61195. */
  61196. get cutoff(): NodeMaterialConnectionPoint;
  61197. protected _buildBlock(state: NodeMaterialBuildState): this;
  61198. }
  61199. }
  61200. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61201. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61202. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61203. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61204. /**
  61205. * Block used to test if the fragment shader is front facing
  61206. */
  61207. export class FrontFacingBlock extends NodeMaterialBlock {
  61208. /**
  61209. * Creates a new FrontFacingBlock
  61210. * @param name defines the block name
  61211. */
  61212. constructor(name: string);
  61213. /**
  61214. * Gets the current class name
  61215. * @returns the class name
  61216. */
  61217. getClassName(): string;
  61218. /**
  61219. * Gets the output component
  61220. */
  61221. get output(): NodeMaterialConnectionPoint;
  61222. protected _buildBlock(state: NodeMaterialBuildState): this;
  61223. }
  61224. }
  61225. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61226. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61227. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61228. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61229. /**
  61230. * Block used to get the derivative value on x and y of a given input
  61231. */
  61232. export class DerivativeBlock extends NodeMaterialBlock {
  61233. /**
  61234. * Create a new DerivativeBlock
  61235. * @param name defines the block name
  61236. */
  61237. constructor(name: string);
  61238. /**
  61239. * Gets the current class name
  61240. * @returns the class name
  61241. */
  61242. getClassName(): string;
  61243. /**
  61244. * Gets the input component
  61245. */
  61246. get input(): NodeMaterialConnectionPoint;
  61247. /**
  61248. * Gets the derivative output on x
  61249. */
  61250. get dx(): NodeMaterialConnectionPoint;
  61251. /**
  61252. * Gets the derivative output on y
  61253. */
  61254. get dy(): NodeMaterialConnectionPoint;
  61255. protected _buildBlock(state: NodeMaterialBuildState): this;
  61256. }
  61257. }
  61258. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61259. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61260. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61261. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61262. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61263. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61264. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61265. }
  61266. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61267. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61268. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61269. import { Mesh } from "babylonjs/Meshes/mesh";
  61270. import { Effect } from "babylonjs/Materials/effect";
  61271. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61273. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61274. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61275. /**
  61276. * Block used to add support for scene fog
  61277. */
  61278. export class FogBlock extends NodeMaterialBlock {
  61279. private _fogDistanceName;
  61280. private _fogParameters;
  61281. /**
  61282. * Create a new FogBlock
  61283. * @param name defines the block name
  61284. */
  61285. constructor(name: string);
  61286. /**
  61287. * Gets the current class name
  61288. * @returns the class name
  61289. */
  61290. getClassName(): string;
  61291. /**
  61292. * Gets the world position input component
  61293. */
  61294. get worldPosition(): NodeMaterialConnectionPoint;
  61295. /**
  61296. * Gets the view input component
  61297. */
  61298. get view(): NodeMaterialConnectionPoint;
  61299. /**
  61300. * Gets the color input component
  61301. */
  61302. get input(): NodeMaterialConnectionPoint;
  61303. /**
  61304. * Gets the fog color input component
  61305. */
  61306. get fogColor(): NodeMaterialConnectionPoint;
  61307. /**
  61308. * Gets the output component
  61309. */
  61310. get output(): NodeMaterialConnectionPoint;
  61311. autoConfigure(material: NodeMaterial): void;
  61312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61313. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61314. protected _buildBlock(state: NodeMaterialBuildState): this;
  61315. }
  61316. }
  61317. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61322. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61323. import { Effect } from "babylonjs/Materials/effect";
  61324. import { Mesh } from "babylonjs/Meshes/mesh";
  61325. import { Light } from "babylonjs/Lights/light";
  61326. import { Nullable } from "babylonjs/types";
  61327. import { Scene } from "babylonjs/scene";
  61328. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61329. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61330. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61331. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61332. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61333. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61334. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61335. /**
  61336. * Block used to add light in the fragment shader
  61337. */
  61338. export class LightBlock extends NodeMaterialBlock {
  61339. private _lightId;
  61340. /**
  61341. * Gets or sets the light associated with this block
  61342. */
  61343. light: Nullable<Light>;
  61344. /**
  61345. * Create a new LightBlock
  61346. * @param name defines the block name
  61347. */
  61348. constructor(name: string);
  61349. /**
  61350. * Gets the current class name
  61351. * @returns the class name
  61352. */
  61353. getClassName(): string;
  61354. /**
  61355. * Gets the world position input component
  61356. */
  61357. get worldPosition(): NodeMaterialConnectionPoint;
  61358. /**
  61359. * Gets the world normal input component
  61360. */
  61361. get worldNormal(): NodeMaterialConnectionPoint;
  61362. /**
  61363. * Gets the camera (or eye) position component
  61364. */
  61365. get cameraPosition(): NodeMaterialConnectionPoint;
  61366. /**
  61367. * Gets the glossiness component
  61368. */
  61369. get glossiness(): NodeMaterialConnectionPoint;
  61370. /**
  61371. * Gets the glossinness power component
  61372. */
  61373. get glossPower(): NodeMaterialConnectionPoint;
  61374. /**
  61375. * Gets the diffuse color component
  61376. */
  61377. get diffuseColor(): NodeMaterialConnectionPoint;
  61378. /**
  61379. * Gets the specular color component
  61380. */
  61381. get specularColor(): NodeMaterialConnectionPoint;
  61382. /**
  61383. * Gets the diffuse output component
  61384. */
  61385. get diffuseOutput(): NodeMaterialConnectionPoint;
  61386. /**
  61387. * Gets the specular output component
  61388. */
  61389. get specularOutput(): NodeMaterialConnectionPoint;
  61390. /**
  61391. * Gets the shadow output component
  61392. */
  61393. get shadow(): NodeMaterialConnectionPoint;
  61394. autoConfigure(material: NodeMaterial): void;
  61395. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61396. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61397. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61398. private _injectVertexCode;
  61399. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61400. serialize(): any;
  61401. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61402. }
  61403. }
  61404. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61405. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61406. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61407. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61408. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61409. }
  61410. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61411. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61412. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61413. }
  61414. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61418. /**
  61419. * Block used to multiply 2 values
  61420. */
  61421. export class MultiplyBlock extends NodeMaterialBlock {
  61422. /**
  61423. * Creates a new MultiplyBlock
  61424. * @param name defines the block name
  61425. */
  61426. constructor(name: string);
  61427. /**
  61428. * Gets the current class name
  61429. * @returns the class name
  61430. */
  61431. getClassName(): string;
  61432. /**
  61433. * Gets the left operand input component
  61434. */
  61435. get left(): NodeMaterialConnectionPoint;
  61436. /**
  61437. * Gets the right operand input component
  61438. */
  61439. get right(): NodeMaterialConnectionPoint;
  61440. /**
  61441. * Gets the output component
  61442. */
  61443. get output(): NodeMaterialConnectionPoint;
  61444. protected _buildBlock(state: NodeMaterialBuildState): this;
  61445. }
  61446. }
  61447. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61451. /**
  61452. * Block used to add 2 vectors
  61453. */
  61454. export class AddBlock extends NodeMaterialBlock {
  61455. /**
  61456. * Creates a new AddBlock
  61457. * @param name defines the block name
  61458. */
  61459. constructor(name: string);
  61460. /**
  61461. * Gets the current class name
  61462. * @returns the class name
  61463. */
  61464. getClassName(): string;
  61465. /**
  61466. * Gets the left operand input component
  61467. */
  61468. get left(): NodeMaterialConnectionPoint;
  61469. /**
  61470. * Gets the right operand input component
  61471. */
  61472. get right(): NodeMaterialConnectionPoint;
  61473. /**
  61474. * Gets the output component
  61475. */
  61476. get output(): NodeMaterialConnectionPoint;
  61477. protected _buildBlock(state: NodeMaterialBuildState): this;
  61478. }
  61479. }
  61480. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61483. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61484. /**
  61485. * Block used to scale a vector by a float
  61486. */
  61487. export class ScaleBlock extends NodeMaterialBlock {
  61488. /**
  61489. * Creates a new ScaleBlock
  61490. * @param name defines the block name
  61491. */
  61492. constructor(name: string);
  61493. /**
  61494. * Gets the current class name
  61495. * @returns the class name
  61496. */
  61497. getClassName(): string;
  61498. /**
  61499. * Gets the input component
  61500. */
  61501. get input(): NodeMaterialConnectionPoint;
  61502. /**
  61503. * Gets the factor input component
  61504. */
  61505. get factor(): NodeMaterialConnectionPoint;
  61506. /**
  61507. * Gets the output component
  61508. */
  61509. get output(): NodeMaterialConnectionPoint;
  61510. protected _buildBlock(state: NodeMaterialBuildState): this;
  61511. }
  61512. }
  61513. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61514. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61515. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61516. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61517. import { Scene } from "babylonjs/scene";
  61518. /**
  61519. * Block used to clamp a float
  61520. */
  61521. export class ClampBlock extends NodeMaterialBlock {
  61522. /** Gets or sets the minimum range */
  61523. minimum: number;
  61524. /** Gets or sets the maximum range */
  61525. maximum: number;
  61526. /**
  61527. * Creates a new ClampBlock
  61528. * @param name defines the block name
  61529. */
  61530. constructor(name: string);
  61531. /**
  61532. * Gets the current class name
  61533. * @returns the class name
  61534. */
  61535. getClassName(): string;
  61536. /**
  61537. * Gets the value input component
  61538. */
  61539. get value(): NodeMaterialConnectionPoint;
  61540. /**
  61541. * Gets the output component
  61542. */
  61543. get output(): NodeMaterialConnectionPoint;
  61544. protected _buildBlock(state: NodeMaterialBuildState): this;
  61545. protected _dumpPropertiesCode(): string;
  61546. serialize(): any;
  61547. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61548. }
  61549. }
  61550. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61554. /**
  61555. * Block used to apply a cross product between 2 vectors
  61556. */
  61557. export class CrossBlock extends NodeMaterialBlock {
  61558. /**
  61559. * Creates a new CrossBlock
  61560. * @param name defines the block name
  61561. */
  61562. constructor(name: string);
  61563. /**
  61564. * Gets the current class name
  61565. * @returns the class name
  61566. */
  61567. getClassName(): string;
  61568. /**
  61569. * Gets the left operand input component
  61570. */
  61571. get left(): NodeMaterialConnectionPoint;
  61572. /**
  61573. * Gets the right operand input component
  61574. */
  61575. get right(): NodeMaterialConnectionPoint;
  61576. /**
  61577. * Gets the output component
  61578. */
  61579. get output(): NodeMaterialConnectionPoint;
  61580. protected _buildBlock(state: NodeMaterialBuildState): this;
  61581. }
  61582. }
  61583. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61587. /**
  61588. * Block used to apply a dot product between 2 vectors
  61589. */
  61590. export class DotBlock extends NodeMaterialBlock {
  61591. /**
  61592. * Creates a new DotBlock
  61593. * @param name defines the block name
  61594. */
  61595. constructor(name: string);
  61596. /**
  61597. * Gets the current class name
  61598. * @returns the class name
  61599. */
  61600. getClassName(): string;
  61601. /**
  61602. * Gets the left operand input component
  61603. */
  61604. get left(): NodeMaterialConnectionPoint;
  61605. /**
  61606. * Gets the right operand input component
  61607. */
  61608. get right(): NodeMaterialConnectionPoint;
  61609. /**
  61610. * Gets the output component
  61611. */
  61612. get output(): NodeMaterialConnectionPoint;
  61613. protected _buildBlock(state: NodeMaterialBuildState): this;
  61614. }
  61615. }
  61616. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61617. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61618. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61619. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61620. import { Vector2 } from "babylonjs/Maths/math.vector";
  61621. import { Scene } from "babylonjs/scene";
  61622. /**
  61623. * Block used to remap a float from a range to a new one
  61624. */
  61625. export class RemapBlock extends NodeMaterialBlock {
  61626. /**
  61627. * Gets or sets the source range
  61628. */
  61629. sourceRange: Vector2;
  61630. /**
  61631. * Gets or sets the target range
  61632. */
  61633. targetRange: Vector2;
  61634. /**
  61635. * Creates a new RemapBlock
  61636. * @param name defines the block name
  61637. */
  61638. constructor(name: string);
  61639. /**
  61640. * Gets the current class name
  61641. * @returns the class name
  61642. */
  61643. getClassName(): string;
  61644. /**
  61645. * Gets the input component
  61646. */
  61647. get input(): NodeMaterialConnectionPoint;
  61648. /**
  61649. * Gets the source min input component
  61650. */
  61651. get sourceMin(): NodeMaterialConnectionPoint;
  61652. /**
  61653. * Gets the source max input component
  61654. */
  61655. get sourceMax(): NodeMaterialConnectionPoint;
  61656. /**
  61657. * Gets the target min input component
  61658. */
  61659. get targetMin(): NodeMaterialConnectionPoint;
  61660. /**
  61661. * Gets the target max input component
  61662. */
  61663. get targetMax(): NodeMaterialConnectionPoint;
  61664. /**
  61665. * Gets the output component
  61666. */
  61667. get output(): NodeMaterialConnectionPoint;
  61668. protected _buildBlock(state: NodeMaterialBuildState): this;
  61669. protected _dumpPropertiesCode(): string;
  61670. serialize(): any;
  61671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61672. }
  61673. }
  61674. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61676. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61677. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61678. /**
  61679. * Block used to normalize a vector
  61680. */
  61681. export class NormalizeBlock extends NodeMaterialBlock {
  61682. /**
  61683. * Creates a new NormalizeBlock
  61684. * @param name defines the block name
  61685. */
  61686. constructor(name: string);
  61687. /**
  61688. * Gets the current class name
  61689. * @returns the class name
  61690. */
  61691. getClassName(): string;
  61692. /**
  61693. * Gets the input component
  61694. */
  61695. get input(): NodeMaterialConnectionPoint;
  61696. /**
  61697. * Gets the output component
  61698. */
  61699. get output(): NodeMaterialConnectionPoint;
  61700. protected _buildBlock(state: NodeMaterialBuildState): this;
  61701. }
  61702. }
  61703. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61704. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61705. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61706. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61707. import { Scene } from "babylonjs/scene";
  61708. /**
  61709. * Operations supported by the Trigonometry block
  61710. */
  61711. export enum TrigonometryBlockOperations {
  61712. /** Cos */
  61713. Cos = 0,
  61714. /** Sin */
  61715. Sin = 1,
  61716. /** Abs */
  61717. Abs = 2,
  61718. /** Exp */
  61719. Exp = 3,
  61720. /** Exp2 */
  61721. Exp2 = 4,
  61722. /** Round */
  61723. Round = 5,
  61724. /** Floor */
  61725. Floor = 6,
  61726. /** Ceiling */
  61727. Ceiling = 7,
  61728. /** Square root */
  61729. Sqrt = 8,
  61730. /** Log */
  61731. Log = 9,
  61732. /** Tangent */
  61733. Tan = 10,
  61734. /** Arc tangent */
  61735. ArcTan = 11,
  61736. /** Arc cosinus */
  61737. ArcCos = 12,
  61738. /** Arc sinus */
  61739. ArcSin = 13,
  61740. /** Fraction */
  61741. Fract = 14,
  61742. /** Sign */
  61743. Sign = 15,
  61744. /** To radians (from degrees) */
  61745. Radians = 16,
  61746. /** To degrees (from radians) */
  61747. Degrees = 17
  61748. }
  61749. /**
  61750. * Block used to apply trigonometry operation to floats
  61751. */
  61752. export class TrigonometryBlock extends NodeMaterialBlock {
  61753. /**
  61754. * Gets or sets the operation applied by the block
  61755. */
  61756. operation: TrigonometryBlockOperations;
  61757. /**
  61758. * Creates a new TrigonometryBlock
  61759. * @param name defines the block name
  61760. */
  61761. constructor(name: string);
  61762. /**
  61763. * Gets the current class name
  61764. * @returns the class name
  61765. */
  61766. getClassName(): string;
  61767. /**
  61768. * Gets the input component
  61769. */
  61770. get input(): NodeMaterialConnectionPoint;
  61771. /**
  61772. * Gets the output component
  61773. */
  61774. get output(): NodeMaterialConnectionPoint;
  61775. protected _buildBlock(state: NodeMaterialBuildState): this;
  61776. serialize(): any;
  61777. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61778. protected _dumpPropertiesCode(): string;
  61779. }
  61780. }
  61781. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61783. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61785. /**
  61786. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61787. */
  61788. export class ColorMergerBlock extends NodeMaterialBlock {
  61789. /**
  61790. * Create a new ColorMergerBlock
  61791. * @param name defines the block name
  61792. */
  61793. constructor(name: string);
  61794. /**
  61795. * Gets the current class name
  61796. * @returns the class name
  61797. */
  61798. getClassName(): string;
  61799. /**
  61800. * Gets the rgb component (input)
  61801. */
  61802. get rgbIn(): NodeMaterialConnectionPoint;
  61803. /**
  61804. * Gets the r component (input)
  61805. */
  61806. get r(): NodeMaterialConnectionPoint;
  61807. /**
  61808. * Gets the g component (input)
  61809. */
  61810. get g(): NodeMaterialConnectionPoint;
  61811. /**
  61812. * Gets the b component (input)
  61813. */
  61814. get b(): NodeMaterialConnectionPoint;
  61815. /**
  61816. * Gets the a component (input)
  61817. */
  61818. get a(): NodeMaterialConnectionPoint;
  61819. /**
  61820. * Gets the rgba component (output)
  61821. */
  61822. get rgba(): NodeMaterialConnectionPoint;
  61823. /**
  61824. * Gets the rgb component (output)
  61825. */
  61826. get rgbOut(): NodeMaterialConnectionPoint;
  61827. /**
  61828. * Gets the rgb component (output)
  61829. * @deprecated Please use rgbOut instead.
  61830. */
  61831. get rgb(): NodeMaterialConnectionPoint;
  61832. protected _buildBlock(state: NodeMaterialBuildState): this;
  61833. }
  61834. }
  61835. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61838. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61839. /**
  61840. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61841. */
  61842. export class VectorMergerBlock extends NodeMaterialBlock {
  61843. /**
  61844. * Create a new VectorMergerBlock
  61845. * @param name defines the block name
  61846. */
  61847. constructor(name: string);
  61848. /**
  61849. * Gets the current class name
  61850. * @returns the class name
  61851. */
  61852. getClassName(): string;
  61853. /**
  61854. * Gets the xyz component (input)
  61855. */
  61856. get xyzIn(): NodeMaterialConnectionPoint;
  61857. /**
  61858. * Gets the xy component (input)
  61859. */
  61860. get xyIn(): NodeMaterialConnectionPoint;
  61861. /**
  61862. * Gets the x component (input)
  61863. */
  61864. get x(): NodeMaterialConnectionPoint;
  61865. /**
  61866. * Gets the y component (input)
  61867. */
  61868. get y(): NodeMaterialConnectionPoint;
  61869. /**
  61870. * Gets the z component (input)
  61871. */
  61872. get z(): NodeMaterialConnectionPoint;
  61873. /**
  61874. * Gets the w component (input)
  61875. */
  61876. get w(): NodeMaterialConnectionPoint;
  61877. /**
  61878. * Gets the xyzw component (output)
  61879. */
  61880. get xyzw(): NodeMaterialConnectionPoint;
  61881. /**
  61882. * Gets the xyz component (output)
  61883. */
  61884. get xyzOut(): NodeMaterialConnectionPoint;
  61885. /**
  61886. * Gets the xy component (output)
  61887. */
  61888. get xyOut(): NodeMaterialConnectionPoint;
  61889. /**
  61890. * Gets the xy component (output)
  61891. * @deprecated Please use xyOut instead.
  61892. */
  61893. get xy(): NodeMaterialConnectionPoint;
  61894. /**
  61895. * Gets the xyz component (output)
  61896. * @deprecated Please use xyzOut instead.
  61897. */
  61898. get xyz(): NodeMaterialConnectionPoint;
  61899. protected _buildBlock(state: NodeMaterialBuildState): this;
  61900. }
  61901. }
  61902. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61903. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61904. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61905. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61906. /**
  61907. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61908. */
  61909. export class ColorSplitterBlock extends NodeMaterialBlock {
  61910. /**
  61911. * Create a new ColorSplitterBlock
  61912. * @param name defines the block name
  61913. */
  61914. constructor(name: string);
  61915. /**
  61916. * Gets the current class name
  61917. * @returns the class name
  61918. */
  61919. getClassName(): string;
  61920. /**
  61921. * Gets the rgba component (input)
  61922. */
  61923. get rgba(): NodeMaterialConnectionPoint;
  61924. /**
  61925. * Gets the rgb component (input)
  61926. */
  61927. get rgbIn(): NodeMaterialConnectionPoint;
  61928. /**
  61929. * Gets the rgb component (output)
  61930. */
  61931. get rgbOut(): NodeMaterialConnectionPoint;
  61932. /**
  61933. * Gets the r component (output)
  61934. */
  61935. get r(): NodeMaterialConnectionPoint;
  61936. /**
  61937. * Gets the g component (output)
  61938. */
  61939. get g(): NodeMaterialConnectionPoint;
  61940. /**
  61941. * Gets the b component (output)
  61942. */
  61943. get b(): NodeMaterialConnectionPoint;
  61944. /**
  61945. * Gets the a component (output)
  61946. */
  61947. get a(): NodeMaterialConnectionPoint;
  61948. protected _inputRename(name: string): string;
  61949. protected _outputRename(name: string): string;
  61950. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61951. }
  61952. }
  61953. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61957. /**
  61958. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61959. */
  61960. export class VectorSplitterBlock extends NodeMaterialBlock {
  61961. /**
  61962. * Create a new VectorSplitterBlock
  61963. * @param name defines the block name
  61964. */
  61965. constructor(name: string);
  61966. /**
  61967. * Gets the current class name
  61968. * @returns the class name
  61969. */
  61970. getClassName(): string;
  61971. /**
  61972. * Gets the xyzw component (input)
  61973. */
  61974. get xyzw(): NodeMaterialConnectionPoint;
  61975. /**
  61976. * Gets the xyz component (input)
  61977. */
  61978. get xyzIn(): NodeMaterialConnectionPoint;
  61979. /**
  61980. * Gets the xy component (input)
  61981. */
  61982. get xyIn(): NodeMaterialConnectionPoint;
  61983. /**
  61984. * Gets the xyz component (output)
  61985. */
  61986. get xyzOut(): NodeMaterialConnectionPoint;
  61987. /**
  61988. * Gets the xy component (output)
  61989. */
  61990. get xyOut(): NodeMaterialConnectionPoint;
  61991. /**
  61992. * Gets the x component (output)
  61993. */
  61994. get x(): NodeMaterialConnectionPoint;
  61995. /**
  61996. * Gets the y component (output)
  61997. */
  61998. get y(): NodeMaterialConnectionPoint;
  61999. /**
  62000. * Gets the z component (output)
  62001. */
  62002. get z(): NodeMaterialConnectionPoint;
  62003. /**
  62004. * Gets the w component (output)
  62005. */
  62006. get w(): NodeMaterialConnectionPoint;
  62007. protected _inputRename(name: string): string;
  62008. protected _outputRename(name: string): string;
  62009. protected _buildBlock(state: NodeMaterialBuildState): this;
  62010. }
  62011. }
  62012. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62014. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62015. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62016. /**
  62017. * Block used to lerp between 2 values
  62018. */
  62019. export class LerpBlock extends NodeMaterialBlock {
  62020. /**
  62021. * Creates a new LerpBlock
  62022. * @param name defines the block name
  62023. */
  62024. constructor(name: string);
  62025. /**
  62026. * Gets the current class name
  62027. * @returns the class name
  62028. */
  62029. getClassName(): string;
  62030. /**
  62031. * Gets the left operand input component
  62032. */
  62033. get left(): NodeMaterialConnectionPoint;
  62034. /**
  62035. * Gets the right operand input component
  62036. */
  62037. get right(): NodeMaterialConnectionPoint;
  62038. /**
  62039. * Gets the gradient operand input component
  62040. */
  62041. get gradient(): NodeMaterialConnectionPoint;
  62042. /**
  62043. * Gets the output component
  62044. */
  62045. get output(): NodeMaterialConnectionPoint;
  62046. protected _buildBlock(state: NodeMaterialBuildState): this;
  62047. }
  62048. }
  62049. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62051. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62052. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62053. /**
  62054. * Block used to divide 2 vectors
  62055. */
  62056. export class DivideBlock extends NodeMaterialBlock {
  62057. /**
  62058. * Creates a new DivideBlock
  62059. * @param name defines the block name
  62060. */
  62061. constructor(name: string);
  62062. /**
  62063. * Gets the current class name
  62064. * @returns the class name
  62065. */
  62066. getClassName(): string;
  62067. /**
  62068. * Gets the left operand input component
  62069. */
  62070. get left(): NodeMaterialConnectionPoint;
  62071. /**
  62072. * Gets the right operand input component
  62073. */
  62074. get right(): NodeMaterialConnectionPoint;
  62075. /**
  62076. * Gets the output component
  62077. */
  62078. get output(): NodeMaterialConnectionPoint;
  62079. protected _buildBlock(state: NodeMaterialBuildState): this;
  62080. }
  62081. }
  62082. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62083. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62084. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62085. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62086. /**
  62087. * Block used to subtract 2 vectors
  62088. */
  62089. export class SubtractBlock extends NodeMaterialBlock {
  62090. /**
  62091. * Creates a new SubtractBlock
  62092. * @param name defines the block name
  62093. */
  62094. constructor(name: string);
  62095. /**
  62096. * Gets the current class name
  62097. * @returns the class name
  62098. */
  62099. getClassName(): string;
  62100. /**
  62101. * Gets the left operand input component
  62102. */
  62103. get left(): NodeMaterialConnectionPoint;
  62104. /**
  62105. * Gets the right operand input component
  62106. */
  62107. get right(): NodeMaterialConnectionPoint;
  62108. /**
  62109. * Gets the output component
  62110. */
  62111. get output(): NodeMaterialConnectionPoint;
  62112. protected _buildBlock(state: NodeMaterialBuildState): this;
  62113. }
  62114. }
  62115. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62116. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62117. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62118. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62119. /**
  62120. * Block used to step a value
  62121. */
  62122. export class StepBlock extends NodeMaterialBlock {
  62123. /**
  62124. * Creates a new StepBlock
  62125. * @param name defines the block name
  62126. */
  62127. constructor(name: string);
  62128. /**
  62129. * Gets the current class name
  62130. * @returns the class name
  62131. */
  62132. getClassName(): string;
  62133. /**
  62134. * Gets the value operand input component
  62135. */
  62136. get value(): NodeMaterialConnectionPoint;
  62137. /**
  62138. * Gets the edge operand input component
  62139. */
  62140. get edge(): NodeMaterialConnectionPoint;
  62141. /**
  62142. * Gets the output component
  62143. */
  62144. get output(): NodeMaterialConnectionPoint;
  62145. protected _buildBlock(state: NodeMaterialBuildState): this;
  62146. }
  62147. }
  62148. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62149. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62150. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62151. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62152. /**
  62153. * Block used to get the opposite (1 - x) of a value
  62154. */
  62155. export class OneMinusBlock extends NodeMaterialBlock {
  62156. /**
  62157. * Creates a new OneMinusBlock
  62158. * @param name defines the block name
  62159. */
  62160. constructor(name: string);
  62161. /**
  62162. * Gets the current class name
  62163. * @returns the class name
  62164. */
  62165. getClassName(): string;
  62166. /**
  62167. * Gets the input component
  62168. */
  62169. get input(): NodeMaterialConnectionPoint;
  62170. /**
  62171. * Gets the output component
  62172. */
  62173. get output(): NodeMaterialConnectionPoint;
  62174. protected _buildBlock(state: NodeMaterialBuildState): this;
  62175. }
  62176. }
  62177. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62181. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62182. /**
  62183. * Block used to get the view direction
  62184. */
  62185. export class ViewDirectionBlock extends NodeMaterialBlock {
  62186. /**
  62187. * Creates a new ViewDirectionBlock
  62188. * @param name defines the block name
  62189. */
  62190. constructor(name: string);
  62191. /**
  62192. * Gets the current class name
  62193. * @returns the class name
  62194. */
  62195. getClassName(): string;
  62196. /**
  62197. * Gets the world position component
  62198. */
  62199. get worldPosition(): NodeMaterialConnectionPoint;
  62200. /**
  62201. * Gets the camera position component
  62202. */
  62203. get cameraPosition(): NodeMaterialConnectionPoint;
  62204. /**
  62205. * Gets the output component
  62206. */
  62207. get output(): NodeMaterialConnectionPoint;
  62208. autoConfigure(material: NodeMaterial): void;
  62209. protected _buildBlock(state: NodeMaterialBuildState): this;
  62210. }
  62211. }
  62212. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62216. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62217. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62218. /**
  62219. * Block used to compute fresnel value
  62220. */
  62221. export class FresnelBlock extends NodeMaterialBlock {
  62222. /**
  62223. * Create a new FresnelBlock
  62224. * @param name defines the block name
  62225. */
  62226. constructor(name: string);
  62227. /**
  62228. * Gets the current class name
  62229. * @returns the class name
  62230. */
  62231. getClassName(): string;
  62232. /**
  62233. * Gets the world normal input component
  62234. */
  62235. get worldNormal(): NodeMaterialConnectionPoint;
  62236. /**
  62237. * Gets the view direction input component
  62238. */
  62239. get viewDirection(): NodeMaterialConnectionPoint;
  62240. /**
  62241. * Gets the bias input component
  62242. */
  62243. get bias(): NodeMaterialConnectionPoint;
  62244. /**
  62245. * Gets the camera (or eye) position component
  62246. */
  62247. get power(): NodeMaterialConnectionPoint;
  62248. /**
  62249. * Gets the fresnel output component
  62250. */
  62251. get fresnel(): NodeMaterialConnectionPoint;
  62252. autoConfigure(material: NodeMaterial): void;
  62253. protected _buildBlock(state: NodeMaterialBuildState): this;
  62254. }
  62255. }
  62256. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62258. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62259. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62260. /**
  62261. * Block used to get the max of 2 values
  62262. */
  62263. export class MaxBlock extends NodeMaterialBlock {
  62264. /**
  62265. * Creates a new MaxBlock
  62266. * @param name defines the block name
  62267. */
  62268. constructor(name: string);
  62269. /**
  62270. * Gets the current class name
  62271. * @returns the class name
  62272. */
  62273. getClassName(): string;
  62274. /**
  62275. * Gets the left operand input component
  62276. */
  62277. get left(): NodeMaterialConnectionPoint;
  62278. /**
  62279. * Gets the right operand input component
  62280. */
  62281. get right(): NodeMaterialConnectionPoint;
  62282. /**
  62283. * Gets the output component
  62284. */
  62285. get output(): NodeMaterialConnectionPoint;
  62286. protected _buildBlock(state: NodeMaterialBuildState): this;
  62287. }
  62288. }
  62289. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62293. /**
  62294. * Block used to get the min of 2 values
  62295. */
  62296. export class MinBlock extends NodeMaterialBlock {
  62297. /**
  62298. * Creates a new MinBlock
  62299. * @param name defines the block name
  62300. */
  62301. constructor(name: string);
  62302. /**
  62303. * Gets the current class name
  62304. * @returns the class name
  62305. */
  62306. getClassName(): string;
  62307. /**
  62308. * Gets the left operand input component
  62309. */
  62310. get left(): NodeMaterialConnectionPoint;
  62311. /**
  62312. * Gets the right operand input component
  62313. */
  62314. get right(): NodeMaterialConnectionPoint;
  62315. /**
  62316. * Gets the output component
  62317. */
  62318. get output(): NodeMaterialConnectionPoint;
  62319. protected _buildBlock(state: NodeMaterialBuildState): this;
  62320. }
  62321. }
  62322. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62323. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62324. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62325. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62326. /**
  62327. * Block used to get the distance between 2 values
  62328. */
  62329. export class DistanceBlock extends NodeMaterialBlock {
  62330. /**
  62331. * Creates a new DistanceBlock
  62332. * @param name defines the block name
  62333. */
  62334. constructor(name: string);
  62335. /**
  62336. * Gets the current class name
  62337. * @returns the class name
  62338. */
  62339. getClassName(): string;
  62340. /**
  62341. * Gets the left operand input component
  62342. */
  62343. get left(): NodeMaterialConnectionPoint;
  62344. /**
  62345. * Gets the right operand input component
  62346. */
  62347. get right(): NodeMaterialConnectionPoint;
  62348. /**
  62349. * Gets the output component
  62350. */
  62351. get output(): NodeMaterialConnectionPoint;
  62352. protected _buildBlock(state: NodeMaterialBuildState): this;
  62353. }
  62354. }
  62355. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62359. /**
  62360. * Block used to get the length of a vector
  62361. */
  62362. export class LengthBlock extends NodeMaterialBlock {
  62363. /**
  62364. * Creates a new LengthBlock
  62365. * @param name defines the block name
  62366. */
  62367. constructor(name: string);
  62368. /**
  62369. * Gets the current class name
  62370. * @returns the class name
  62371. */
  62372. getClassName(): string;
  62373. /**
  62374. * Gets the value input component
  62375. */
  62376. get value(): NodeMaterialConnectionPoint;
  62377. /**
  62378. * Gets the output component
  62379. */
  62380. get output(): NodeMaterialConnectionPoint;
  62381. protected _buildBlock(state: NodeMaterialBuildState): this;
  62382. }
  62383. }
  62384. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62385. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62386. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62388. /**
  62389. * Block used to get negative version of a value (i.e. x * -1)
  62390. */
  62391. export class NegateBlock extends NodeMaterialBlock {
  62392. /**
  62393. * Creates a new NegateBlock
  62394. * @param name defines the block name
  62395. */
  62396. constructor(name: string);
  62397. /**
  62398. * Gets the current class name
  62399. * @returns the class name
  62400. */
  62401. getClassName(): string;
  62402. /**
  62403. * Gets the value input component
  62404. */
  62405. get value(): NodeMaterialConnectionPoint;
  62406. /**
  62407. * Gets the output component
  62408. */
  62409. get output(): NodeMaterialConnectionPoint;
  62410. protected _buildBlock(state: NodeMaterialBuildState): this;
  62411. }
  62412. }
  62413. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62417. /**
  62418. * Block used to get the value of the first parameter raised to the power of the second
  62419. */
  62420. export class PowBlock extends NodeMaterialBlock {
  62421. /**
  62422. * Creates a new PowBlock
  62423. * @param name defines the block name
  62424. */
  62425. constructor(name: string);
  62426. /**
  62427. * Gets the current class name
  62428. * @returns the class name
  62429. */
  62430. getClassName(): string;
  62431. /**
  62432. * Gets the value operand input component
  62433. */
  62434. get value(): NodeMaterialConnectionPoint;
  62435. /**
  62436. * Gets the power operand input component
  62437. */
  62438. get power(): NodeMaterialConnectionPoint;
  62439. /**
  62440. * Gets the output component
  62441. */
  62442. get output(): NodeMaterialConnectionPoint;
  62443. protected _buildBlock(state: NodeMaterialBuildState): this;
  62444. }
  62445. }
  62446. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62447. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62449. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62450. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62451. /**
  62452. * Block used to get a random number
  62453. */
  62454. export class RandomNumberBlock extends NodeMaterialBlock {
  62455. /**
  62456. * Creates a new RandomNumberBlock
  62457. * @param name defines the block name
  62458. */
  62459. constructor(name: string);
  62460. /**
  62461. * Gets the current class name
  62462. * @returns the class name
  62463. */
  62464. getClassName(): string;
  62465. /**
  62466. * Gets the seed input component
  62467. */
  62468. get seed(): NodeMaterialConnectionPoint;
  62469. /**
  62470. * Gets the output component
  62471. */
  62472. get output(): NodeMaterialConnectionPoint;
  62473. protected _buildBlock(state: NodeMaterialBuildState): this;
  62474. }
  62475. }
  62476. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62478. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62479. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62480. /**
  62481. * Block used to compute arc tangent of 2 values
  62482. */
  62483. export class ArcTan2Block extends NodeMaterialBlock {
  62484. /**
  62485. * Creates a new ArcTan2Block
  62486. * @param name defines the block name
  62487. */
  62488. constructor(name: string);
  62489. /**
  62490. * Gets the current class name
  62491. * @returns the class name
  62492. */
  62493. getClassName(): string;
  62494. /**
  62495. * Gets the x operand input component
  62496. */
  62497. get x(): NodeMaterialConnectionPoint;
  62498. /**
  62499. * Gets the y operand input component
  62500. */
  62501. get y(): NodeMaterialConnectionPoint;
  62502. /**
  62503. * Gets the output component
  62504. */
  62505. get output(): NodeMaterialConnectionPoint;
  62506. protected _buildBlock(state: NodeMaterialBuildState): this;
  62507. }
  62508. }
  62509. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62511. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62513. /**
  62514. * Block used to smooth step a value
  62515. */
  62516. export class SmoothStepBlock extends NodeMaterialBlock {
  62517. /**
  62518. * Creates a new SmoothStepBlock
  62519. * @param name defines the block name
  62520. */
  62521. constructor(name: string);
  62522. /**
  62523. * Gets the current class name
  62524. * @returns the class name
  62525. */
  62526. getClassName(): string;
  62527. /**
  62528. * Gets the value operand input component
  62529. */
  62530. get value(): NodeMaterialConnectionPoint;
  62531. /**
  62532. * Gets the first edge operand input component
  62533. */
  62534. get edge0(): NodeMaterialConnectionPoint;
  62535. /**
  62536. * Gets the second edge operand input component
  62537. */
  62538. get edge1(): NodeMaterialConnectionPoint;
  62539. /**
  62540. * Gets the output component
  62541. */
  62542. get output(): NodeMaterialConnectionPoint;
  62543. protected _buildBlock(state: NodeMaterialBuildState): this;
  62544. }
  62545. }
  62546. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62548. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62549. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62550. /**
  62551. * Block used to get the reciprocal (1 / x) of a value
  62552. */
  62553. export class ReciprocalBlock extends NodeMaterialBlock {
  62554. /**
  62555. * Creates a new ReciprocalBlock
  62556. * @param name defines the block name
  62557. */
  62558. constructor(name: string);
  62559. /**
  62560. * Gets the current class name
  62561. * @returns the class name
  62562. */
  62563. getClassName(): string;
  62564. /**
  62565. * Gets the input component
  62566. */
  62567. get input(): NodeMaterialConnectionPoint;
  62568. /**
  62569. * Gets the output component
  62570. */
  62571. get output(): NodeMaterialConnectionPoint;
  62572. protected _buildBlock(state: NodeMaterialBuildState): this;
  62573. }
  62574. }
  62575. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62576. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62577. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62578. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62579. /**
  62580. * Block used to replace a color by another one
  62581. */
  62582. export class ReplaceColorBlock extends NodeMaterialBlock {
  62583. /**
  62584. * Creates a new ReplaceColorBlock
  62585. * @param name defines the block name
  62586. */
  62587. constructor(name: string);
  62588. /**
  62589. * Gets the current class name
  62590. * @returns the class name
  62591. */
  62592. getClassName(): string;
  62593. /**
  62594. * Gets the value input component
  62595. */
  62596. get value(): NodeMaterialConnectionPoint;
  62597. /**
  62598. * Gets the reference input component
  62599. */
  62600. get reference(): NodeMaterialConnectionPoint;
  62601. /**
  62602. * Gets the distance input component
  62603. */
  62604. get distance(): NodeMaterialConnectionPoint;
  62605. /**
  62606. * Gets the replacement input component
  62607. */
  62608. get replacement(): NodeMaterialConnectionPoint;
  62609. /**
  62610. * Gets the output component
  62611. */
  62612. get output(): NodeMaterialConnectionPoint;
  62613. protected _buildBlock(state: NodeMaterialBuildState): this;
  62614. }
  62615. }
  62616. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62617. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62618. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62619. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62620. /**
  62621. * Block used to posterize a value
  62622. * @see https://en.wikipedia.org/wiki/Posterization
  62623. */
  62624. export class PosterizeBlock extends NodeMaterialBlock {
  62625. /**
  62626. * Creates a new PosterizeBlock
  62627. * @param name defines the block name
  62628. */
  62629. constructor(name: string);
  62630. /**
  62631. * Gets the current class name
  62632. * @returns the class name
  62633. */
  62634. getClassName(): string;
  62635. /**
  62636. * Gets the value input component
  62637. */
  62638. get value(): NodeMaterialConnectionPoint;
  62639. /**
  62640. * Gets the steps input component
  62641. */
  62642. get steps(): NodeMaterialConnectionPoint;
  62643. /**
  62644. * Gets the output component
  62645. */
  62646. get output(): NodeMaterialConnectionPoint;
  62647. protected _buildBlock(state: NodeMaterialBuildState): this;
  62648. }
  62649. }
  62650. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62651. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62652. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62653. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62654. import { Scene } from "babylonjs/scene";
  62655. /**
  62656. * Operations supported by the Wave block
  62657. */
  62658. export enum WaveBlockKind {
  62659. /** SawTooth */
  62660. SawTooth = 0,
  62661. /** Square */
  62662. Square = 1,
  62663. /** Triangle */
  62664. Triangle = 2
  62665. }
  62666. /**
  62667. * Block used to apply wave operation to floats
  62668. */
  62669. export class WaveBlock extends NodeMaterialBlock {
  62670. /**
  62671. * Gets or sets the kibnd of wave to be applied by the block
  62672. */
  62673. kind: WaveBlockKind;
  62674. /**
  62675. * Creates a new WaveBlock
  62676. * @param name defines the block name
  62677. */
  62678. constructor(name: string);
  62679. /**
  62680. * Gets the current class name
  62681. * @returns the class name
  62682. */
  62683. getClassName(): string;
  62684. /**
  62685. * Gets the input component
  62686. */
  62687. get input(): NodeMaterialConnectionPoint;
  62688. /**
  62689. * Gets the output component
  62690. */
  62691. get output(): NodeMaterialConnectionPoint;
  62692. protected _buildBlock(state: NodeMaterialBuildState): this;
  62693. serialize(): any;
  62694. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62695. }
  62696. }
  62697. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62698. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62699. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62700. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62701. import { Color3 } from "babylonjs/Maths/math.color";
  62702. import { Scene } from "babylonjs/scene";
  62703. /**
  62704. * Class used to store a color step for the GradientBlock
  62705. */
  62706. export class GradientBlockColorStep {
  62707. /**
  62708. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62709. */
  62710. step: number;
  62711. /**
  62712. * Gets or sets the color associated with this step
  62713. */
  62714. color: Color3;
  62715. /**
  62716. * Creates a new GradientBlockColorStep
  62717. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62718. * @param color defines the color associated with this step
  62719. */
  62720. constructor(
  62721. /**
  62722. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62723. */
  62724. step: number,
  62725. /**
  62726. * Gets or sets the color associated with this step
  62727. */
  62728. color: Color3);
  62729. }
  62730. /**
  62731. * Block used to return a color from a gradient based on an input value between 0 and 1
  62732. */
  62733. export class GradientBlock extends NodeMaterialBlock {
  62734. /**
  62735. * Gets or sets the list of color steps
  62736. */
  62737. colorSteps: GradientBlockColorStep[];
  62738. /**
  62739. * Creates a new GradientBlock
  62740. * @param name defines the block name
  62741. */
  62742. constructor(name: string);
  62743. /**
  62744. * Gets the current class name
  62745. * @returns the class name
  62746. */
  62747. getClassName(): string;
  62748. /**
  62749. * Gets the gradient input component
  62750. */
  62751. get gradient(): NodeMaterialConnectionPoint;
  62752. /**
  62753. * Gets the output component
  62754. */
  62755. get output(): NodeMaterialConnectionPoint;
  62756. private _writeColorConstant;
  62757. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62758. serialize(): any;
  62759. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62760. protected _dumpPropertiesCode(): string;
  62761. }
  62762. }
  62763. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62764. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62765. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62766. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62767. /**
  62768. * Block used to normalize lerp between 2 values
  62769. */
  62770. export class NLerpBlock extends NodeMaterialBlock {
  62771. /**
  62772. * Creates a new NLerpBlock
  62773. * @param name defines the block name
  62774. */
  62775. constructor(name: string);
  62776. /**
  62777. * Gets the current class name
  62778. * @returns the class name
  62779. */
  62780. getClassName(): string;
  62781. /**
  62782. * Gets the left operand input component
  62783. */
  62784. get left(): NodeMaterialConnectionPoint;
  62785. /**
  62786. * Gets the right operand input component
  62787. */
  62788. get right(): NodeMaterialConnectionPoint;
  62789. /**
  62790. * Gets the gradient operand input component
  62791. */
  62792. get gradient(): NodeMaterialConnectionPoint;
  62793. /**
  62794. * Gets the output component
  62795. */
  62796. get output(): NodeMaterialConnectionPoint;
  62797. protected _buildBlock(state: NodeMaterialBuildState): this;
  62798. }
  62799. }
  62800. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62804. import { Scene } from "babylonjs/scene";
  62805. /**
  62806. * block used to Generate a Worley Noise 3D Noise Pattern
  62807. */
  62808. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62809. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62810. manhattanDistance: boolean;
  62811. /**
  62812. * Creates a new WorleyNoise3DBlock
  62813. * @param name defines the block name
  62814. */
  62815. constructor(name: string);
  62816. /**
  62817. * Gets the current class name
  62818. * @returns the class name
  62819. */
  62820. getClassName(): string;
  62821. /**
  62822. * Gets the seed input component
  62823. */
  62824. get seed(): NodeMaterialConnectionPoint;
  62825. /**
  62826. * Gets the jitter input component
  62827. */
  62828. get jitter(): NodeMaterialConnectionPoint;
  62829. /**
  62830. * Gets the output component
  62831. */
  62832. get output(): NodeMaterialConnectionPoint;
  62833. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62834. /**
  62835. * Exposes the properties to the UI?
  62836. */
  62837. protected _dumpPropertiesCode(): string;
  62838. /**
  62839. * Exposes the properties to the Seralize?
  62840. */
  62841. serialize(): any;
  62842. /**
  62843. * Exposes the properties to the deseralize?
  62844. */
  62845. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62846. }
  62847. }
  62848. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62851. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62852. /**
  62853. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62854. */
  62855. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62856. /**
  62857. * Creates a new SimplexPerlin3DBlock
  62858. * @param name defines the block name
  62859. */
  62860. constructor(name: string);
  62861. /**
  62862. * Gets the current class name
  62863. * @returns the class name
  62864. */
  62865. getClassName(): string;
  62866. /**
  62867. * Gets the seed operand input component
  62868. */
  62869. get seed(): NodeMaterialConnectionPoint;
  62870. /**
  62871. * Gets the output component
  62872. */
  62873. get output(): NodeMaterialConnectionPoint;
  62874. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62875. }
  62876. }
  62877. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62881. /**
  62882. * Block used to blend normals
  62883. */
  62884. export class NormalBlendBlock extends NodeMaterialBlock {
  62885. /**
  62886. * Creates a new NormalBlendBlock
  62887. * @param name defines the block name
  62888. */
  62889. constructor(name: string);
  62890. /**
  62891. * Gets the current class name
  62892. * @returns the class name
  62893. */
  62894. getClassName(): string;
  62895. /**
  62896. * Gets the first input component
  62897. */
  62898. get normalMap0(): NodeMaterialConnectionPoint;
  62899. /**
  62900. * Gets the second input component
  62901. */
  62902. get normalMap1(): NodeMaterialConnectionPoint;
  62903. /**
  62904. * Gets the output component
  62905. */
  62906. get output(): NodeMaterialConnectionPoint;
  62907. protected _buildBlock(state: NodeMaterialBuildState): this;
  62908. }
  62909. }
  62910. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62912. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62914. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62915. /**
  62916. * Block used to rotate a 2d vector by a given angle
  62917. */
  62918. export class Rotate2dBlock extends NodeMaterialBlock {
  62919. /**
  62920. * Creates a new Rotate2dBlock
  62921. * @param name defines the block name
  62922. */
  62923. constructor(name: string);
  62924. /**
  62925. * Gets the current class name
  62926. * @returns the class name
  62927. */
  62928. getClassName(): string;
  62929. /**
  62930. * Gets the input vector
  62931. */
  62932. get input(): NodeMaterialConnectionPoint;
  62933. /**
  62934. * Gets the input angle
  62935. */
  62936. get angle(): NodeMaterialConnectionPoint;
  62937. /**
  62938. * Gets the output component
  62939. */
  62940. get output(): NodeMaterialConnectionPoint;
  62941. autoConfigure(material: NodeMaterial): void;
  62942. protected _buildBlock(state: NodeMaterialBuildState): this;
  62943. }
  62944. }
  62945. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62949. /**
  62950. * Block used to get the reflected vector from a direction and a normal
  62951. */
  62952. export class ReflectBlock extends NodeMaterialBlock {
  62953. /**
  62954. * Creates a new ReflectBlock
  62955. * @param name defines the block name
  62956. */
  62957. constructor(name: string);
  62958. /**
  62959. * Gets the current class name
  62960. * @returns the class name
  62961. */
  62962. getClassName(): string;
  62963. /**
  62964. * Gets the incident component
  62965. */
  62966. get incident(): NodeMaterialConnectionPoint;
  62967. /**
  62968. * Gets the normal component
  62969. */
  62970. get normal(): NodeMaterialConnectionPoint;
  62971. /**
  62972. * Gets the output component
  62973. */
  62974. get output(): NodeMaterialConnectionPoint;
  62975. protected _buildBlock(state: NodeMaterialBuildState): this;
  62976. }
  62977. }
  62978. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62982. /**
  62983. * Block used to get the refracted vector from a direction and a normal
  62984. */
  62985. export class RefractBlock extends NodeMaterialBlock {
  62986. /**
  62987. * Creates a new RefractBlock
  62988. * @param name defines the block name
  62989. */
  62990. constructor(name: string);
  62991. /**
  62992. * Gets the current class name
  62993. * @returns the class name
  62994. */
  62995. getClassName(): string;
  62996. /**
  62997. * Gets the incident component
  62998. */
  62999. get incident(): NodeMaterialConnectionPoint;
  63000. /**
  63001. * Gets the normal component
  63002. */
  63003. get normal(): NodeMaterialConnectionPoint;
  63004. /**
  63005. * Gets the index of refraction component
  63006. */
  63007. get ior(): NodeMaterialConnectionPoint;
  63008. /**
  63009. * Gets the output component
  63010. */
  63011. get output(): NodeMaterialConnectionPoint;
  63012. protected _buildBlock(state: NodeMaterialBuildState): this;
  63013. }
  63014. }
  63015. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63019. /**
  63020. * Block used to desaturate a color
  63021. */
  63022. export class DesaturateBlock extends NodeMaterialBlock {
  63023. /**
  63024. * Creates a new DesaturateBlock
  63025. * @param name defines the block name
  63026. */
  63027. constructor(name: string);
  63028. /**
  63029. * Gets the current class name
  63030. * @returns the class name
  63031. */
  63032. getClassName(): string;
  63033. /**
  63034. * Gets the color operand input component
  63035. */
  63036. get color(): NodeMaterialConnectionPoint;
  63037. /**
  63038. * Gets the level operand input component
  63039. */
  63040. get level(): NodeMaterialConnectionPoint;
  63041. /**
  63042. * Gets the output component
  63043. */
  63044. get output(): NodeMaterialConnectionPoint;
  63045. protected _buildBlock(state: NodeMaterialBuildState): this;
  63046. }
  63047. }
  63048. declare module "babylonjs/Materials/Node/Blocks/index" {
  63049. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63050. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63051. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63052. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63053. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63054. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63055. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63056. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63057. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63058. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63059. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63060. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63061. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63062. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63063. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63064. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63065. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63066. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63067. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63068. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63069. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63070. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63071. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63072. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63073. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63074. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63075. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63076. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63077. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63078. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63079. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63080. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63081. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63082. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63083. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63084. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63085. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63086. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63087. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63088. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63089. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63090. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63091. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63092. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63093. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63094. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63095. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63096. }
  63097. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63098. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63099. }
  63100. declare module "babylonjs/Materials/Node/index" {
  63101. export * from "babylonjs/Materials/Node/Enums/index";
  63102. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63103. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63104. export * from "babylonjs/Materials/Node/nodeMaterial";
  63105. export * from "babylonjs/Materials/Node/Blocks/index";
  63106. export * from "babylonjs/Materials/Node/Optimizers/index";
  63107. }
  63108. declare module "babylonjs/Materials/effectRenderer" {
  63109. import { Nullable } from "babylonjs/types";
  63110. import { Texture } from "babylonjs/Materials/Textures/texture";
  63111. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63112. import { Viewport } from "babylonjs/Maths/math.viewport";
  63113. import { Observable } from "babylonjs/Misc/observable";
  63114. import { Effect } from "babylonjs/Materials/effect";
  63115. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63116. import "babylonjs/Shaders/postprocess.vertex";
  63117. /**
  63118. * Effect Render Options
  63119. */
  63120. export interface IEffectRendererOptions {
  63121. /**
  63122. * Defines the vertices positions.
  63123. */
  63124. positions?: number[];
  63125. /**
  63126. * Defines the indices.
  63127. */
  63128. indices?: number[];
  63129. }
  63130. /**
  63131. * Helper class to render one or more effects
  63132. */
  63133. export class EffectRenderer {
  63134. private engine;
  63135. private static _DefaultOptions;
  63136. private _vertexBuffers;
  63137. private _indexBuffer;
  63138. private _ringBufferIndex;
  63139. private _ringScreenBuffer;
  63140. private _fullscreenViewport;
  63141. private _getNextFrameBuffer;
  63142. /**
  63143. * Creates an effect renderer
  63144. * @param engine the engine to use for rendering
  63145. * @param options defines the options of the effect renderer
  63146. */
  63147. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63148. /**
  63149. * Sets the current viewport in normalized coordinates 0-1
  63150. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63151. */
  63152. setViewport(viewport?: Viewport): void;
  63153. /**
  63154. * Binds the embedded attributes buffer to the effect.
  63155. * @param effect Defines the effect to bind the attributes for
  63156. */
  63157. bindBuffers(effect: Effect): void;
  63158. /**
  63159. * Sets the current effect wrapper to use during draw.
  63160. * The effect needs to be ready before calling this api.
  63161. * This also sets the default full screen position attribute.
  63162. * @param effectWrapper Defines the effect to draw with
  63163. */
  63164. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63165. /**
  63166. * Draws a full screen quad.
  63167. */
  63168. draw(): void;
  63169. /**
  63170. * renders one or more effects to a specified texture
  63171. * @param effectWrappers list of effects to renderer
  63172. * @param outputTexture texture to draw to, if null it will render to the screen
  63173. */
  63174. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63175. /**
  63176. * Disposes of the effect renderer
  63177. */
  63178. dispose(): void;
  63179. }
  63180. /**
  63181. * Options to create an EffectWrapper
  63182. */
  63183. interface EffectWrapperCreationOptions {
  63184. /**
  63185. * Engine to use to create the effect
  63186. */
  63187. engine: ThinEngine;
  63188. /**
  63189. * Fragment shader for the effect
  63190. */
  63191. fragmentShader: string;
  63192. /**
  63193. * Vertex shader for the effect
  63194. */
  63195. vertexShader?: string;
  63196. /**
  63197. * Attributes to use in the shader
  63198. */
  63199. attributeNames?: Array<string>;
  63200. /**
  63201. * Uniforms to use in the shader
  63202. */
  63203. uniformNames?: Array<string>;
  63204. /**
  63205. * Texture sampler names to use in the shader
  63206. */
  63207. samplerNames?: Array<string>;
  63208. /**
  63209. * The friendly name of the effect displayed in Spector.
  63210. */
  63211. name?: string;
  63212. }
  63213. /**
  63214. * Wraps an effect to be used for rendering
  63215. */
  63216. export class EffectWrapper {
  63217. /**
  63218. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63219. */
  63220. onApplyObservable: Observable<{}>;
  63221. /**
  63222. * The underlying effect
  63223. */
  63224. effect: Effect;
  63225. /**
  63226. * Creates an effect to be renderer
  63227. * @param creationOptions options to create the effect
  63228. */
  63229. constructor(creationOptions: EffectWrapperCreationOptions);
  63230. /**
  63231. * Disposes of the effect wrapper
  63232. */
  63233. dispose(): void;
  63234. }
  63235. }
  63236. declare module "babylonjs/Materials/index" {
  63237. export * from "babylonjs/Materials/Background/index";
  63238. export * from "babylonjs/Materials/colorCurves";
  63239. export * from "babylonjs/Materials/iEffectFallbacks";
  63240. export * from "babylonjs/Materials/effectFallbacks";
  63241. export * from "babylonjs/Materials/effect";
  63242. export * from "babylonjs/Materials/fresnelParameters";
  63243. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63244. export * from "babylonjs/Materials/material";
  63245. export * from "babylonjs/Materials/materialDefines";
  63246. export * from "babylonjs/Materials/materialHelper";
  63247. export * from "babylonjs/Materials/multiMaterial";
  63248. export * from "babylonjs/Materials/PBR/index";
  63249. export * from "babylonjs/Materials/pushMaterial";
  63250. export * from "babylonjs/Materials/shaderMaterial";
  63251. export * from "babylonjs/Materials/standardMaterial";
  63252. export * from "babylonjs/Materials/Textures/index";
  63253. export * from "babylonjs/Materials/uniformBuffer";
  63254. export * from "babylonjs/Materials/materialFlags";
  63255. export * from "babylonjs/Materials/Node/index";
  63256. export * from "babylonjs/Materials/effectRenderer";
  63257. }
  63258. declare module "babylonjs/Maths/index" {
  63259. export * from "babylonjs/Maths/math.scalar";
  63260. export * from "babylonjs/Maths/math";
  63261. export * from "babylonjs/Maths/sphericalPolynomial";
  63262. }
  63263. declare module "babylonjs/Misc/workerPool" {
  63264. import { IDisposable } from "babylonjs/scene";
  63265. /**
  63266. * Helper class to push actions to a pool of workers.
  63267. */
  63268. export class WorkerPool implements IDisposable {
  63269. private _workerInfos;
  63270. private _pendingActions;
  63271. /**
  63272. * Constructor
  63273. * @param workers Array of workers to use for actions
  63274. */
  63275. constructor(workers: Array<Worker>);
  63276. /**
  63277. * Terminates all workers and clears any pending actions.
  63278. */
  63279. dispose(): void;
  63280. /**
  63281. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63282. * pended until a worker has completed its action.
  63283. * @param action The action to perform. Call onComplete when the action is complete.
  63284. */
  63285. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63286. private _execute;
  63287. }
  63288. }
  63289. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63290. import { IDisposable } from "babylonjs/scene";
  63291. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63292. /**
  63293. * Configuration for Draco compression
  63294. */
  63295. export interface IDracoCompressionConfiguration {
  63296. /**
  63297. * Configuration for the decoder.
  63298. */
  63299. decoder: {
  63300. /**
  63301. * The url to the WebAssembly module.
  63302. */
  63303. wasmUrl?: string;
  63304. /**
  63305. * The url to the WebAssembly binary.
  63306. */
  63307. wasmBinaryUrl?: string;
  63308. /**
  63309. * The url to the fallback JavaScript module.
  63310. */
  63311. fallbackUrl?: string;
  63312. };
  63313. }
  63314. /**
  63315. * Draco compression (https://google.github.io/draco/)
  63316. *
  63317. * This class wraps the Draco module.
  63318. *
  63319. * **Encoder**
  63320. *
  63321. * The encoder is not currently implemented.
  63322. *
  63323. * **Decoder**
  63324. *
  63325. * 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.
  63326. *
  63327. * To update the configuration, use the following code:
  63328. * ```javascript
  63329. * DracoCompression.Configuration = {
  63330. * decoder: {
  63331. * wasmUrl: "<url to the WebAssembly library>",
  63332. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63333. * fallbackUrl: "<url to the fallback JavaScript library>",
  63334. * }
  63335. * };
  63336. * ```
  63337. *
  63338. * 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.
  63339. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63340. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63341. *
  63342. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63343. * ```javascript
  63344. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63345. * ```
  63346. *
  63347. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63348. */
  63349. export class DracoCompression implements IDisposable {
  63350. private _workerPoolPromise?;
  63351. private _decoderModulePromise?;
  63352. /**
  63353. * The configuration. Defaults to the following urls:
  63354. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63355. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63356. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63357. */
  63358. static Configuration: IDracoCompressionConfiguration;
  63359. /**
  63360. * Returns true if the decoder configuration is available.
  63361. */
  63362. static get DecoderAvailable(): boolean;
  63363. /**
  63364. * Default number of workers to create when creating the draco compression object.
  63365. */
  63366. static DefaultNumWorkers: number;
  63367. private static GetDefaultNumWorkers;
  63368. private static _Default;
  63369. /**
  63370. * Default instance for the draco compression object.
  63371. */
  63372. static get Default(): DracoCompression;
  63373. /**
  63374. * Constructor
  63375. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63376. */
  63377. constructor(numWorkers?: number);
  63378. /**
  63379. * Stop all async operations and release resources.
  63380. */
  63381. dispose(): void;
  63382. /**
  63383. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63384. * @returns a promise that resolves when ready
  63385. */
  63386. whenReadyAsync(): Promise<void>;
  63387. /**
  63388. * Decode Draco compressed mesh data to vertex data.
  63389. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63390. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63391. * @returns A promise that resolves with the decoded vertex data
  63392. */
  63393. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63394. [kind: string]: number;
  63395. }): Promise<VertexData>;
  63396. }
  63397. }
  63398. declare module "babylonjs/Meshes/Compression/index" {
  63399. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63400. }
  63401. declare module "babylonjs/Meshes/csg" {
  63402. import { Nullable } from "babylonjs/types";
  63403. import { Scene } from "babylonjs/scene";
  63404. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63405. import { Mesh } from "babylonjs/Meshes/mesh";
  63406. import { Material } from "babylonjs/Materials/material";
  63407. /**
  63408. * Class for building Constructive Solid Geometry
  63409. */
  63410. export class CSG {
  63411. private polygons;
  63412. /**
  63413. * The world matrix
  63414. */
  63415. matrix: Matrix;
  63416. /**
  63417. * Stores the position
  63418. */
  63419. position: Vector3;
  63420. /**
  63421. * Stores the rotation
  63422. */
  63423. rotation: Vector3;
  63424. /**
  63425. * Stores the rotation quaternion
  63426. */
  63427. rotationQuaternion: Nullable<Quaternion>;
  63428. /**
  63429. * Stores the scaling vector
  63430. */
  63431. scaling: Vector3;
  63432. /**
  63433. * Convert the Mesh to CSG
  63434. * @param mesh The Mesh to convert to CSG
  63435. * @returns A new CSG from the Mesh
  63436. */
  63437. static FromMesh(mesh: Mesh): CSG;
  63438. /**
  63439. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63440. * @param polygons Polygons used to construct a CSG solid
  63441. */
  63442. private static FromPolygons;
  63443. /**
  63444. * Clones, or makes a deep copy, of the CSG
  63445. * @returns A new CSG
  63446. */
  63447. clone(): CSG;
  63448. /**
  63449. * Unions this CSG with another CSG
  63450. * @param csg The CSG to union against this CSG
  63451. * @returns The unioned CSG
  63452. */
  63453. union(csg: CSG): CSG;
  63454. /**
  63455. * Unions this CSG with another CSG in place
  63456. * @param csg The CSG to union against this CSG
  63457. */
  63458. unionInPlace(csg: CSG): void;
  63459. /**
  63460. * Subtracts this CSG with another CSG
  63461. * @param csg The CSG to subtract against this CSG
  63462. * @returns A new CSG
  63463. */
  63464. subtract(csg: CSG): CSG;
  63465. /**
  63466. * Subtracts this CSG with another CSG in place
  63467. * @param csg The CSG to subtact against this CSG
  63468. */
  63469. subtractInPlace(csg: CSG): void;
  63470. /**
  63471. * Intersect this CSG with another CSG
  63472. * @param csg The CSG to intersect against this CSG
  63473. * @returns A new CSG
  63474. */
  63475. intersect(csg: CSG): CSG;
  63476. /**
  63477. * Intersects this CSG with another CSG in place
  63478. * @param csg The CSG to intersect against this CSG
  63479. */
  63480. intersectInPlace(csg: CSG): void;
  63481. /**
  63482. * Return a new CSG solid with solid and empty space switched. This solid is
  63483. * not modified.
  63484. * @returns A new CSG solid with solid and empty space switched
  63485. */
  63486. inverse(): CSG;
  63487. /**
  63488. * Inverses the CSG in place
  63489. */
  63490. inverseInPlace(): void;
  63491. /**
  63492. * This is used to keep meshes transformations so they can be restored
  63493. * when we build back a Babylon Mesh
  63494. * NB : All CSG operations are performed in world coordinates
  63495. * @param csg The CSG to copy the transform attributes from
  63496. * @returns This CSG
  63497. */
  63498. copyTransformAttributes(csg: CSG): CSG;
  63499. /**
  63500. * Build Raw mesh from CSG
  63501. * Coordinates here are in world space
  63502. * @param name The name of the mesh geometry
  63503. * @param scene The Scene
  63504. * @param keepSubMeshes Specifies if the submeshes should be kept
  63505. * @returns A new Mesh
  63506. */
  63507. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63508. /**
  63509. * Build Mesh from CSG taking material and transforms into account
  63510. * @param name The name of the Mesh
  63511. * @param material The material of the Mesh
  63512. * @param scene The Scene
  63513. * @param keepSubMeshes Specifies if submeshes should be kept
  63514. * @returns The new Mesh
  63515. */
  63516. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63517. }
  63518. }
  63519. declare module "babylonjs/Meshes/trailMesh" {
  63520. import { Mesh } from "babylonjs/Meshes/mesh";
  63521. import { Scene } from "babylonjs/scene";
  63522. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63523. /**
  63524. * Class used to create a trail following a mesh
  63525. */
  63526. export class TrailMesh extends Mesh {
  63527. private _generator;
  63528. private _autoStart;
  63529. private _running;
  63530. private _diameter;
  63531. private _length;
  63532. private _sectionPolygonPointsCount;
  63533. private _sectionVectors;
  63534. private _sectionNormalVectors;
  63535. private _beforeRenderObserver;
  63536. /**
  63537. * @constructor
  63538. * @param name The value used by scene.getMeshByName() to do a lookup.
  63539. * @param generator The mesh or transform node to generate a trail.
  63540. * @param scene The scene to add this mesh to.
  63541. * @param diameter Diameter of trailing mesh. Default is 1.
  63542. * @param length Length of trailing mesh. Default is 60.
  63543. * @param autoStart Automatically start trailing mesh. Default true.
  63544. */
  63545. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63546. /**
  63547. * "TrailMesh"
  63548. * @returns "TrailMesh"
  63549. */
  63550. getClassName(): string;
  63551. private _createMesh;
  63552. /**
  63553. * Start trailing mesh.
  63554. */
  63555. start(): void;
  63556. /**
  63557. * Stop trailing mesh.
  63558. */
  63559. stop(): void;
  63560. /**
  63561. * Update trailing mesh geometry.
  63562. */
  63563. update(): void;
  63564. /**
  63565. * Returns a new TrailMesh object.
  63566. * @param name is a string, the name given to the new mesh
  63567. * @param newGenerator use new generator object for cloned trail mesh
  63568. * @returns a new mesh
  63569. */
  63570. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63571. /**
  63572. * Serializes this trail mesh
  63573. * @param serializationObject object to write serialization to
  63574. */
  63575. serialize(serializationObject: any): void;
  63576. /**
  63577. * Parses a serialized trail mesh
  63578. * @param parsedMesh the serialized mesh
  63579. * @param scene the scene to create the trail mesh in
  63580. * @returns the created trail mesh
  63581. */
  63582. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63583. }
  63584. }
  63585. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63586. import { Nullable } from "babylonjs/types";
  63587. import { Scene } from "babylonjs/scene";
  63588. import { Vector4 } from "babylonjs/Maths/math.vector";
  63589. import { Color4 } from "babylonjs/Maths/math.color";
  63590. import { Mesh } from "babylonjs/Meshes/mesh";
  63591. /**
  63592. * Class containing static functions to help procedurally build meshes
  63593. */
  63594. export class TiledBoxBuilder {
  63595. /**
  63596. * Creates a box mesh
  63597. * 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)
  63598. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63602. * @param name defines the name of the mesh
  63603. * @param options defines the options used to create the mesh
  63604. * @param scene defines the hosting scene
  63605. * @returns the box mesh
  63606. */
  63607. static CreateTiledBox(name: string, options: {
  63608. pattern?: number;
  63609. width?: number;
  63610. height?: number;
  63611. depth?: number;
  63612. tileSize?: number;
  63613. tileWidth?: number;
  63614. tileHeight?: number;
  63615. alignHorizontal?: number;
  63616. alignVertical?: number;
  63617. faceUV?: Vector4[];
  63618. faceColors?: Color4[];
  63619. sideOrientation?: number;
  63620. updatable?: boolean;
  63621. }, scene?: Nullable<Scene>): Mesh;
  63622. }
  63623. }
  63624. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63625. import { Vector4 } from "babylonjs/Maths/math.vector";
  63626. import { Mesh } from "babylonjs/Meshes/mesh";
  63627. /**
  63628. * Class containing static functions to help procedurally build meshes
  63629. */
  63630. export class TorusKnotBuilder {
  63631. /**
  63632. * Creates a torus knot mesh
  63633. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63634. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63635. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63636. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63640. * @param name defines the name of the mesh
  63641. * @param options defines the options used to create the mesh
  63642. * @param scene defines the hosting scene
  63643. * @returns the torus knot mesh
  63644. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63645. */
  63646. static CreateTorusKnot(name: string, options: {
  63647. radius?: number;
  63648. tube?: number;
  63649. radialSegments?: number;
  63650. tubularSegments?: number;
  63651. p?: number;
  63652. q?: number;
  63653. updatable?: boolean;
  63654. sideOrientation?: number;
  63655. frontUVs?: Vector4;
  63656. backUVs?: Vector4;
  63657. }, scene: any): Mesh;
  63658. }
  63659. }
  63660. declare module "babylonjs/Meshes/polygonMesh" {
  63661. import { Scene } from "babylonjs/scene";
  63662. import { Vector2 } from "babylonjs/Maths/math.vector";
  63663. import { Mesh } from "babylonjs/Meshes/mesh";
  63664. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63665. import { Path2 } from "babylonjs/Maths/math.path";
  63666. /**
  63667. * Polygon
  63668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63669. */
  63670. export class Polygon {
  63671. /**
  63672. * Creates a rectangle
  63673. * @param xmin bottom X coord
  63674. * @param ymin bottom Y coord
  63675. * @param xmax top X coord
  63676. * @param ymax top Y coord
  63677. * @returns points that make the resulting rectation
  63678. */
  63679. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63680. /**
  63681. * Creates a circle
  63682. * @param radius radius of circle
  63683. * @param cx scale in x
  63684. * @param cy scale in y
  63685. * @param numberOfSides number of sides that make up the circle
  63686. * @returns points that make the resulting circle
  63687. */
  63688. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63689. /**
  63690. * Creates a polygon from input string
  63691. * @param input Input polygon data
  63692. * @returns the parsed points
  63693. */
  63694. static Parse(input: string): Vector2[];
  63695. /**
  63696. * Starts building a polygon from x and y coordinates
  63697. * @param x x coordinate
  63698. * @param y y coordinate
  63699. * @returns the started path2
  63700. */
  63701. static StartingAt(x: number, y: number): Path2;
  63702. }
  63703. /**
  63704. * Builds a polygon
  63705. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63706. */
  63707. export class PolygonMeshBuilder {
  63708. private _points;
  63709. private _outlinepoints;
  63710. private _holes;
  63711. private _name;
  63712. private _scene;
  63713. private _epoints;
  63714. private _eholes;
  63715. private _addToepoint;
  63716. /**
  63717. * Babylon reference to the earcut plugin.
  63718. */
  63719. bjsEarcut: any;
  63720. /**
  63721. * Creates a PolygonMeshBuilder
  63722. * @param name name of the builder
  63723. * @param contours Path of the polygon
  63724. * @param scene scene to add to when creating the mesh
  63725. * @param earcutInjection can be used to inject your own earcut reference
  63726. */
  63727. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63728. /**
  63729. * Adds a whole within the polygon
  63730. * @param hole Array of points defining the hole
  63731. * @returns this
  63732. */
  63733. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63734. /**
  63735. * Creates the polygon
  63736. * @param updatable If the mesh should be updatable
  63737. * @param depth The depth of the mesh created
  63738. * @returns the created mesh
  63739. */
  63740. build(updatable?: boolean, depth?: number): Mesh;
  63741. /**
  63742. * Creates the polygon
  63743. * @param depth The depth of the mesh created
  63744. * @returns the created VertexData
  63745. */
  63746. buildVertexData(depth?: number): VertexData;
  63747. /**
  63748. * Adds a side to the polygon
  63749. * @param positions points that make the polygon
  63750. * @param normals normals of the polygon
  63751. * @param uvs uvs of the polygon
  63752. * @param indices indices of the polygon
  63753. * @param bounds bounds of the polygon
  63754. * @param points points of the polygon
  63755. * @param depth depth of the polygon
  63756. * @param flip flip of the polygon
  63757. */
  63758. private addSide;
  63759. }
  63760. }
  63761. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63762. import { Scene } from "babylonjs/scene";
  63763. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63764. import { Color4 } from "babylonjs/Maths/math.color";
  63765. import { Mesh } from "babylonjs/Meshes/mesh";
  63766. import { Nullable } from "babylonjs/types";
  63767. /**
  63768. * Class containing static functions to help procedurally build meshes
  63769. */
  63770. export class PolygonBuilder {
  63771. /**
  63772. * Creates a polygon mesh
  63773. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63774. * * 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
  63775. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63778. * * Remember you can only change the shape positions, not their number when updating a polygon
  63779. * @param name defines the name of the mesh
  63780. * @param options defines the options used to create the mesh
  63781. * @param scene defines the hosting scene
  63782. * @param earcutInjection can be used to inject your own earcut reference
  63783. * @returns the polygon mesh
  63784. */
  63785. static CreatePolygon(name: string, options: {
  63786. shape: Vector3[];
  63787. holes?: Vector3[][];
  63788. depth?: number;
  63789. faceUV?: Vector4[];
  63790. faceColors?: Color4[];
  63791. updatable?: boolean;
  63792. sideOrientation?: number;
  63793. frontUVs?: Vector4;
  63794. backUVs?: Vector4;
  63795. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63796. /**
  63797. * Creates an extruded polygon mesh, with depth in the Y direction.
  63798. * * 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)
  63799. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63800. * @param name defines the name of the mesh
  63801. * @param options defines the options used to create the mesh
  63802. * @param scene defines the hosting scene
  63803. * @param earcutInjection can be used to inject your own earcut reference
  63804. * @returns the polygon mesh
  63805. */
  63806. static ExtrudePolygon(name: string, options: {
  63807. shape: Vector3[];
  63808. holes?: Vector3[][];
  63809. depth?: number;
  63810. faceUV?: Vector4[];
  63811. faceColors?: Color4[];
  63812. updatable?: boolean;
  63813. sideOrientation?: number;
  63814. frontUVs?: Vector4;
  63815. backUVs?: Vector4;
  63816. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63817. }
  63818. }
  63819. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63820. import { Scene } from "babylonjs/scene";
  63821. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63822. import { Mesh } from "babylonjs/Meshes/mesh";
  63823. import { Nullable } from "babylonjs/types";
  63824. /**
  63825. * Class containing static functions to help procedurally build meshes
  63826. */
  63827. export class LatheBuilder {
  63828. /**
  63829. * Creates lathe mesh.
  63830. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63831. * * 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
  63832. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63833. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63834. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63835. * * 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
  63836. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63837. * * 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
  63838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63840. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63842. * @param name defines the name of the mesh
  63843. * @param options defines the options used to create the mesh
  63844. * @param scene defines the hosting scene
  63845. * @returns the lathe mesh
  63846. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63847. */
  63848. static CreateLathe(name: string, options: {
  63849. shape: Vector3[];
  63850. radius?: number;
  63851. tessellation?: number;
  63852. clip?: number;
  63853. arc?: number;
  63854. closed?: boolean;
  63855. updatable?: boolean;
  63856. sideOrientation?: number;
  63857. frontUVs?: Vector4;
  63858. backUVs?: Vector4;
  63859. cap?: number;
  63860. invertUV?: boolean;
  63861. }, scene?: Nullable<Scene>): Mesh;
  63862. }
  63863. }
  63864. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63865. import { Nullable } from "babylonjs/types";
  63866. import { Scene } from "babylonjs/scene";
  63867. import { Vector4 } from "babylonjs/Maths/math.vector";
  63868. import { Mesh } from "babylonjs/Meshes/mesh";
  63869. /**
  63870. * Class containing static functions to help procedurally build meshes
  63871. */
  63872. export class TiledPlaneBuilder {
  63873. /**
  63874. * Creates a tiled plane mesh
  63875. * * The parameter `pattern` will, depending on value, do nothing or
  63876. * * * flip (reflect about central vertical) alternate tiles across and up
  63877. * * * flip every tile on alternate rows
  63878. * * * rotate (180 degs) alternate tiles across and up
  63879. * * * rotate every tile on alternate rows
  63880. * * * flip and rotate alternate tiles across and up
  63881. * * * flip and rotate every tile on alternate rows
  63882. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63883. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63885. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63886. * * 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)
  63887. * * 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)
  63888. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63889. * @param name defines the name of the mesh
  63890. * @param options defines the options used to create the mesh
  63891. * @param scene defines the hosting scene
  63892. * @returns the box mesh
  63893. */
  63894. static CreateTiledPlane(name: string, options: {
  63895. pattern?: number;
  63896. tileSize?: number;
  63897. tileWidth?: number;
  63898. tileHeight?: number;
  63899. size?: number;
  63900. width?: number;
  63901. height?: number;
  63902. alignHorizontal?: number;
  63903. alignVertical?: number;
  63904. sideOrientation?: number;
  63905. frontUVs?: Vector4;
  63906. backUVs?: Vector4;
  63907. updatable?: boolean;
  63908. }, scene?: Nullable<Scene>): Mesh;
  63909. }
  63910. }
  63911. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63912. import { Nullable } from "babylonjs/types";
  63913. import { Scene } from "babylonjs/scene";
  63914. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63915. import { Mesh } from "babylonjs/Meshes/mesh";
  63916. /**
  63917. * Class containing static functions to help procedurally build meshes
  63918. */
  63919. export class TubeBuilder {
  63920. /**
  63921. * Creates a tube mesh.
  63922. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63923. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63924. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63925. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63926. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63927. * * 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)
  63928. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63929. * * 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
  63930. * * 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
  63931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63932. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63933. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63935. * @param name defines the name of the mesh
  63936. * @param options defines the options used to create the mesh
  63937. * @param scene defines the hosting scene
  63938. * @returns the tube mesh
  63939. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63940. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63941. */
  63942. static CreateTube(name: string, options: {
  63943. path: Vector3[];
  63944. radius?: number;
  63945. tessellation?: number;
  63946. radiusFunction?: {
  63947. (i: number, distance: number): number;
  63948. };
  63949. cap?: number;
  63950. arc?: number;
  63951. updatable?: boolean;
  63952. sideOrientation?: number;
  63953. frontUVs?: Vector4;
  63954. backUVs?: Vector4;
  63955. instance?: Mesh;
  63956. invertUV?: boolean;
  63957. }, scene?: Nullable<Scene>): Mesh;
  63958. }
  63959. }
  63960. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63961. import { Scene } from "babylonjs/scene";
  63962. import { Vector4 } from "babylonjs/Maths/math.vector";
  63963. import { Mesh } from "babylonjs/Meshes/mesh";
  63964. import { Nullable } from "babylonjs/types";
  63965. /**
  63966. * Class containing static functions to help procedurally build meshes
  63967. */
  63968. export class IcoSphereBuilder {
  63969. /**
  63970. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63971. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63972. * * 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`)
  63973. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63974. * * 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
  63975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63978. * @param name defines the name of the mesh
  63979. * @param options defines the options used to create the mesh
  63980. * @param scene defines the hosting scene
  63981. * @returns the icosahedron mesh
  63982. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63983. */
  63984. static CreateIcoSphere(name: string, options: {
  63985. radius?: number;
  63986. radiusX?: number;
  63987. radiusY?: number;
  63988. radiusZ?: number;
  63989. flat?: boolean;
  63990. subdivisions?: number;
  63991. sideOrientation?: number;
  63992. frontUVs?: Vector4;
  63993. backUVs?: Vector4;
  63994. updatable?: boolean;
  63995. }, scene?: Nullable<Scene>): Mesh;
  63996. }
  63997. }
  63998. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  63999. import { Vector3 } from "babylonjs/Maths/math.vector";
  64000. import { Mesh } from "babylonjs/Meshes/mesh";
  64001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64002. /**
  64003. * Class containing static functions to help procedurally build meshes
  64004. */
  64005. export class DecalBuilder {
  64006. /**
  64007. * Creates a decal mesh.
  64008. * 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
  64009. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64010. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64011. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64012. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64013. * @param name defines the name of the mesh
  64014. * @param sourceMesh defines the mesh where the decal must be applied
  64015. * @param options defines the options used to create the mesh
  64016. * @param scene defines the hosting scene
  64017. * @returns the decal mesh
  64018. * @see https://doc.babylonjs.com/how_to/decals
  64019. */
  64020. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64021. position?: Vector3;
  64022. normal?: Vector3;
  64023. size?: Vector3;
  64024. angle?: number;
  64025. }): Mesh;
  64026. }
  64027. }
  64028. declare module "babylonjs/Meshes/meshBuilder" {
  64029. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64030. import { Nullable } from "babylonjs/types";
  64031. import { Scene } from "babylonjs/scene";
  64032. import { Mesh } from "babylonjs/Meshes/mesh";
  64033. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64034. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64036. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64037. import { Plane } from "babylonjs/Maths/math.plane";
  64038. /**
  64039. * Class containing static functions to help procedurally build meshes
  64040. */
  64041. export class MeshBuilder {
  64042. /**
  64043. * Creates a box mesh
  64044. * * The parameter `size` sets the size (float) of each box side (default 1)
  64045. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64046. * * 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)
  64047. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64049. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64051. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64052. * @param name defines the name of the mesh
  64053. * @param options defines the options used to create the mesh
  64054. * @param scene defines the hosting scene
  64055. * @returns the box mesh
  64056. */
  64057. static CreateBox(name: string, options: {
  64058. size?: number;
  64059. width?: number;
  64060. height?: number;
  64061. depth?: number;
  64062. faceUV?: Vector4[];
  64063. faceColors?: Color4[];
  64064. sideOrientation?: number;
  64065. frontUVs?: Vector4;
  64066. backUVs?: Vector4;
  64067. updatable?: boolean;
  64068. }, scene?: Nullable<Scene>): Mesh;
  64069. /**
  64070. * Creates a tiled box mesh
  64071. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64073. * @param name defines the name of the mesh
  64074. * @param options defines the options used to create the mesh
  64075. * @param scene defines the hosting scene
  64076. * @returns the tiled box mesh
  64077. */
  64078. static CreateTiledBox(name: string, options: {
  64079. pattern?: number;
  64080. size?: number;
  64081. width?: number;
  64082. height?: number;
  64083. depth: number;
  64084. tileSize?: number;
  64085. tileWidth?: number;
  64086. tileHeight?: number;
  64087. faceUV?: Vector4[];
  64088. faceColors?: Color4[];
  64089. alignHorizontal?: number;
  64090. alignVertical?: number;
  64091. sideOrientation?: number;
  64092. updatable?: boolean;
  64093. }, scene?: Nullable<Scene>): Mesh;
  64094. /**
  64095. * Creates a sphere mesh
  64096. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64097. * * 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`)
  64098. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64099. * * 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
  64100. * * 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)
  64101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64104. * @param name defines the name of the mesh
  64105. * @param options defines the options used to create the mesh
  64106. * @param scene defines the hosting scene
  64107. * @returns the sphere mesh
  64108. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64109. */
  64110. static CreateSphere(name: string, options: {
  64111. segments?: number;
  64112. diameter?: number;
  64113. diameterX?: number;
  64114. diameterY?: number;
  64115. diameterZ?: number;
  64116. arc?: number;
  64117. slice?: number;
  64118. sideOrientation?: number;
  64119. frontUVs?: Vector4;
  64120. backUVs?: Vector4;
  64121. updatable?: boolean;
  64122. }, scene?: Nullable<Scene>): Mesh;
  64123. /**
  64124. * Creates a plane polygonal mesh. By default, this is a disc
  64125. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64126. * * 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
  64127. * * 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
  64128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64129. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64131. * @param name defines the name of the mesh
  64132. * @param options defines the options used to create the mesh
  64133. * @param scene defines the hosting scene
  64134. * @returns the plane polygonal mesh
  64135. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64136. */
  64137. static CreateDisc(name: string, options: {
  64138. radius?: number;
  64139. tessellation?: number;
  64140. arc?: number;
  64141. updatable?: boolean;
  64142. sideOrientation?: number;
  64143. frontUVs?: Vector4;
  64144. backUVs?: Vector4;
  64145. }, scene?: Nullable<Scene>): Mesh;
  64146. /**
  64147. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64148. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64149. * * 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`)
  64150. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64151. * * 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
  64152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64155. * @param name defines the name of the mesh
  64156. * @param options defines the options used to create the mesh
  64157. * @param scene defines the hosting scene
  64158. * @returns the icosahedron mesh
  64159. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64160. */
  64161. static CreateIcoSphere(name: string, options: {
  64162. radius?: number;
  64163. radiusX?: number;
  64164. radiusY?: number;
  64165. radiusZ?: number;
  64166. flat?: boolean;
  64167. subdivisions?: number;
  64168. sideOrientation?: number;
  64169. frontUVs?: Vector4;
  64170. backUVs?: Vector4;
  64171. updatable?: boolean;
  64172. }, scene?: Nullable<Scene>): Mesh;
  64173. /**
  64174. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64175. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64176. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64177. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64178. * * 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
  64179. * * 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
  64180. * * 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
  64181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64182. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64183. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64184. * * 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
  64185. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64186. * * 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
  64187. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64189. * @param name defines the name of the mesh
  64190. * @param options defines the options used to create the mesh
  64191. * @param scene defines the hosting scene
  64192. * @returns the ribbon mesh
  64193. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64194. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64195. */
  64196. static CreateRibbon(name: string, options: {
  64197. pathArray: Vector3[][];
  64198. closeArray?: boolean;
  64199. closePath?: boolean;
  64200. offset?: number;
  64201. updatable?: boolean;
  64202. sideOrientation?: number;
  64203. frontUVs?: Vector4;
  64204. backUVs?: Vector4;
  64205. instance?: Mesh;
  64206. invertUV?: boolean;
  64207. uvs?: Vector2[];
  64208. colors?: Color4[];
  64209. }, scene?: Nullable<Scene>): Mesh;
  64210. /**
  64211. * Creates a cylinder or a cone mesh
  64212. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64213. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64214. * * 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.
  64215. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64216. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64217. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64218. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64219. * * 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).
  64220. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64221. * * 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).
  64222. * * 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
  64223. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64224. * * 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
  64225. * * 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.
  64226. * * If `enclose` is false, a ring surface is one element.
  64227. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64228. * * 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
  64229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64232. * @param name defines the name of the mesh
  64233. * @param options defines the options used to create the mesh
  64234. * @param scene defines the hosting scene
  64235. * @returns the cylinder mesh
  64236. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64237. */
  64238. static CreateCylinder(name: string, options: {
  64239. height?: number;
  64240. diameterTop?: number;
  64241. diameterBottom?: number;
  64242. diameter?: number;
  64243. tessellation?: number;
  64244. subdivisions?: number;
  64245. arc?: number;
  64246. faceColors?: Color4[];
  64247. faceUV?: Vector4[];
  64248. updatable?: boolean;
  64249. hasRings?: boolean;
  64250. enclose?: boolean;
  64251. cap?: number;
  64252. sideOrientation?: number;
  64253. frontUVs?: Vector4;
  64254. backUVs?: Vector4;
  64255. }, scene?: Nullable<Scene>): Mesh;
  64256. /**
  64257. * Creates a torus mesh
  64258. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64259. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64260. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64264. * @param name defines the name of the mesh
  64265. * @param options defines the options used to create the mesh
  64266. * @param scene defines the hosting scene
  64267. * @returns the torus mesh
  64268. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64269. */
  64270. static CreateTorus(name: string, options: {
  64271. diameter?: number;
  64272. thickness?: number;
  64273. tessellation?: number;
  64274. updatable?: boolean;
  64275. sideOrientation?: number;
  64276. frontUVs?: Vector4;
  64277. backUVs?: Vector4;
  64278. }, scene?: Nullable<Scene>): Mesh;
  64279. /**
  64280. * Creates a torus knot mesh
  64281. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64282. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64283. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64284. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64286. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64288. * @param name defines the name of the mesh
  64289. * @param options defines the options used to create the mesh
  64290. * @param scene defines the hosting scene
  64291. * @returns the torus knot mesh
  64292. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64293. */
  64294. static CreateTorusKnot(name: string, options: {
  64295. radius?: number;
  64296. tube?: number;
  64297. radialSegments?: number;
  64298. tubularSegments?: number;
  64299. p?: number;
  64300. q?: number;
  64301. updatable?: boolean;
  64302. sideOrientation?: number;
  64303. frontUVs?: Vector4;
  64304. backUVs?: Vector4;
  64305. }, scene?: Nullable<Scene>): Mesh;
  64306. /**
  64307. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64308. * * 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
  64309. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64310. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64311. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64312. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64313. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64314. * * 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
  64315. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64318. * @param name defines the name of the new line system
  64319. * @param options defines the options used to create the line system
  64320. * @param scene defines the hosting scene
  64321. * @returns a new line system mesh
  64322. */
  64323. static CreateLineSystem(name: string, options: {
  64324. lines: Vector3[][];
  64325. updatable?: boolean;
  64326. instance?: Nullable<LinesMesh>;
  64327. colors?: Nullable<Color4[][]>;
  64328. useVertexAlpha?: boolean;
  64329. }, scene: Nullable<Scene>): LinesMesh;
  64330. /**
  64331. * Creates a line mesh
  64332. * 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
  64333. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64334. * * The parameter `points` is an array successive Vector3
  64335. * * 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
  64336. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64337. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64338. * * When updating an instance, remember that only point positions can change, not the number of points
  64339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64341. * @param name defines the name of the new line system
  64342. * @param options defines the options used to create the line system
  64343. * @param scene defines the hosting scene
  64344. * @returns a new line mesh
  64345. */
  64346. static CreateLines(name: string, options: {
  64347. points: Vector3[];
  64348. updatable?: boolean;
  64349. instance?: Nullable<LinesMesh>;
  64350. colors?: Color4[];
  64351. useVertexAlpha?: boolean;
  64352. }, scene?: Nullable<Scene>): LinesMesh;
  64353. /**
  64354. * Creates a dashed line mesh
  64355. * * 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
  64356. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64357. * * The parameter `points` is an array successive Vector3
  64358. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64359. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64360. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64361. * * 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
  64362. * * When updating an instance, remember that only point positions can change, not the number of points
  64363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64364. * @param name defines the name of the mesh
  64365. * @param options defines the options used to create the mesh
  64366. * @param scene defines the hosting scene
  64367. * @returns the dashed line mesh
  64368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64369. */
  64370. static CreateDashedLines(name: string, options: {
  64371. points: Vector3[];
  64372. dashSize?: number;
  64373. gapSize?: number;
  64374. dashNb?: number;
  64375. updatable?: boolean;
  64376. instance?: LinesMesh;
  64377. }, scene?: Nullable<Scene>): LinesMesh;
  64378. /**
  64379. * 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.
  64380. * * 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.
  64381. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64382. * * 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.
  64383. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64384. * * 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
  64385. * * 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
  64386. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64389. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64391. * @param name defines the name of the mesh
  64392. * @param options defines the options used to create the mesh
  64393. * @param scene defines the hosting scene
  64394. * @returns the extruded shape mesh
  64395. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64396. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64397. */
  64398. static ExtrudeShape(name: string, options: {
  64399. shape: Vector3[];
  64400. path: Vector3[];
  64401. scale?: number;
  64402. rotation?: number;
  64403. cap?: number;
  64404. updatable?: boolean;
  64405. sideOrientation?: number;
  64406. frontUVs?: Vector4;
  64407. backUVs?: Vector4;
  64408. instance?: Mesh;
  64409. invertUV?: boolean;
  64410. }, scene?: Nullable<Scene>): Mesh;
  64411. /**
  64412. * Creates an custom extruded shape mesh.
  64413. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64414. * * 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.
  64415. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64416. * * 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
  64417. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64418. * * 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
  64419. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64420. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64421. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64422. * * 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
  64423. * * 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
  64424. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64427. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64429. * @param name defines the name of the mesh
  64430. * @param options defines the options used to create the mesh
  64431. * @param scene defines the hosting scene
  64432. * @returns the custom extruded shape mesh
  64433. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64434. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64435. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64436. */
  64437. static ExtrudeShapeCustom(name: string, options: {
  64438. shape: Vector3[];
  64439. path: Vector3[];
  64440. scaleFunction?: any;
  64441. rotationFunction?: any;
  64442. ribbonCloseArray?: boolean;
  64443. ribbonClosePath?: boolean;
  64444. cap?: number;
  64445. updatable?: boolean;
  64446. sideOrientation?: number;
  64447. frontUVs?: Vector4;
  64448. backUVs?: Vector4;
  64449. instance?: Mesh;
  64450. invertUV?: boolean;
  64451. }, scene?: Nullable<Scene>): Mesh;
  64452. /**
  64453. * Creates lathe mesh.
  64454. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64455. * * 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
  64456. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64457. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64458. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64459. * * 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
  64460. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64461. * * 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
  64462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64466. * @param name defines the name of the mesh
  64467. * @param options defines the options used to create the mesh
  64468. * @param scene defines the hosting scene
  64469. * @returns the lathe mesh
  64470. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64471. */
  64472. static CreateLathe(name: string, options: {
  64473. shape: Vector3[];
  64474. radius?: number;
  64475. tessellation?: number;
  64476. clip?: number;
  64477. arc?: number;
  64478. closed?: boolean;
  64479. updatable?: boolean;
  64480. sideOrientation?: number;
  64481. frontUVs?: Vector4;
  64482. backUVs?: Vector4;
  64483. cap?: number;
  64484. invertUV?: boolean;
  64485. }, scene?: Nullable<Scene>): Mesh;
  64486. /**
  64487. * Creates a tiled plane mesh
  64488. * * You can set a limited pattern arrangement with the tiles
  64489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64490. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64492. * @param name defines the name of the mesh
  64493. * @param options defines the options used to create the mesh
  64494. * @param scene defines the hosting scene
  64495. * @returns the plane mesh
  64496. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64497. */
  64498. static CreateTiledPlane(name: string, options: {
  64499. pattern?: number;
  64500. tileSize?: number;
  64501. tileWidth?: number;
  64502. tileHeight?: number;
  64503. size?: number;
  64504. width?: number;
  64505. height?: number;
  64506. alignHorizontal?: number;
  64507. alignVertical?: number;
  64508. sideOrientation?: number;
  64509. frontUVs?: Vector4;
  64510. backUVs?: Vector4;
  64511. updatable?: boolean;
  64512. }, scene?: Nullable<Scene>): Mesh;
  64513. /**
  64514. * Creates a plane mesh
  64515. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64516. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64517. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64521. * @param name defines the name of the mesh
  64522. * @param options defines the options used to create the mesh
  64523. * @param scene defines the hosting scene
  64524. * @returns the plane mesh
  64525. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64526. */
  64527. static CreatePlane(name: string, options: {
  64528. size?: number;
  64529. width?: number;
  64530. height?: number;
  64531. sideOrientation?: number;
  64532. frontUVs?: Vector4;
  64533. backUVs?: Vector4;
  64534. updatable?: boolean;
  64535. sourcePlane?: Plane;
  64536. }, scene?: Nullable<Scene>): Mesh;
  64537. /**
  64538. * Creates a ground mesh
  64539. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64540. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64542. * @param name defines the name of the mesh
  64543. * @param options defines the options used to create the mesh
  64544. * @param scene defines the hosting scene
  64545. * @returns the ground mesh
  64546. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64547. */
  64548. static CreateGround(name: string, options: {
  64549. width?: number;
  64550. height?: number;
  64551. subdivisions?: number;
  64552. subdivisionsX?: number;
  64553. subdivisionsY?: number;
  64554. updatable?: boolean;
  64555. }, scene?: Nullable<Scene>): Mesh;
  64556. /**
  64557. * Creates a tiled ground mesh
  64558. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64559. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64560. * * 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
  64561. * * 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
  64562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64563. * @param name defines the name of the mesh
  64564. * @param options defines the options used to create the mesh
  64565. * @param scene defines the hosting scene
  64566. * @returns the tiled ground mesh
  64567. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64568. */
  64569. static CreateTiledGround(name: string, options: {
  64570. xmin: number;
  64571. zmin: number;
  64572. xmax: number;
  64573. zmax: number;
  64574. subdivisions?: {
  64575. w: number;
  64576. h: number;
  64577. };
  64578. precision?: {
  64579. w: number;
  64580. h: number;
  64581. };
  64582. updatable?: boolean;
  64583. }, scene?: Nullable<Scene>): Mesh;
  64584. /**
  64585. * Creates a ground mesh from a height map
  64586. * * The parameter `url` sets the URL of the height map image resource.
  64587. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64588. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64589. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64590. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64591. * * 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.
  64592. * * 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).
  64593. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64595. * @param name defines the name of the mesh
  64596. * @param url defines the url to the height map
  64597. * @param options defines the options used to create the mesh
  64598. * @param scene defines the hosting scene
  64599. * @returns the ground mesh
  64600. * @see https://doc.babylonjs.com/babylon101/height_map
  64601. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64602. */
  64603. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64604. width?: number;
  64605. height?: number;
  64606. subdivisions?: number;
  64607. minHeight?: number;
  64608. maxHeight?: number;
  64609. colorFilter?: Color3;
  64610. alphaFilter?: number;
  64611. updatable?: boolean;
  64612. onReady?: (mesh: GroundMesh) => void;
  64613. }, scene?: Nullable<Scene>): GroundMesh;
  64614. /**
  64615. * Creates a polygon mesh
  64616. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64617. * * 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
  64618. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64621. * * Remember you can only change the shape positions, not their number when updating a polygon
  64622. * @param name defines the name of the mesh
  64623. * @param options defines the options used to create the mesh
  64624. * @param scene defines the hosting scene
  64625. * @param earcutInjection can be used to inject your own earcut reference
  64626. * @returns the polygon mesh
  64627. */
  64628. static CreatePolygon(name: string, options: {
  64629. shape: Vector3[];
  64630. holes?: Vector3[][];
  64631. depth?: number;
  64632. faceUV?: Vector4[];
  64633. faceColors?: Color4[];
  64634. updatable?: boolean;
  64635. sideOrientation?: number;
  64636. frontUVs?: Vector4;
  64637. backUVs?: Vector4;
  64638. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64639. /**
  64640. * Creates an extruded polygon mesh, with depth in the Y direction.
  64641. * * 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)
  64642. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64643. * @param name defines the name of the mesh
  64644. * @param options defines the options used to create the mesh
  64645. * @param scene defines the hosting scene
  64646. * @param earcutInjection can be used to inject your own earcut reference
  64647. * @returns the polygon mesh
  64648. */
  64649. static ExtrudePolygon(name: string, options: {
  64650. shape: Vector3[];
  64651. holes?: Vector3[][];
  64652. depth?: number;
  64653. faceUV?: Vector4[];
  64654. faceColors?: Color4[];
  64655. updatable?: boolean;
  64656. sideOrientation?: number;
  64657. frontUVs?: Vector4;
  64658. backUVs?: Vector4;
  64659. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64660. /**
  64661. * Creates a tube mesh.
  64662. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64663. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64664. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64665. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64666. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64667. * * 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)
  64668. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64669. * * 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
  64670. * * 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
  64671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64673. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64675. * @param name defines the name of the mesh
  64676. * @param options defines the options used to create the mesh
  64677. * @param scene defines the hosting scene
  64678. * @returns the tube mesh
  64679. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64680. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64681. */
  64682. static CreateTube(name: string, options: {
  64683. path: Vector3[];
  64684. radius?: number;
  64685. tessellation?: number;
  64686. radiusFunction?: {
  64687. (i: number, distance: number): number;
  64688. };
  64689. cap?: number;
  64690. arc?: number;
  64691. updatable?: boolean;
  64692. sideOrientation?: number;
  64693. frontUVs?: Vector4;
  64694. backUVs?: Vector4;
  64695. instance?: Mesh;
  64696. invertUV?: boolean;
  64697. }, scene?: Nullable<Scene>): Mesh;
  64698. /**
  64699. * Creates a polyhedron mesh
  64700. * * 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
  64701. * * The parameter `size` (positive float, default 1) sets the polygon size
  64702. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64703. * * 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`
  64704. * * 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
  64705. * * 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)`)
  64706. * * 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
  64707. * * 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
  64708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64709. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64711. * @param name defines the name of the mesh
  64712. * @param options defines the options used to create the mesh
  64713. * @param scene defines the hosting scene
  64714. * @returns the polyhedron mesh
  64715. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64716. */
  64717. static CreatePolyhedron(name: string, options: {
  64718. type?: number;
  64719. size?: number;
  64720. sizeX?: number;
  64721. sizeY?: number;
  64722. sizeZ?: number;
  64723. custom?: any;
  64724. faceUV?: Vector4[];
  64725. faceColors?: Color4[];
  64726. flat?: boolean;
  64727. updatable?: boolean;
  64728. sideOrientation?: number;
  64729. frontUVs?: Vector4;
  64730. backUVs?: Vector4;
  64731. }, scene?: Nullable<Scene>): Mesh;
  64732. /**
  64733. * Creates a decal mesh.
  64734. * 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
  64735. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64736. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64737. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64738. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64739. * @param name defines the name of the mesh
  64740. * @param sourceMesh defines the mesh where the decal must be applied
  64741. * @param options defines the options used to create the mesh
  64742. * @param scene defines the hosting scene
  64743. * @returns the decal mesh
  64744. * @see https://doc.babylonjs.com/how_to/decals
  64745. */
  64746. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64747. position?: Vector3;
  64748. normal?: Vector3;
  64749. size?: Vector3;
  64750. angle?: number;
  64751. }): Mesh;
  64752. }
  64753. }
  64754. declare module "babylonjs/Meshes/meshSimplification" {
  64755. import { Mesh } from "babylonjs/Meshes/mesh";
  64756. /**
  64757. * A simplifier interface for future simplification implementations
  64758. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64759. */
  64760. export interface ISimplifier {
  64761. /**
  64762. * Simplification of a given mesh according to the given settings.
  64763. * Since this requires computation, it is assumed that the function runs async.
  64764. * @param settings The settings of the simplification, including quality and distance
  64765. * @param successCallback A callback that will be called after the mesh was simplified.
  64766. * @param errorCallback in case of an error, this callback will be called. optional.
  64767. */
  64768. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64769. }
  64770. /**
  64771. * Expected simplification settings.
  64772. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64773. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64774. */
  64775. export interface ISimplificationSettings {
  64776. /**
  64777. * Gets or sets the expected quality
  64778. */
  64779. quality: number;
  64780. /**
  64781. * Gets or sets the distance when this optimized version should be used
  64782. */
  64783. distance: number;
  64784. /**
  64785. * Gets an already optimized mesh
  64786. */
  64787. optimizeMesh?: boolean;
  64788. }
  64789. /**
  64790. * Class used to specify simplification options
  64791. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64792. */
  64793. export class SimplificationSettings implements ISimplificationSettings {
  64794. /** expected quality */
  64795. quality: number;
  64796. /** distance when this optimized version should be used */
  64797. distance: number;
  64798. /** already optimized mesh */
  64799. optimizeMesh?: boolean | undefined;
  64800. /**
  64801. * Creates a SimplificationSettings
  64802. * @param quality expected quality
  64803. * @param distance distance when this optimized version should be used
  64804. * @param optimizeMesh already optimized mesh
  64805. */
  64806. constructor(
  64807. /** expected quality */
  64808. quality: number,
  64809. /** distance when this optimized version should be used */
  64810. distance: number,
  64811. /** already optimized mesh */
  64812. optimizeMesh?: boolean | undefined);
  64813. }
  64814. /**
  64815. * Interface used to define a simplification task
  64816. */
  64817. export interface ISimplificationTask {
  64818. /**
  64819. * Array of settings
  64820. */
  64821. settings: Array<ISimplificationSettings>;
  64822. /**
  64823. * Simplification type
  64824. */
  64825. simplificationType: SimplificationType;
  64826. /**
  64827. * Mesh to simplify
  64828. */
  64829. mesh: Mesh;
  64830. /**
  64831. * Callback called on success
  64832. */
  64833. successCallback?: () => void;
  64834. /**
  64835. * Defines if parallel processing can be used
  64836. */
  64837. parallelProcessing: boolean;
  64838. }
  64839. /**
  64840. * Queue used to order the simplification tasks
  64841. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64842. */
  64843. export class SimplificationQueue {
  64844. private _simplificationArray;
  64845. /**
  64846. * Gets a boolean indicating that the process is still running
  64847. */
  64848. running: boolean;
  64849. /**
  64850. * Creates a new queue
  64851. */
  64852. constructor();
  64853. /**
  64854. * Adds a new simplification task
  64855. * @param task defines a task to add
  64856. */
  64857. addTask(task: ISimplificationTask): void;
  64858. /**
  64859. * Execute next task
  64860. */
  64861. executeNext(): void;
  64862. /**
  64863. * Execute a simplification task
  64864. * @param task defines the task to run
  64865. */
  64866. runSimplification(task: ISimplificationTask): void;
  64867. private getSimplifier;
  64868. }
  64869. /**
  64870. * The implemented types of simplification
  64871. * At the moment only Quadratic Error Decimation is implemented
  64872. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64873. */
  64874. export enum SimplificationType {
  64875. /** Quadratic error decimation */
  64876. QUADRATIC = 0
  64877. }
  64878. }
  64879. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64880. import { Scene } from "babylonjs/scene";
  64881. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64882. import { ISceneComponent } from "babylonjs/sceneComponent";
  64883. module "babylonjs/scene" {
  64884. interface Scene {
  64885. /** @hidden (Backing field) */
  64886. _simplificationQueue: SimplificationQueue;
  64887. /**
  64888. * Gets or sets the simplification queue attached to the scene
  64889. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64890. */
  64891. simplificationQueue: SimplificationQueue;
  64892. }
  64893. }
  64894. module "babylonjs/Meshes/mesh" {
  64895. interface Mesh {
  64896. /**
  64897. * Simplify the mesh according to the given array of settings.
  64898. * Function will return immediately and will simplify async
  64899. * @param settings a collection of simplification settings
  64900. * @param parallelProcessing should all levels calculate parallel or one after the other
  64901. * @param simplificationType the type of simplification to run
  64902. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64903. * @returns the current mesh
  64904. */
  64905. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64906. }
  64907. }
  64908. /**
  64909. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64910. * created in a scene
  64911. */
  64912. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64913. /**
  64914. * The component name helpfull to identify the component in the list of scene components.
  64915. */
  64916. readonly name: string;
  64917. /**
  64918. * The scene the component belongs to.
  64919. */
  64920. scene: Scene;
  64921. /**
  64922. * Creates a new instance of the component for the given scene
  64923. * @param scene Defines the scene to register the component in
  64924. */
  64925. constructor(scene: Scene);
  64926. /**
  64927. * Registers the component in a given scene
  64928. */
  64929. register(): void;
  64930. /**
  64931. * Rebuilds the elements related to this component in case of
  64932. * context lost for instance.
  64933. */
  64934. rebuild(): void;
  64935. /**
  64936. * Disposes the component and the associated ressources
  64937. */
  64938. dispose(): void;
  64939. private _beforeCameraUpdate;
  64940. }
  64941. }
  64942. declare module "babylonjs/Meshes/Builders/index" {
  64943. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64944. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64945. export * from "babylonjs/Meshes/Builders/discBuilder";
  64946. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64947. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64948. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64949. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64950. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64951. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64952. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64953. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64954. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64955. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64956. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64957. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64958. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64959. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64960. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64961. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64962. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64963. }
  64964. declare module "babylonjs/Meshes/index" {
  64965. export * from "babylonjs/Meshes/abstractMesh";
  64966. export * from "babylonjs/Meshes/buffer";
  64967. export * from "babylonjs/Meshes/Compression/index";
  64968. export * from "babylonjs/Meshes/csg";
  64969. export * from "babylonjs/Meshes/geometry";
  64970. export * from "babylonjs/Meshes/groundMesh";
  64971. export * from "babylonjs/Meshes/trailMesh";
  64972. export * from "babylonjs/Meshes/instancedMesh";
  64973. export * from "babylonjs/Meshes/linesMesh";
  64974. export * from "babylonjs/Meshes/mesh";
  64975. export * from "babylonjs/Meshes/mesh.vertexData";
  64976. export * from "babylonjs/Meshes/meshBuilder";
  64977. export * from "babylonjs/Meshes/meshSimplification";
  64978. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64979. export * from "babylonjs/Meshes/polygonMesh";
  64980. export * from "babylonjs/Meshes/subMesh";
  64981. export * from "babylonjs/Meshes/meshLODLevel";
  64982. export * from "babylonjs/Meshes/transformNode";
  64983. export * from "babylonjs/Meshes/Builders/index";
  64984. export * from "babylonjs/Meshes/dataBuffer";
  64985. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64986. }
  64987. declare module "babylonjs/Morph/index" {
  64988. export * from "babylonjs/Morph/morphTarget";
  64989. export * from "babylonjs/Morph/morphTargetManager";
  64990. }
  64991. declare module "babylonjs/Navigation/INavigationEngine" {
  64992. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64993. import { Vector3 } from "babylonjs/Maths/math";
  64994. import { Mesh } from "babylonjs/Meshes/mesh";
  64995. import { Scene } from "babylonjs/scene";
  64996. /**
  64997. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64998. */
  64999. export interface INavigationEnginePlugin {
  65000. /**
  65001. * plugin name
  65002. */
  65003. name: string;
  65004. /**
  65005. * Creates a navigation mesh
  65006. * @param meshes array of all the geometry used to compute the navigatio mesh
  65007. * @param parameters bunch of parameters used to filter geometry
  65008. */
  65009. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65010. /**
  65011. * Create a navigation mesh debug mesh
  65012. * @param scene is where the mesh will be added
  65013. * @returns debug display mesh
  65014. */
  65015. createDebugNavMesh(scene: Scene): Mesh;
  65016. /**
  65017. * Get a navigation mesh constrained position, closest to the parameter position
  65018. * @param position world position
  65019. * @returns the closest point to position constrained by the navigation mesh
  65020. */
  65021. getClosestPoint(position: Vector3): Vector3;
  65022. /**
  65023. * Get a navigation mesh constrained position, within a particular radius
  65024. * @param position world position
  65025. * @param maxRadius the maximum distance to the constrained world position
  65026. * @returns the closest point to position constrained by the navigation mesh
  65027. */
  65028. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65029. /**
  65030. * Compute the final position from a segment made of destination-position
  65031. * @param position world position
  65032. * @param destination world position
  65033. * @returns the resulting point along the navmesh
  65034. */
  65035. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65036. /**
  65037. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65038. * @param start world position
  65039. * @param end world position
  65040. * @returns array containing world position composing the path
  65041. */
  65042. computePath(start: Vector3, end: Vector3): Vector3[];
  65043. /**
  65044. * If this plugin is supported
  65045. * @returns true if plugin is supported
  65046. */
  65047. isSupported(): boolean;
  65048. /**
  65049. * Create a new Crowd so you can add agents
  65050. * @param maxAgents the maximum agent count in the crowd
  65051. * @param maxAgentRadius the maximum radius an agent can have
  65052. * @param scene to attach the crowd to
  65053. * @returns the crowd you can add agents to
  65054. */
  65055. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65056. /**
  65057. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65058. * The queries will try to find a solution within those bounds
  65059. * default is (1,1,1)
  65060. * @param extent x,y,z value that define the extent around the queries point of reference
  65061. */
  65062. setDefaultQueryExtent(extent: Vector3): void;
  65063. /**
  65064. * Get the Bounding box extent specified by setDefaultQueryExtent
  65065. * @returns the box extent values
  65066. */
  65067. getDefaultQueryExtent(): Vector3;
  65068. /**
  65069. * Release all resources
  65070. */
  65071. dispose(): void;
  65072. }
  65073. /**
  65074. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65075. */
  65076. export interface ICrowd {
  65077. /**
  65078. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65079. * You can attach anything to that node. The node position is updated in the scene update tick.
  65080. * @param pos world position that will be constrained by the navigation mesh
  65081. * @param parameters agent parameters
  65082. * @param transform hooked to the agent that will be update by the scene
  65083. * @returns agent index
  65084. */
  65085. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65086. /**
  65087. * Returns the agent position in world space
  65088. * @param index agent index returned by addAgent
  65089. * @returns world space position
  65090. */
  65091. getAgentPosition(index: number): Vector3;
  65092. /**
  65093. * Gets the agent velocity in world space
  65094. * @param index agent index returned by addAgent
  65095. * @returns world space velocity
  65096. */
  65097. getAgentVelocity(index: number): Vector3;
  65098. /**
  65099. * remove a particular agent previously created
  65100. * @param index agent index returned by addAgent
  65101. */
  65102. removeAgent(index: number): void;
  65103. /**
  65104. * get the list of all agents attached to this crowd
  65105. * @returns list of agent indices
  65106. */
  65107. getAgents(): number[];
  65108. /**
  65109. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65110. * @param deltaTime in seconds
  65111. */
  65112. update(deltaTime: number): void;
  65113. /**
  65114. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65115. * @param index agent index returned by addAgent
  65116. * @param destination targeted world position
  65117. */
  65118. agentGoto(index: number, destination: Vector3): void;
  65119. /**
  65120. * Teleport the agent to a new position
  65121. * @param index agent index returned by addAgent
  65122. * @param destination targeted world position
  65123. */
  65124. agentTeleport(index: number, destination: Vector3): void;
  65125. /**
  65126. * Update agent parameters
  65127. * @param index agent index returned by addAgent
  65128. * @param parameters agent parameters
  65129. */
  65130. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65131. /**
  65132. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65133. * The queries will try to find a solution within those bounds
  65134. * default is (1,1,1)
  65135. * @param extent x,y,z value that define the extent around the queries point of reference
  65136. */
  65137. setDefaultQueryExtent(extent: Vector3): void;
  65138. /**
  65139. * Get the Bounding box extent specified by setDefaultQueryExtent
  65140. * @returns the box extent values
  65141. */
  65142. getDefaultQueryExtent(): Vector3;
  65143. /**
  65144. * Release all resources
  65145. */
  65146. dispose(): void;
  65147. }
  65148. /**
  65149. * Configures an agent
  65150. */
  65151. export interface IAgentParameters {
  65152. /**
  65153. * Agent radius. [Limit: >= 0]
  65154. */
  65155. radius: number;
  65156. /**
  65157. * Agent height. [Limit: > 0]
  65158. */
  65159. height: number;
  65160. /**
  65161. * Maximum allowed acceleration. [Limit: >= 0]
  65162. */
  65163. maxAcceleration: number;
  65164. /**
  65165. * Maximum allowed speed. [Limit: >= 0]
  65166. */
  65167. maxSpeed: number;
  65168. /**
  65169. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65170. */
  65171. collisionQueryRange: number;
  65172. /**
  65173. * The path visibility optimization range. [Limit: > 0]
  65174. */
  65175. pathOptimizationRange: number;
  65176. /**
  65177. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65178. */
  65179. separationWeight: number;
  65180. }
  65181. /**
  65182. * Configures the navigation mesh creation
  65183. */
  65184. export interface INavMeshParameters {
  65185. /**
  65186. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65187. */
  65188. cs: number;
  65189. /**
  65190. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65191. */
  65192. ch: number;
  65193. /**
  65194. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65195. */
  65196. walkableSlopeAngle: number;
  65197. /**
  65198. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65199. * be considered walkable. [Limit: >= 3] [Units: vx]
  65200. */
  65201. walkableHeight: number;
  65202. /**
  65203. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65204. */
  65205. walkableClimb: number;
  65206. /**
  65207. * The distance to erode/shrink the walkable area of the heightfield away from
  65208. * obstructions. [Limit: >=0] [Units: vx]
  65209. */
  65210. walkableRadius: number;
  65211. /**
  65212. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65213. */
  65214. maxEdgeLen: number;
  65215. /**
  65216. * The maximum distance a simplfied contour's border edges should deviate
  65217. * the original raw contour. [Limit: >=0] [Units: vx]
  65218. */
  65219. maxSimplificationError: number;
  65220. /**
  65221. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65222. */
  65223. minRegionArea: number;
  65224. /**
  65225. * Any regions with a span count smaller than this value will, if possible,
  65226. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65227. */
  65228. mergeRegionArea: number;
  65229. /**
  65230. * The maximum number of vertices allowed for polygons generated during the
  65231. * contour to polygon conversion process. [Limit: >= 3]
  65232. */
  65233. maxVertsPerPoly: number;
  65234. /**
  65235. * Sets the sampling distance to use when generating the detail mesh.
  65236. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65237. */
  65238. detailSampleDist: number;
  65239. /**
  65240. * The maximum distance the detail mesh surface should deviate from heightfield
  65241. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65242. */
  65243. detailSampleMaxError: number;
  65244. }
  65245. }
  65246. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65247. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65248. import { Mesh } from "babylonjs/Meshes/mesh";
  65249. import { Scene } from "babylonjs/scene";
  65250. import { Vector3 } from "babylonjs/Maths/math";
  65251. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65252. /**
  65253. * RecastJS navigation plugin
  65254. */
  65255. export class RecastJSPlugin implements INavigationEnginePlugin {
  65256. /**
  65257. * Reference to the Recast library
  65258. */
  65259. bjsRECAST: any;
  65260. /**
  65261. * plugin name
  65262. */
  65263. name: string;
  65264. /**
  65265. * the first navmesh created. We might extend this to support multiple navmeshes
  65266. */
  65267. navMesh: any;
  65268. /**
  65269. * Initializes the recastJS plugin
  65270. * @param recastInjection can be used to inject your own recast reference
  65271. */
  65272. constructor(recastInjection?: any);
  65273. /**
  65274. * Creates a navigation mesh
  65275. * @param meshes array of all the geometry used to compute the navigatio mesh
  65276. * @param parameters bunch of parameters used to filter geometry
  65277. */
  65278. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65279. /**
  65280. * Create a navigation mesh debug mesh
  65281. * @param scene is where the mesh will be added
  65282. * @returns debug display mesh
  65283. */
  65284. createDebugNavMesh(scene: Scene): Mesh;
  65285. /**
  65286. * Get a navigation mesh constrained position, closest to the parameter position
  65287. * @param position world position
  65288. * @returns the closest point to position constrained by the navigation mesh
  65289. */
  65290. getClosestPoint(position: Vector3): Vector3;
  65291. /**
  65292. * Get a navigation mesh constrained position, within a particular radius
  65293. * @param position world position
  65294. * @param maxRadius the maximum distance to the constrained world position
  65295. * @returns the closest point to position constrained by the navigation mesh
  65296. */
  65297. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65298. /**
  65299. * Compute the final position from a segment made of destination-position
  65300. * @param position world position
  65301. * @param destination world position
  65302. * @returns the resulting point along the navmesh
  65303. */
  65304. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65305. /**
  65306. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65307. * @param start world position
  65308. * @param end world position
  65309. * @returns array containing world position composing the path
  65310. */
  65311. computePath(start: Vector3, end: Vector3): Vector3[];
  65312. /**
  65313. * Create a new Crowd so you can add agents
  65314. * @param maxAgents the maximum agent count in the crowd
  65315. * @param maxAgentRadius the maximum radius an agent can have
  65316. * @param scene to attach the crowd to
  65317. * @returns the crowd you can add agents to
  65318. */
  65319. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65320. /**
  65321. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65322. * The queries will try to find a solution within those bounds
  65323. * default is (1,1,1)
  65324. * @param extent x,y,z value that define the extent around the queries point of reference
  65325. */
  65326. setDefaultQueryExtent(extent: Vector3): void;
  65327. /**
  65328. * Get the Bounding box extent specified by setDefaultQueryExtent
  65329. * @returns the box extent values
  65330. */
  65331. getDefaultQueryExtent(): Vector3;
  65332. /**
  65333. * Disposes
  65334. */
  65335. dispose(): void;
  65336. /**
  65337. * If this plugin is supported
  65338. * @returns true if plugin is supported
  65339. */
  65340. isSupported(): boolean;
  65341. }
  65342. /**
  65343. * Recast detour crowd implementation
  65344. */
  65345. export class RecastJSCrowd implements ICrowd {
  65346. /**
  65347. * Recast/detour plugin
  65348. */
  65349. bjsRECASTPlugin: RecastJSPlugin;
  65350. /**
  65351. * Link to the detour crowd
  65352. */
  65353. recastCrowd: any;
  65354. /**
  65355. * One transform per agent
  65356. */
  65357. transforms: TransformNode[];
  65358. /**
  65359. * All agents created
  65360. */
  65361. agents: number[];
  65362. /**
  65363. * Link to the scene is kept to unregister the crowd from the scene
  65364. */
  65365. private _scene;
  65366. /**
  65367. * Observer for crowd updates
  65368. */
  65369. private _onBeforeAnimationsObserver;
  65370. /**
  65371. * Constructor
  65372. * @param plugin recastJS plugin
  65373. * @param maxAgents the maximum agent count in the crowd
  65374. * @param maxAgentRadius the maximum radius an agent can have
  65375. * @param scene to attach the crowd to
  65376. * @returns the crowd you can add agents to
  65377. */
  65378. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65379. /**
  65380. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65381. * You can attach anything to that node. The node position is updated in the scene update tick.
  65382. * @param pos world position that will be constrained by the navigation mesh
  65383. * @param parameters agent parameters
  65384. * @param transform hooked to the agent that will be update by the scene
  65385. * @returns agent index
  65386. */
  65387. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65388. /**
  65389. * Returns the agent position in world space
  65390. * @param index agent index returned by addAgent
  65391. * @returns world space position
  65392. */
  65393. getAgentPosition(index: number): Vector3;
  65394. /**
  65395. * Returns the agent velocity in world space
  65396. * @param index agent index returned by addAgent
  65397. * @returns world space velocity
  65398. */
  65399. getAgentVelocity(index: number): Vector3;
  65400. /**
  65401. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65402. * @param index agent index returned by addAgent
  65403. * @param destination targeted world position
  65404. */
  65405. agentGoto(index: number, destination: Vector3): void;
  65406. /**
  65407. * Teleport the agent to a new position
  65408. * @param index agent index returned by addAgent
  65409. * @param destination targeted world position
  65410. */
  65411. agentTeleport(index: number, destination: Vector3): void;
  65412. /**
  65413. * Update agent parameters
  65414. * @param index agent index returned by addAgent
  65415. * @param parameters agent parameters
  65416. */
  65417. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65418. /**
  65419. * remove a particular agent previously created
  65420. * @param index agent index returned by addAgent
  65421. */
  65422. removeAgent(index: number): void;
  65423. /**
  65424. * get the list of all agents attached to this crowd
  65425. * @returns list of agent indices
  65426. */
  65427. getAgents(): number[];
  65428. /**
  65429. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65430. * @param deltaTime in seconds
  65431. */
  65432. update(deltaTime: number): void;
  65433. /**
  65434. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65435. * The queries will try to find a solution within those bounds
  65436. * default is (1,1,1)
  65437. * @param extent x,y,z value that define the extent around the queries point of reference
  65438. */
  65439. setDefaultQueryExtent(extent: Vector3): void;
  65440. /**
  65441. * Get the Bounding box extent specified by setDefaultQueryExtent
  65442. * @returns the box extent values
  65443. */
  65444. getDefaultQueryExtent(): Vector3;
  65445. /**
  65446. * Release all resources
  65447. */
  65448. dispose(): void;
  65449. }
  65450. }
  65451. declare module "babylonjs/Navigation/Plugins/index" {
  65452. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65453. }
  65454. declare module "babylonjs/Navigation/index" {
  65455. export * from "babylonjs/Navigation/INavigationEngine";
  65456. export * from "babylonjs/Navigation/Plugins/index";
  65457. }
  65458. declare module "babylonjs/Offline/database" {
  65459. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65460. /**
  65461. * Class used to enable access to IndexedDB
  65462. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65463. */
  65464. export class Database implements IOfflineProvider {
  65465. private _callbackManifestChecked;
  65466. private _currentSceneUrl;
  65467. private _db;
  65468. private _enableSceneOffline;
  65469. private _enableTexturesOffline;
  65470. private _manifestVersionFound;
  65471. private _mustUpdateRessources;
  65472. private _hasReachedQuota;
  65473. private _isSupported;
  65474. private _idbFactory;
  65475. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65476. private static IsUASupportingBlobStorage;
  65477. /**
  65478. * Gets a boolean indicating if Database storate is enabled (off by default)
  65479. */
  65480. static IDBStorageEnabled: boolean;
  65481. /**
  65482. * Gets a boolean indicating if scene must be saved in the database
  65483. */
  65484. get enableSceneOffline(): boolean;
  65485. /**
  65486. * Gets a boolean indicating if textures must be saved in the database
  65487. */
  65488. get enableTexturesOffline(): boolean;
  65489. /**
  65490. * Creates a new Database
  65491. * @param urlToScene defines the url to load the scene
  65492. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65493. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65494. */
  65495. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65496. private static _ParseURL;
  65497. private static _ReturnFullUrlLocation;
  65498. private _checkManifestFile;
  65499. /**
  65500. * Open the database and make it available
  65501. * @param successCallback defines the callback to call on success
  65502. * @param errorCallback defines the callback to call on error
  65503. */
  65504. open(successCallback: () => void, errorCallback: () => void): void;
  65505. /**
  65506. * Loads an image from the database
  65507. * @param url defines the url to load from
  65508. * @param image defines the target DOM image
  65509. */
  65510. loadImage(url: string, image: HTMLImageElement): void;
  65511. private _loadImageFromDBAsync;
  65512. private _saveImageIntoDBAsync;
  65513. private _checkVersionFromDB;
  65514. private _loadVersionFromDBAsync;
  65515. private _saveVersionIntoDBAsync;
  65516. /**
  65517. * Loads a file from database
  65518. * @param url defines the URL to load from
  65519. * @param sceneLoaded defines a callback to call on success
  65520. * @param progressCallBack defines a callback to call when progress changed
  65521. * @param errorCallback defines a callback to call on error
  65522. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65523. */
  65524. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65525. private _loadFileAsync;
  65526. private _saveFileAsync;
  65527. /**
  65528. * Validates if xhr data is correct
  65529. * @param xhr defines the request to validate
  65530. * @param dataType defines the expected data type
  65531. * @returns true if data is correct
  65532. */
  65533. private static _ValidateXHRData;
  65534. }
  65535. }
  65536. declare module "babylonjs/Offline/index" {
  65537. export * from "babylonjs/Offline/database";
  65538. export * from "babylonjs/Offline/IOfflineProvider";
  65539. }
  65540. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65541. /** @hidden */
  65542. export var gpuUpdateParticlesPixelShader: {
  65543. name: string;
  65544. shader: string;
  65545. };
  65546. }
  65547. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65548. /** @hidden */
  65549. export var gpuUpdateParticlesVertexShader: {
  65550. name: string;
  65551. shader: string;
  65552. };
  65553. }
  65554. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65555. /** @hidden */
  65556. export var clipPlaneFragmentDeclaration2: {
  65557. name: string;
  65558. shader: string;
  65559. };
  65560. }
  65561. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65562. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65563. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65564. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65565. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65566. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65567. /** @hidden */
  65568. export var gpuRenderParticlesPixelShader: {
  65569. name: string;
  65570. shader: string;
  65571. };
  65572. }
  65573. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65574. /** @hidden */
  65575. export var clipPlaneVertexDeclaration2: {
  65576. name: string;
  65577. shader: string;
  65578. };
  65579. }
  65580. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65581. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65582. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65583. /** @hidden */
  65584. export var gpuRenderParticlesVertexShader: {
  65585. name: string;
  65586. shader: string;
  65587. };
  65588. }
  65589. declare module "babylonjs/Particles/gpuParticleSystem" {
  65590. import { Nullable } from "babylonjs/types";
  65591. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65592. import { Observable } from "babylonjs/Misc/observable";
  65593. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65594. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65595. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65596. import { Scene, IDisposable } from "babylonjs/scene";
  65597. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65598. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65599. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65600. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65601. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65602. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65603. /**
  65604. * This represents a GPU particle system in Babylon
  65605. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65606. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65607. */
  65608. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65609. /**
  65610. * The layer mask we are rendering the particles through.
  65611. */
  65612. layerMask: number;
  65613. private _capacity;
  65614. private _activeCount;
  65615. private _currentActiveCount;
  65616. private _accumulatedCount;
  65617. private _renderEffect;
  65618. private _updateEffect;
  65619. private _buffer0;
  65620. private _buffer1;
  65621. private _spriteBuffer;
  65622. private _updateVAO;
  65623. private _renderVAO;
  65624. private _targetIndex;
  65625. private _sourceBuffer;
  65626. private _targetBuffer;
  65627. private _engine;
  65628. private _currentRenderId;
  65629. private _started;
  65630. private _stopped;
  65631. private _timeDelta;
  65632. private _randomTexture;
  65633. private _randomTexture2;
  65634. private _attributesStrideSize;
  65635. private _updateEffectOptions;
  65636. private _randomTextureSize;
  65637. private _actualFrame;
  65638. private readonly _rawTextureWidth;
  65639. /**
  65640. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65641. */
  65642. static get IsSupported(): boolean;
  65643. /**
  65644. * An event triggered when the system is disposed.
  65645. */
  65646. onDisposeObservable: Observable<GPUParticleSystem>;
  65647. /**
  65648. * Gets the maximum number of particles active at the same time.
  65649. * @returns The max number of active particles.
  65650. */
  65651. getCapacity(): number;
  65652. /**
  65653. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65654. * to override the particles.
  65655. */
  65656. forceDepthWrite: boolean;
  65657. /**
  65658. * Gets or set the number of active particles
  65659. */
  65660. get activeParticleCount(): number;
  65661. set activeParticleCount(value: number);
  65662. private _preWarmDone;
  65663. /**
  65664. * Specifies if the particles are updated in emitter local space or world space.
  65665. * This is always false for GPU particles
  65666. */
  65667. get isLocal(): boolean;
  65668. set isLocal(value: boolean);
  65669. /**
  65670. * Is this system ready to be used/rendered
  65671. * @return true if the system is ready
  65672. */
  65673. isReady(): boolean;
  65674. /**
  65675. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65676. * @returns True if it has been started, otherwise false.
  65677. */
  65678. isStarted(): boolean;
  65679. /**
  65680. * Starts the particle system and begins to emit
  65681. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65682. */
  65683. start(delay?: number): void;
  65684. /**
  65685. * Stops the particle system.
  65686. */
  65687. stop(): void;
  65688. /**
  65689. * Remove all active particles
  65690. */
  65691. reset(): void;
  65692. /**
  65693. * Returns the string "GPUParticleSystem"
  65694. * @returns a string containing the class name
  65695. */
  65696. getClassName(): string;
  65697. private _colorGradientsTexture;
  65698. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65699. /**
  65700. * Adds a new color gradient
  65701. * @param gradient defines the gradient to use (between 0 and 1)
  65702. * @param color1 defines the color to affect to the specified gradient
  65703. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65704. * @returns the current particle system
  65705. */
  65706. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65707. /**
  65708. * Remove a specific color gradient
  65709. * @param gradient defines the gradient to remove
  65710. * @returns the current particle system
  65711. */
  65712. removeColorGradient(gradient: number): GPUParticleSystem;
  65713. private _angularSpeedGradientsTexture;
  65714. private _sizeGradientsTexture;
  65715. private _velocityGradientsTexture;
  65716. private _limitVelocityGradientsTexture;
  65717. private _dragGradientsTexture;
  65718. private _addFactorGradient;
  65719. /**
  65720. * Adds a new size gradient
  65721. * @param gradient defines the gradient to use (between 0 and 1)
  65722. * @param factor defines the size factor to affect to the specified gradient
  65723. * @returns the current particle system
  65724. */
  65725. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65726. /**
  65727. * Remove a specific size gradient
  65728. * @param gradient defines the gradient to remove
  65729. * @returns the current particle system
  65730. */
  65731. removeSizeGradient(gradient: number): GPUParticleSystem;
  65732. /**
  65733. * Adds a new angular speed gradient
  65734. * @param gradient defines the gradient to use (between 0 and 1)
  65735. * @param factor defines the angular speed to affect to the specified gradient
  65736. * @returns the current particle system
  65737. */
  65738. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65739. /**
  65740. * Remove a specific angular speed gradient
  65741. * @param gradient defines the gradient to remove
  65742. * @returns the current particle system
  65743. */
  65744. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65745. /**
  65746. * Adds a new velocity gradient
  65747. * @param gradient defines the gradient to use (between 0 and 1)
  65748. * @param factor defines the velocity to affect to the specified gradient
  65749. * @returns the current particle system
  65750. */
  65751. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65752. /**
  65753. * Remove a specific velocity gradient
  65754. * @param gradient defines the gradient to remove
  65755. * @returns the current particle system
  65756. */
  65757. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65758. /**
  65759. * Adds a new limit velocity gradient
  65760. * @param gradient defines the gradient to use (between 0 and 1)
  65761. * @param factor defines the limit velocity value to affect to the specified gradient
  65762. * @returns the current particle system
  65763. */
  65764. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65765. /**
  65766. * Remove a specific limit velocity gradient
  65767. * @param gradient defines the gradient to remove
  65768. * @returns the current particle system
  65769. */
  65770. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65771. /**
  65772. * Adds a new drag gradient
  65773. * @param gradient defines the gradient to use (between 0 and 1)
  65774. * @param factor defines the drag value to affect to the specified gradient
  65775. * @returns the current particle system
  65776. */
  65777. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65778. /**
  65779. * Remove a specific drag gradient
  65780. * @param gradient defines the gradient to remove
  65781. * @returns the current particle system
  65782. */
  65783. removeDragGradient(gradient: number): GPUParticleSystem;
  65784. /**
  65785. * Not supported by GPUParticleSystem
  65786. * @param gradient defines the gradient to use (between 0 and 1)
  65787. * @param factor defines the emit rate value to affect to the specified gradient
  65788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65789. * @returns the current particle system
  65790. */
  65791. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65792. /**
  65793. * Not supported by GPUParticleSystem
  65794. * @param gradient defines the gradient to remove
  65795. * @returns the current particle system
  65796. */
  65797. removeEmitRateGradient(gradient: number): IParticleSystem;
  65798. /**
  65799. * Not supported by GPUParticleSystem
  65800. * @param gradient defines the gradient to use (between 0 and 1)
  65801. * @param factor defines the start size value to affect to the specified gradient
  65802. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65803. * @returns the current particle system
  65804. */
  65805. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65806. /**
  65807. * Not supported by GPUParticleSystem
  65808. * @param gradient defines the gradient to remove
  65809. * @returns the current particle system
  65810. */
  65811. removeStartSizeGradient(gradient: number): IParticleSystem;
  65812. /**
  65813. * Not supported by GPUParticleSystem
  65814. * @param gradient defines the gradient to use (between 0 and 1)
  65815. * @param min defines the color remap minimal range
  65816. * @param max defines the color remap maximal range
  65817. * @returns the current particle system
  65818. */
  65819. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65820. /**
  65821. * Not supported by GPUParticleSystem
  65822. * @param gradient defines the gradient to remove
  65823. * @returns the current particle system
  65824. */
  65825. removeColorRemapGradient(): IParticleSystem;
  65826. /**
  65827. * Not supported by GPUParticleSystem
  65828. * @param gradient defines the gradient to use (between 0 and 1)
  65829. * @param min defines the alpha remap minimal range
  65830. * @param max defines the alpha remap maximal range
  65831. * @returns the current particle system
  65832. */
  65833. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65834. /**
  65835. * Not supported by GPUParticleSystem
  65836. * @param gradient defines the gradient to remove
  65837. * @returns the current particle system
  65838. */
  65839. removeAlphaRemapGradient(): IParticleSystem;
  65840. /**
  65841. * Not supported by GPUParticleSystem
  65842. * @param gradient defines the gradient to use (between 0 and 1)
  65843. * @param color defines the color to affect to the specified gradient
  65844. * @returns the current particle system
  65845. */
  65846. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65847. /**
  65848. * Not supported by GPUParticleSystem
  65849. * @param gradient defines the gradient to remove
  65850. * @returns the current particle system
  65851. */
  65852. removeRampGradient(): IParticleSystem;
  65853. /**
  65854. * Not supported by GPUParticleSystem
  65855. * @returns the list of ramp gradients
  65856. */
  65857. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65858. /**
  65859. * Not supported by GPUParticleSystem
  65860. * Gets or sets a boolean indicating that ramp gradients must be used
  65861. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65862. */
  65863. get useRampGradients(): boolean;
  65864. set useRampGradients(value: boolean);
  65865. /**
  65866. * Not supported by GPUParticleSystem
  65867. * @param gradient defines the gradient to use (between 0 and 1)
  65868. * @param factor defines the life time factor to affect to the specified gradient
  65869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65870. * @returns the current particle system
  65871. */
  65872. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65873. /**
  65874. * Not supported by GPUParticleSystem
  65875. * @param gradient defines the gradient to remove
  65876. * @returns the current particle system
  65877. */
  65878. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65879. /**
  65880. * Instantiates a GPU particle system.
  65881. * 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.
  65882. * @param name The name of the particle system
  65883. * @param options The options used to create the system
  65884. * @param scene The scene the particle system belongs to
  65885. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65886. */
  65887. constructor(name: string, options: Partial<{
  65888. capacity: number;
  65889. randomTextureSize: number;
  65890. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65891. protected _reset(): void;
  65892. private _createUpdateVAO;
  65893. private _createRenderVAO;
  65894. private _initialize;
  65895. /** @hidden */
  65896. _recreateUpdateEffect(): void;
  65897. /** @hidden */
  65898. _recreateRenderEffect(): void;
  65899. /**
  65900. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65901. * @param preWarm defines if we are in the pre-warmimg phase
  65902. */
  65903. animate(preWarm?: boolean): void;
  65904. private _createFactorGradientTexture;
  65905. private _createSizeGradientTexture;
  65906. private _createAngularSpeedGradientTexture;
  65907. private _createVelocityGradientTexture;
  65908. private _createLimitVelocityGradientTexture;
  65909. private _createDragGradientTexture;
  65910. private _createColorGradientTexture;
  65911. /**
  65912. * Renders the particle system in its current state
  65913. * @param preWarm defines if the system should only update the particles but not render them
  65914. * @returns the current number of particles
  65915. */
  65916. render(preWarm?: boolean): number;
  65917. /**
  65918. * Rebuilds the particle system
  65919. */
  65920. rebuild(): void;
  65921. private _releaseBuffers;
  65922. private _releaseVAOs;
  65923. /**
  65924. * Disposes the particle system and free the associated resources
  65925. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65926. */
  65927. dispose(disposeTexture?: boolean): void;
  65928. /**
  65929. * Clones the particle system.
  65930. * @param name The name of the cloned object
  65931. * @param newEmitter The new emitter to use
  65932. * @returns the cloned particle system
  65933. */
  65934. clone(name: string, newEmitter: any): GPUParticleSystem;
  65935. /**
  65936. * Serializes the particle system to a JSON object.
  65937. * @returns the JSON object
  65938. */
  65939. serialize(): any;
  65940. /**
  65941. * Parses a JSON object to create a GPU particle system.
  65942. * @param parsedParticleSystem The JSON object to parse
  65943. * @param scene The scene to create the particle system in
  65944. * @param rootUrl The root url to use to load external dependencies like texture
  65945. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65946. * @returns the parsed GPU particle system
  65947. */
  65948. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65949. }
  65950. }
  65951. declare module "babylonjs/Particles/particleSystemSet" {
  65952. import { Nullable } from "babylonjs/types";
  65953. import { Color3 } from "babylonjs/Maths/math.color";
  65954. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65956. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65957. import { Scene, IDisposable } from "babylonjs/scene";
  65958. /**
  65959. * Represents a set of particle systems working together to create a specific effect
  65960. */
  65961. export class ParticleSystemSet implements IDisposable {
  65962. /**
  65963. * Gets or sets base Assets URL
  65964. */
  65965. static BaseAssetsUrl: string;
  65966. private _emitterCreationOptions;
  65967. private _emitterNode;
  65968. /**
  65969. * Gets the particle system list
  65970. */
  65971. systems: IParticleSystem[];
  65972. /**
  65973. * Gets the emitter node used with this set
  65974. */
  65975. get emitterNode(): Nullable<TransformNode>;
  65976. /**
  65977. * Creates a new emitter mesh as a sphere
  65978. * @param options defines the options used to create the sphere
  65979. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65980. * @param scene defines the hosting scene
  65981. */
  65982. setEmitterAsSphere(options: {
  65983. diameter: number;
  65984. segments: number;
  65985. color: Color3;
  65986. }, renderingGroupId: number, scene: Scene): void;
  65987. /**
  65988. * Starts all particle systems of the set
  65989. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65990. */
  65991. start(emitter?: AbstractMesh): void;
  65992. /**
  65993. * Release all associated resources
  65994. */
  65995. dispose(): void;
  65996. /**
  65997. * Serialize the set into a JSON compatible object
  65998. * @returns a JSON compatible representation of the set
  65999. */
  66000. serialize(): any;
  66001. /**
  66002. * Parse a new ParticleSystemSet from a serialized source
  66003. * @param data defines a JSON compatible representation of the set
  66004. * @param scene defines the hosting scene
  66005. * @param gpu defines if we want GPU particles or CPU particles
  66006. * @returns a new ParticleSystemSet
  66007. */
  66008. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66009. }
  66010. }
  66011. declare module "babylonjs/Particles/particleHelper" {
  66012. import { Nullable } from "babylonjs/types";
  66013. import { Scene } from "babylonjs/scene";
  66014. import { Vector3 } from "babylonjs/Maths/math.vector";
  66015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66016. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66017. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66018. /**
  66019. * This class is made for on one-liner static method to help creating particle system set.
  66020. */
  66021. export class ParticleHelper {
  66022. /**
  66023. * Gets or sets base Assets URL
  66024. */
  66025. static BaseAssetsUrl: string;
  66026. /**
  66027. * Create a default particle system that you can tweak
  66028. * @param emitter defines the emitter to use
  66029. * @param capacity defines the system capacity (default is 500 particles)
  66030. * @param scene defines the hosting scene
  66031. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66032. * @returns the new Particle system
  66033. */
  66034. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66035. /**
  66036. * This is the main static method (one-liner) of this helper to create different particle systems
  66037. * @param type This string represents the type to the particle system to create
  66038. * @param scene The scene where the particle system should live
  66039. * @param gpu If the system will use gpu
  66040. * @returns the ParticleSystemSet created
  66041. */
  66042. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66043. /**
  66044. * Static function used to export a particle system to a ParticleSystemSet variable.
  66045. * Please note that the emitter shape is not exported
  66046. * @param systems defines the particle systems to export
  66047. * @returns the created particle system set
  66048. */
  66049. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66050. }
  66051. }
  66052. declare module "babylonjs/Particles/particleSystemComponent" {
  66053. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66054. import { Effect } from "babylonjs/Materials/effect";
  66055. import "babylonjs/Shaders/particles.vertex";
  66056. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66057. module "babylonjs/Engines/engine" {
  66058. interface Engine {
  66059. /**
  66060. * Create an effect to use with particle systems.
  66061. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66062. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66063. * @param uniformsNames defines a list of attribute names
  66064. * @param samplers defines an array of string used to represent textures
  66065. * @param defines defines the string containing the defines to use to compile the shaders
  66066. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66067. * @param onCompiled defines a function to call when the effect creation is successful
  66068. * @param onError defines a function to call when the effect creation has failed
  66069. * @returns the new Effect
  66070. */
  66071. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66072. }
  66073. }
  66074. module "babylonjs/Meshes/mesh" {
  66075. interface Mesh {
  66076. /**
  66077. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66078. * @returns an array of IParticleSystem
  66079. */
  66080. getEmittedParticleSystems(): IParticleSystem[];
  66081. /**
  66082. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66083. * @returns an array of IParticleSystem
  66084. */
  66085. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66086. }
  66087. }
  66088. /**
  66089. * @hidden
  66090. */
  66091. export var _IDoNeedToBeInTheBuild: number;
  66092. }
  66093. declare module "babylonjs/Particles/pointsCloudSystem" {
  66094. import { Color4 } from "babylonjs/Maths/math";
  66095. import { Mesh } from "babylonjs/Meshes/mesh";
  66096. import { Scene, IDisposable } from "babylonjs/scene";
  66097. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66098. /** Defines the 4 color options */
  66099. export enum PointColor {
  66100. /** color value */
  66101. Color = 2,
  66102. /** uv value */
  66103. UV = 1,
  66104. /** random value */
  66105. Random = 0,
  66106. /** stated value */
  66107. Stated = 3
  66108. }
  66109. /**
  66110. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66111. * 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.
  66112. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66113. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66114. *
  66115. * Full documentation here : TO BE ENTERED
  66116. */
  66117. export class PointsCloudSystem implements IDisposable {
  66118. /**
  66119. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66120. * Example : var p = SPS.particles[i];
  66121. */
  66122. particles: CloudPoint[];
  66123. /**
  66124. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66125. */
  66126. nbParticles: number;
  66127. /**
  66128. * This a counter for your own usage. It's not set by any SPS functions.
  66129. */
  66130. counter: number;
  66131. /**
  66132. * The PCS name. This name is also given to the underlying mesh.
  66133. */
  66134. name: string;
  66135. /**
  66136. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66137. */
  66138. mesh: Mesh;
  66139. /**
  66140. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66141. * Please read :
  66142. */
  66143. vars: any;
  66144. /**
  66145. * @hidden
  66146. */
  66147. _size: number;
  66148. private _scene;
  66149. private _promises;
  66150. private _positions;
  66151. private _indices;
  66152. private _normals;
  66153. private _colors;
  66154. private _uvs;
  66155. private _indices32;
  66156. private _positions32;
  66157. private _colors32;
  66158. private _uvs32;
  66159. private _updatable;
  66160. private _isVisibilityBoxLocked;
  66161. private _alwaysVisible;
  66162. private _groups;
  66163. private _groupCounter;
  66164. private _computeParticleColor;
  66165. private _computeParticleTexture;
  66166. private _computeParticleRotation;
  66167. private _computeBoundingBox;
  66168. private _isReady;
  66169. /**
  66170. * Creates a PCS (Points Cloud System) object
  66171. * @param name (String) is the PCS name, this will be the underlying mesh name
  66172. * @param pointSize (number) is the size for each point
  66173. * @param scene (Scene) is the scene in which the PCS is added
  66174. * @param options defines the options of the PCS e.g.
  66175. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66176. */
  66177. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66178. updatable?: boolean;
  66179. });
  66180. /**
  66181. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66182. * If no points were added to the PCS, the returned mesh is just a single point.
  66183. * @returns a promise for the created mesh
  66184. */
  66185. buildMeshAsync(): Promise<Mesh>;
  66186. /**
  66187. * @hidden
  66188. */
  66189. private _buildMesh;
  66190. private _addParticle;
  66191. private _randomUnitVector;
  66192. private _getColorIndicesForCoord;
  66193. private _setPointsColorOrUV;
  66194. private _colorFromTexture;
  66195. private _calculateDensity;
  66196. /**
  66197. * Adds points to the PCS in random positions within a unit sphere
  66198. * @param nb (positive integer) the number of particles to be created from this model
  66199. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66200. * @returns the number of groups in the system
  66201. */
  66202. addPoints(nb: number, pointFunction?: any): number;
  66203. /**
  66204. * Adds points to the PCS from the surface of the model shape
  66205. * @param mesh is any Mesh object that will be used as a surface model for the points
  66206. * @param nb (positive integer) the number of particles to be created from this model
  66207. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66208. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66209. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66210. * @returns the number of groups in the system
  66211. */
  66212. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66213. /**
  66214. * Adds points to the PCS inside the model shape
  66215. * @param mesh is any Mesh object that will be used as a surface model for the points
  66216. * @param nb (positive integer) the number of particles to be created from this model
  66217. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66218. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66219. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66220. * @returns the number of groups in the system
  66221. */
  66222. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66223. /**
  66224. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66225. * This method calls `updateParticle()` for each particle of the SPS.
  66226. * For an animated SPS, it is usually called within the render loop.
  66227. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66228. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66229. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66230. * @returns the PCS.
  66231. */
  66232. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66233. /**
  66234. * Disposes the PCS.
  66235. */
  66236. dispose(): void;
  66237. /**
  66238. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66239. * doc :
  66240. * @returns the PCS.
  66241. */
  66242. refreshVisibleSize(): PointsCloudSystem;
  66243. /**
  66244. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66245. * @param size the size (float) of the visibility box
  66246. * note : this doesn't lock the PCS mesh bounding box.
  66247. * doc :
  66248. */
  66249. setVisibilityBox(size: number): void;
  66250. /**
  66251. * Gets whether the PCS is always visible or not
  66252. * doc :
  66253. */
  66254. get isAlwaysVisible(): boolean;
  66255. /**
  66256. * Sets the PCS as always visible or not
  66257. * doc :
  66258. */
  66259. set isAlwaysVisible(val: boolean);
  66260. /**
  66261. * Tells to `setParticles()` to compute the particle rotations or not
  66262. * Default value : false. The PCS is faster when it's set to false
  66263. * Note : particle rotations are only applied to parent particles
  66264. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66265. */
  66266. set computeParticleRotation(val: boolean);
  66267. /**
  66268. * Tells to `setParticles()` to compute the particle colors or not.
  66269. * Default value : true. The PCS is faster when it's set to false.
  66270. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66271. */
  66272. set computeParticleColor(val: boolean);
  66273. set computeParticleTexture(val: boolean);
  66274. /**
  66275. * Gets if `setParticles()` computes the particle colors or not.
  66276. * Default value : false. The PCS is faster when it's set to false.
  66277. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66278. */
  66279. get computeParticleColor(): boolean;
  66280. /**
  66281. * Gets if `setParticles()` computes the particle textures or not.
  66282. * Default value : false. The PCS is faster when it's set to false.
  66283. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66284. */
  66285. get computeParticleTexture(): boolean;
  66286. /**
  66287. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66288. */
  66289. set computeBoundingBox(val: boolean);
  66290. /**
  66291. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66292. */
  66293. get computeBoundingBox(): boolean;
  66294. /**
  66295. * This function does nothing. It may be overwritten to set all the particle first values.
  66296. * The PCS doesn't call this function, you may have to call it by your own.
  66297. * doc :
  66298. */
  66299. initParticles(): void;
  66300. /**
  66301. * This function does nothing. It may be overwritten to recycle a particle
  66302. * The PCS doesn't call this function, you can to call it
  66303. * doc :
  66304. * @param particle The particle to recycle
  66305. * @returns the recycled particle
  66306. */
  66307. recycleParticle(particle: CloudPoint): CloudPoint;
  66308. /**
  66309. * Updates a particle : this function should be overwritten by the user.
  66310. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66311. * doc :
  66312. * @example : just set a particle position or velocity and recycle conditions
  66313. * @param particle The particle to update
  66314. * @returns the updated particle
  66315. */
  66316. updateParticle(particle: CloudPoint): CloudPoint;
  66317. /**
  66318. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66319. * This does nothing and may be overwritten by the user.
  66320. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66321. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66322. * @param update the boolean update value actually passed to setParticles()
  66323. */
  66324. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66325. /**
  66326. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66327. * This will be passed three parameters.
  66328. * This does nothing and may be overwritten by the user.
  66329. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66330. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66331. * @param update the boolean update value actually passed to setParticles()
  66332. */
  66333. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66334. }
  66335. }
  66336. declare module "babylonjs/Particles/cloudPoint" {
  66337. import { Nullable } from "babylonjs/types";
  66338. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66339. import { Mesh } from "babylonjs/Meshes/mesh";
  66340. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66341. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66342. /**
  66343. * Represents one particle of a points cloud system.
  66344. */
  66345. export class CloudPoint {
  66346. /**
  66347. * particle global index
  66348. */
  66349. idx: number;
  66350. /**
  66351. * The color of the particle
  66352. */
  66353. color: Nullable<Color4>;
  66354. /**
  66355. * The world space position of the particle.
  66356. */
  66357. position: Vector3;
  66358. /**
  66359. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66360. */
  66361. rotation: Vector3;
  66362. /**
  66363. * The world space rotation quaternion of the particle.
  66364. */
  66365. rotationQuaternion: Nullable<Quaternion>;
  66366. /**
  66367. * The uv of the particle.
  66368. */
  66369. uv: Nullable<Vector2>;
  66370. /**
  66371. * The current speed of the particle.
  66372. */
  66373. velocity: Vector3;
  66374. /**
  66375. * The pivot point in the particle local space.
  66376. */
  66377. pivot: Vector3;
  66378. /**
  66379. * Must the particle be translated from its pivot point in its local space ?
  66380. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66381. * Default : false
  66382. */
  66383. translateFromPivot: boolean;
  66384. /**
  66385. * Index of this particle in the global "positions" array (Internal use)
  66386. * @hidden
  66387. */
  66388. _pos: number;
  66389. /**
  66390. * @hidden Index of this particle in the global "indices" array (Internal use)
  66391. */
  66392. _ind: number;
  66393. /**
  66394. * Group this particle belongs to
  66395. */
  66396. _group: PointsGroup;
  66397. /**
  66398. * Group id of this particle
  66399. */
  66400. groupId: number;
  66401. /**
  66402. * Index of the particle in its group id (Internal use)
  66403. */
  66404. idxInGroup: number;
  66405. /**
  66406. * @hidden Particle BoundingInfo object (Internal use)
  66407. */
  66408. _boundingInfo: BoundingInfo;
  66409. /**
  66410. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66411. */
  66412. _pcs: PointsCloudSystem;
  66413. /**
  66414. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66415. */
  66416. _stillInvisible: boolean;
  66417. /**
  66418. * @hidden Last computed particle rotation matrix
  66419. */
  66420. _rotationMatrix: number[];
  66421. /**
  66422. * Parent particle Id, if any.
  66423. * Default null.
  66424. */
  66425. parentId: Nullable<number>;
  66426. /**
  66427. * @hidden Internal global position in the PCS.
  66428. */
  66429. _globalPosition: Vector3;
  66430. /**
  66431. * Creates a Point Cloud object.
  66432. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66433. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66434. * @param group (PointsGroup) is the group the particle belongs to
  66435. * @param groupId (integer) is the group identifier in the PCS.
  66436. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66437. * @param pcs defines the PCS it is associated to
  66438. */
  66439. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66440. /**
  66441. * get point size
  66442. */
  66443. get size(): Vector3;
  66444. /**
  66445. * Set point size
  66446. */
  66447. set size(scale: Vector3);
  66448. /**
  66449. * Legacy support, changed quaternion to rotationQuaternion
  66450. */
  66451. get quaternion(): Nullable<Quaternion>;
  66452. /**
  66453. * Legacy support, changed quaternion to rotationQuaternion
  66454. */
  66455. set quaternion(q: Nullable<Quaternion>);
  66456. /**
  66457. * Returns a boolean. True if the particle intersects a mesh, else false
  66458. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66459. * @param target is the object (point or mesh) what the intersection is computed against
  66460. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66461. * @returns true if it intersects
  66462. */
  66463. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66464. /**
  66465. * get the rotation matrix of the particle
  66466. * @hidden
  66467. */
  66468. getRotationMatrix(m: Matrix): void;
  66469. }
  66470. /**
  66471. * Represents a group of points in a points cloud system
  66472. * * PCS internal tool, don't use it manually.
  66473. */
  66474. export class PointsGroup {
  66475. /**
  66476. * The group id
  66477. * @hidden
  66478. */
  66479. groupID: number;
  66480. /**
  66481. * image data for group (internal use)
  66482. * @hidden
  66483. */
  66484. _groupImageData: Nullable<ArrayBufferView>;
  66485. /**
  66486. * Image Width (internal use)
  66487. * @hidden
  66488. */
  66489. _groupImgWidth: number;
  66490. /**
  66491. * Image Height (internal use)
  66492. * @hidden
  66493. */
  66494. _groupImgHeight: number;
  66495. /**
  66496. * Custom position function (internal use)
  66497. * @hidden
  66498. */
  66499. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66500. /**
  66501. * density per facet for surface points
  66502. * @hidden
  66503. */
  66504. _groupDensity: number[];
  66505. /**
  66506. * Only when points are colored by texture carries pointer to texture list array
  66507. * @hidden
  66508. */
  66509. _textureNb: number;
  66510. /**
  66511. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66512. * PCS internal tool, don't use it manually.
  66513. * @hidden
  66514. */
  66515. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66516. }
  66517. }
  66518. declare module "babylonjs/Particles/index" {
  66519. export * from "babylonjs/Particles/baseParticleSystem";
  66520. export * from "babylonjs/Particles/EmitterTypes/index";
  66521. export * from "babylonjs/Particles/gpuParticleSystem";
  66522. export * from "babylonjs/Particles/IParticleSystem";
  66523. export * from "babylonjs/Particles/particle";
  66524. export * from "babylonjs/Particles/particleHelper";
  66525. export * from "babylonjs/Particles/particleSystem";
  66526. export * from "babylonjs/Particles/particleSystemComponent";
  66527. export * from "babylonjs/Particles/particleSystemSet";
  66528. export * from "babylonjs/Particles/solidParticle";
  66529. export * from "babylonjs/Particles/solidParticleSystem";
  66530. export * from "babylonjs/Particles/cloudPoint";
  66531. export * from "babylonjs/Particles/pointsCloudSystem";
  66532. export * from "babylonjs/Particles/subEmitter";
  66533. }
  66534. declare module "babylonjs/Physics/physicsEngineComponent" {
  66535. import { Nullable } from "babylonjs/types";
  66536. import { Observable, Observer } from "babylonjs/Misc/observable";
  66537. import { Vector3 } from "babylonjs/Maths/math.vector";
  66538. import { Mesh } from "babylonjs/Meshes/mesh";
  66539. import { ISceneComponent } from "babylonjs/sceneComponent";
  66540. import { Scene } from "babylonjs/scene";
  66541. import { Node } from "babylonjs/node";
  66542. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66543. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66544. module "babylonjs/scene" {
  66545. interface Scene {
  66546. /** @hidden (Backing field) */
  66547. _physicsEngine: Nullable<IPhysicsEngine>;
  66548. /** @hidden */
  66549. _physicsTimeAccumulator: number;
  66550. /**
  66551. * Gets the current physics engine
  66552. * @returns a IPhysicsEngine or null if none attached
  66553. */
  66554. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66555. /**
  66556. * Enables physics to the current scene
  66557. * @param gravity defines the scene's gravity for the physics engine
  66558. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66559. * @return a boolean indicating if the physics engine was initialized
  66560. */
  66561. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66562. /**
  66563. * Disables and disposes the physics engine associated with the scene
  66564. */
  66565. disablePhysicsEngine(): void;
  66566. /**
  66567. * Gets a boolean indicating if there is an active physics engine
  66568. * @returns a boolean indicating if there is an active physics engine
  66569. */
  66570. isPhysicsEnabled(): boolean;
  66571. /**
  66572. * Deletes a physics compound impostor
  66573. * @param compound defines the compound to delete
  66574. */
  66575. deleteCompoundImpostor(compound: any): void;
  66576. /**
  66577. * An event triggered when physic simulation is about to be run
  66578. */
  66579. onBeforePhysicsObservable: Observable<Scene>;
  66580. /**
  66581. * An event triggered when physic simulation has been done
  66582. */
  66583. onAfterPhysicsObservable: Observable<Scene>;
  66584. }
  66585. }
  66586. module "babylonjs/Meshes/abstractMesh" {
  66587. interface AbstractMesh {
  66588. /** @hidden */
  66589. _physicsImpostor: Nullable<PhysicsImpostor>;
  66590. /**
  66591. * Gets or sets impostor used for physic simulation
  66592. * @see http://doc.babylonjs.com/features/physics_engine
  66593. */
  66594. physicsImpostor: Nullable<PhysicsImpostor>;
  66595. /**
  66596. * Gets the current physics impostor
  66597. * @see http://doc.babylonjs.com/features/physics_engine
  66598. * @returns a physics impostor or null
  66599. */
  66600. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66601. /** Apply a physic impulse to the mesh
  66602. * @param force defines the force to apply
  66603. * @param contactPoint defines where to apply the force
  66604. * @returns the current mesh
  66605. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66606. */
  66607. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66608. /**
  66609. * Creates a physic joint between two meshes
  66610. * @param otherMesh defines the other mesh to use
  66611. * @param pivot1 defines the pivot to use on this mesh
  66612. * @param pivot2 defines the pivot to use on the other mesh
  66613. * @param options defines additional options (can be plugin dependent)
  66614. * @returns the current mesh
  66615. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66616. */
  66617. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66618. /** @hidden */
  66619. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66620. }
  66621. }
  66622. /**
  66623. * Defines the physics engine scene component responsible to manage a physics engine
  66624. */
  66625. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66626. /**
  66627. * The component name helpful to identify the component in the list of scene components.
  66628. */
  66629. readonly name: string;
  66630. /**
  66631. * The scene the component belongs to.
  66632. */
  66633. scene: Scene;
  66634. /**
  66635. * Creates a new instance of the component for the given scene
  66636. * @param scene Defines the scene to register the component in
  66637. */
  66638. constructor(scene: Scene);
  66639. /**
  66640. * Registers the component in a given scene
  66641. */
  66642. register(): void;
  66643. /**
  66644. * Rebuilds the elements related to this component in case of
  66645. * context lost for instance.
  66646. */
  66647. rebuild(): void;
  66648. /**
  66649. * Disposes the component and the associated ressources
  66650. */
  66651. dispose(): void;
  66652. }
  66653. }
  66654. declare module "babylonjs/Physics/physicsHelper" {
  66655. import { Nullable } from "babylonjs/types";
  66656. import { Vector3 } from "babylonjs/Maths/math.vector";
  66657. import { Mesh } from "babylonjs/Meshes/mesh";
  66658. import { Scene } from "babylonjs/scene";
  66659. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66660. /**
  66661. * A helper for physics simulations
  66662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66663. */
  66664. export class PhysicsHelper {
  66665. private _scene;
  66666. private _physicsEngine;
  66667. /**
  66668. * Initializes the Physics helper
  66669. * @param scene Babylon.js scene
  66670. */
  66671. constructor(scene: Scene);
  66672. /**
  66673. * Applies a radial explosion impulse
  66674. * @param origin the origin of the explosion
  66675. * @param radiusOrEventOptions the radius or the options of radial explosion
  66676. * @param strength the explosion strength
  66677. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66678. * @returns A physics radial explosion event, or null
  66679. */
  66680. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66681. /**
  66682. * Applies a radial explosion force
  66683. * @param origin the origin of the explosion
  66684. * @param radiusOrEventOptions the radius or the options of radial explosion
  66685. * @param strength the explosion strength
  66686. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66687. * @returns A physics radial explosion event, or null
  66688. */
  66689. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66690. /**
  66691. * Creates a gravitational field
  66692. * @param origin the origin of the explosion
  66693. * @param radiusOrEventOptions the radius or the options of radial explosion
  66694. * @param strength the explosion strength
  66695. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66696. * @returns A physics gravitational field event, or null
  66697. */
  66698. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66699. /**
  66700. * Creates a physics updraft event
  66701. * @param origin the origin of the updraft
  66702. * @param radiusOrEventOptions the radius or the options of the updraft
  66703. * @param strength the strength of the updraft
  66704. * @param height the height of the updraft
  66705. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66706. * @returns A physics updraft event, or null
  66707. */
  66708. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66709. /**
  66710. * Creates a physics vortex event
  66711. * @param origin the of the vortex
  66712. * @param radiusOrEventOptions the radius or the options of the vortex
  66713. * @param strength the strength of the vortex
  66714. * @param height the height of the vortex
  66715. * @returns a Physics vortex event, or null
  66716. * A physics vortex event or null
  66717. */
  66718. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66719. }
  66720. /**
  66721. * Represents a physics radial explosion event
  66722. */
  66723. class PhysicsRadialExplosionEvent {
  66724. private _scene;
  66725. private _options;
  66726. private _sphere;
  66727. private _dataFetched;
  66728. /**
  66729. * Initializes a radial explosioin event
  66730. * @param _scene BabylonJS scene
  66731. * @param _options The options for the vortex event
  66732. */
  66733. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66734. /**
  66735. * Returns the data related to the radial explosion event (sphere).
  66736. * @returns The radial explosion event data
  66737. */
  66738. getData(): PhysicsRadialExplosionEventData;
  66739. /**
  66740. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66741. * @param impostor A physics imposter
  66742. * @param origin the origin of the explosion
  66743. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66744. */
  66745. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66746. /**
  66747. * Triggers affecterd impostors callbacks
  66748. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66749. */
  66750. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66751. /**
  66752. * Disposes the sphere.
  66753. * @param force Specifies if the sphere should be disposed by force
  66754. */
  66755. dispose(force?: boolean): void;
  66756. /*** Helpers ***/
  66757. private _prepareSphere;
  66758. private _intersectsWithSphere;
  66759. }
  66760. /**
  66761. * Represents a gravitational field event
  66762. */
  66763. class PhysicsGravitationalFieldEvent {
  66764. private _physicsHelper;
  66765. private _scene;
  66766. private _origin;
  66767. private _options;
  66768. private _tickCallback;
  66769. private _sphere;
  66770. private _dataFetched;
  66771. /**
  66772. * Initializes the physics gravitational field event
  66773. * @param _physicsHelper A physics helper
  66774. * @param _scene BabylonJS scene
  66775. * @param _origin The origin position of the gravitational field event
  66776. * @param _options The options for the vortex event
  66777. */
  66778. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66779. /**
  66780. * Returns the data related to the gravitational field event (sphere).
  66781. * @returns A gravitational field event
  66782. */
  66783. getData(): PhysicsGravitationalFieldEventData;
  66784. /**
  66785. * Enables the gravitational field.
  66786. */
  66787. enable(): void;
  66788. /**
  66789. * Disables the gravitational field.
  66790. */
  66791. disable(): void;
  66792. /**
  66793. * Disposes the sphere.
  66794. * @param force The force to dispose from the gravitational field event
  66795. */
  66796. dispose(force?: boolean): void;
  66797. private _tick;
  66798. }
  66799. /**
  66800. * Represents a physics updraft event
  66801. */
  66802. class PhysicsUpdraftEvent {
  66803. private _scene;
  66804. private _origin;
  66805. private _options;
  66806. private _physicsEngine;
  66807. private _originTop;
  66808. private _originDirection;
  66809. private _tickCallback;
  66810. private _cylinder;
  66811. private _cylinderPosition;
  66812. private _dataFetched;
  66813. /**
  66814. * Initializes the physics updraft event
  66815. * @param _scene BabylonJS scene
  66816. * @param _origin The origin position of the updraft
  66817. * @param _options The options for the updraft event
  66818. */
  66819. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66820. /**
  66821. * Returns the data related to the updraft event (cylinder).
  66822. * @returns A physics updraft event
  66823. */
  66824. getData(): PhysicsUpdraftEventData;
  66825. /**
  66826. * Enables the updraft.
  66827. */
  66828. enable(): void;
  66829. /**
  66830. * Disables the updraft.
  66831. */
  66832. disable(): void;
  66833. /**
  66834. * Disposes the cylinder.
  66835. * @param force Specifies if the updraft should be disposed by force
  66836. */
  66837. dispose(force?: boolean): void;
  66838. private getImpostorHitData;
  66839. private _tick;
  66840. /*** Helpers ***/
  66841. private _prepareCylinder;
  66842. private _intersectsWithCylinder;
  66843. }
  66844. /**
  66845. * Represents a physics vortex event
  66846. */
  66847. class PhysicsVortexEvent {
  66848. private _scene;
  66849. private _origin;
  66850. private _options;
  66851. private _physicsEngine;
  66852. private _originTop;
  66853. private _tickCallback;
  66854. private _cylinder;
  66855. private _cylinderPosition;
  66856. private _dataFetched;
  66857. /**
  66858. * Initializes the physics vortex event
  66859. * @param _scene The BabylonJS scene
  66860. * @param _origin The origin position of the vortex
  66861. * @param _options The options for the vortex event
  66862. */
  66863. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66864. /**
  66865. * Returns the data related to the vortex event (cylinder).
  66866. * @returns The physics vortex event data
  66867. */
  66868. getData(): PhysicsVortexEventData;
  66869. /**
  66870. * Enables the vortex.
  66871. */
  66872. enable(): void;
  66873. /**
  66874. * Disables the cortex.
  66875. */
  66876. disable(): void;
  66877. /**
  66878. * Disposes the sphere.
  66879. * @param force
  66880. */
  66881. dispose(force?: boolean): void;
  66882. private getImpostorHitData;
  66883. private _tick;
  66884. /*** Helpers ***/
  66885. private _prepareCylinder;
  66886. private _intersectsWithCylinder;
  66887. }
  66888. /**
  66889. * Options fot the radial explosion event
  66890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66891. */
  66892. export class PhysicsRadialExplosionEventOptions {
  66893. /**
  66894. * The radius of the sphere for the radial explosion.
  66895. */
  66896. radius: number;
  66897. /**
  66898. * The strenth of the explosion.
  66899. */
  66900. strength: number;
  66901. /**
  66902. * The strenght of the force in correspondence to the distance of the affected object
  66903. */
  66904. falloff: PhysicsRadialImpulseFalloff;
  66905. /**
  66906. * Sphere options for the radial explosion.
  66907. */
  66908. sphere: {
  66909. segments: number;
  66910. diameter: number;
  66911. };
  66912. /**
  66913. * Sphere options for the radial explosion.
  66914. */
  66915. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66916. }
  66917. /**
  66918. * Options fot the updraft event
  66919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66920. */
  66921. export class PhysicsUpdraftEventOptions {
  66922. /**
  66923. * The radius of the cylinder for the vortex
  66924. */
  66925. radius: number;
  66926. /**
  66927. * The strenth of the updraft.
  66928. */
  66929. strength: number;
  66930. /**
  66931. * The height of the cylinder for the updraft.
  66932. */
  66933. height: number;
  66934. /**
  66935. * The mode for the the updraft.
  66936. */
  66937. updraftMode: PhysicsUpdraftMode;
  66938. }
  66939. /**
  66940. * Options fot the vortex event
  66941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66942. */
  66943. export class PhysicsVortexEventOptions {
  66944. /**
  66945. * The radius of the cylinder for the vortex
  66946. */
  66947. radius: number;
  66948. /**
  66949. * The strenth of the vortex.
  66950. */
  66951. strength: number;
  66952. /**
  66953. * The height of the cylinder for the vortex.
  66954. */
  66955. height: number;
  66956. /**
  66957. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66958. */
  66959. centripetalForceThreshold: number;
  66960. /**
  66961. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66962. */
  66963. centripetalForceMultiplier: number;
  66964. /**
  66965. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66966. */
  66967. centrifugalForceMultiplier: number;
  66968. /**
  66969. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66970. */
  66971. updraftForceMultiplier: number;
  66972. }
  66973. /**
  66974. * The strenght of the force in correspondence to the distance of the affected object
  66975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66976. */
  66977. export enum PhysicsRadialImpulseFalloff {
  66978. /** Defines that impulse is constant in strength across it's whole radius */
  66979. Constant = 0,
  66980. /** Defines that impulse gets weaker if it's further from the origin */
  66981. Linear = 1
  66982. }
  66983. /**
  66984. * The strength of the force in correspondence to the distance of the affected object
  66985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66986. */
  66987. export enum PhysicsUpdraftMode {
  66988. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66989. Center = 0,
  66990. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66991. Perpendicular = 1
  66992. }
  66993. /**
  66994. * Interface for a physics hit data
  66995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66996. */
  66997. export interface PhysicsHitData {
  66998. /**
  66999. * The force applied at the contact point
  67000. */
  67001. force: Vector3;
  67002. /**
  67003. * The contact point
  67004. */
  67005. contactPoint: Vector3;
  67006. /**
  67007. * The distance from the origin to the contact point
  67008. */
  67009. distanceFromOrigin: number;
  67010. }
  67011. /**
  67012. * Interface for radial explosion event data
  67013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67014. */
  67015. export interface PhysicsRadialExplosionEventData {
  67016. /**
  67017. * A sphere used for the radial explosion event
  67018. */
  67019. sphere: Mesh;
  67020. }
  67021. /**
  67022. * Interface for gravitational field event data
  67023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67024. */
  67025. export interface PhysicsGravitationalFieldEventData {
  67026. /**
  67027. * A sphere mesh used for the gravitational field event
  67028. */
  67029. sphere: Mesh;
  67030. }
  67031. /**
  67032. * Interface for updraft event data
  67033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67034. */
  67035. export interface PhysicsUpdraftEventData {
  67036. /**
  67037. * A cylinder used for the updraft event
  67038. */
  67039. cylinder: Mesh;
  67040. }
  67041. /**
  67042. * Interface for vortex event data
  67043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67044. */
  67045. export interface PhysicsVortexEventData {
  67046. /**
  67047. * A cylinder used for the vortex event
  67048. */
  67049. cylinder: Mesh;
  67050. }
  67051. /**
  67052. * Interface for an affected physics impostor
  67053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67054. */
  67055. export interface PhysicsAffectedImpostorWithData {
  67056. /**
  67057. * The impostor affected by the effect
  67058. */
  67059. impostor: PhysicsImpostor;
  67060. /**
  67061. * The data about the hit/horce from the explosion
  67062. */
  67063. hitData: PhysicsHitData;
  67064. }
  67065. }
  67066. declare module "babylonjs/Physics/Plugins/index" {
  67067. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67068. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67069. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67070. }
  67071. declare module "babylonjs/Physics/index" {
  67072. export * from "babylonjs/Physics/IPhysicsEngine";
  67073. export * from "babylonjs/Physics/physicsEngine";
  67074. export * from "babylonjs/Physics/physicsEngineComponent";
  67075. export * from "babylonjs/Physics/physicsHelper";
  67076. export * from "babylonjs/Physics/physicsImpostor";
  67077. export * from "babylonjs/Physics/physicsJoint";
  67078. export * from "babylonjs/Physics/Plugins/index";
  67079. }
  67080. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67081. /** @hidden */
  67082. export var blackAndWhitePixelShader: {
  67083. name: string;
  67084. shader: string;
  67085. };
  67086. }
  67087. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67088. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67089. import { Camera } from "babylonjs/Cameras/camera";
  67090. import { Engine } from "babylonjs/Engines/engine";
  67091. import "babylonjs/Shaders/blackAndWhite.fragment";
  67092. /**
  67093. * Post process used to render in black and white
  67094. */
  67095. export class BlackAndWhitePostProcess extends PostProcess {
  67096. /**
  67097. * Linear about to convert he result to black and white (default: 1)
  67098. */
  67099. degree: number;
  67100. /**
  67101. * Creates a black and white post process
  67102. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67103. * @param name The name of the effect.
  67104. * @param options The required width/height ratio to downsize to before computing the render pass.
  67105. * @param camera The camera to apply the render pass to.
  67106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67107. * @param engine The engine which the post process will be applied. (default: current engine)
  67108. * @param reusable If the post process can be reused on the same frame. (default: false)
  67109. */
  67110. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67111. }
  67112. }
  67113. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67114. import { Nullable } from "babylonjs/types";
  67115. import { Camera } from "babylonjs/Cameras/camera";
  67116. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67117. import { Engine } from "babylonjs/Engines/engine";
  67118. /**
  67119. * This represents a set of one or more post processes in Babylon.
  67120. * A post process can be used to apply a shader to a texture after it is rendered.
  67121. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67122. */
  67123. export class PostProcessRenderEffect {
  67124. private _postProcesses;
  67125. private _getPostProcesses;
  67126. private _singleInstance;
  67127. private _cameras;
  67128. private _indicesForCamera;
  67129. /**
  67130. * Name of the effect
  67131. * @hidden
  67132. */
  67133. _name: string;
  67134. /**
  67135. * Instantiates a post process render effect.
  67136. * A post process can be used to apply a shader to a texture after it is rendered.
  67137. * @param engine The engine the effect is tied to
  67138. * @param name The name of the effect
  67139. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67140. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67141. */
  67142. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67143. /**
  67144. * Checks if all the post processes in the effect are supported.
  67145. */
  67146. get isSupported(): boolean;
  67147. /**
  67148. * Updates the current state of the effect
  67149. * @hidden
  67150. */
  67151. _update(): void;
  67152. /**
  67153. * Attaches the effect on cameras
  67154. * @param cameras The camera to attach to.
  67155. * @hidden
  67156. */
  67157. _attachCameras(cameras: Camera): void;
  67158. /**
  67159. * Attaches the effect on cameras
  67160. * @param cameras The camera to attach to.
  67161. * @hidden
  67162. */
  67163. _attachCameras(cameras: Camera[]): void;
  67164. /**
  67165. * Detaches the effect on cameras
  67166. * @param cameras The camera to detatch from.
  67167. * @hidden
  67168. */
  67169. _detachCameras(cameras: Camera): void;
  67170. /**
  67171. * Detatches the effect on cameras
  67172. * @param cameras The camera to detatch from.
  67173. * @hidden
  67174. */
  67175. _detachCameras(cameras: Camera[]): void;
  67176. /**
  67177. * Enables the effect on given cameras
  67178. * @param cameras The camera to enable.
  67179. * @hidden
  67180. */
  67181. _enable(cameras: Camera): void;
  67182. /**
  67183. * Enables the effect on given cameras
  67184. * @param cameras The camera to enable.
  67185. * @hidden
  67186. */
  67187. _enable(cameras: Nullable<Camera[]>): void;
  67188. /**
  67189. * Disables the effect on the given cameras
  67190. * @param cameras The camera to disable.
  67191. * @hidden
  67192. */
  67193. _disable(cameras: Camera): void;
  67194. /**
  67195. * Disables the effect on the given cameras
  67196. * @param cameras The camera to disable.
  67197. * @hidden
  67198. */
  67199. _disable(cameras: Nullable<Camera[]>): void;
  67200. /**
  67201. * Gets a list of the post processes contained in the effect.
  67202. * @param camera The camera to get the post processes on.
  67203. * @returns The list of the post processes in the effect.
  67204. */
  67205. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67206. }
  67207. }
  67208. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67209. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67210. /** @hidden */
  67211. export var extractHighlightsPixelShader: {
  67212. name: string;
  67213. shader: string;
  67214. };
  67215. }
  67216. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67217. import { Nullable } from "babylonjs/types";
  67218. import { Camera } from "babylonjs/Cameras/camera";
  67219. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67220. import { Engine } from "babylonjs/Engines/engine";
  67221. import "babylonjs/Shaders/extractHighlights.fragment";
  67222. /**
  67223. * 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.
  67224. */
  67225. export class ExtractHighlightsPostProcess extends PostProcess {
  67226. /**
  67227. * The luminance threshold, pixels below this value will be set to black.
  67228. */
  67229. threshold: number;
  67230. /** @hidden */
  67231. _exposure: number;
  67232. /**
  67233. * Post process which has the input texture to be used when performing highlight extraction
  67234. * @hidden
  67235. */
  67236. _inputPostProcess: Nullable<PostProcess>;
  67237. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67238. }
  67239. }
  67240. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67241. /** @hidden */
  67242. export var bloomMergePixelShader: {
  67243. name: string;
  67244. shader: string;
  67245. };
  67246. }
  67247. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67248. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67249. import { Nullable } from "babylonjs/types";
  67250. import { Engine } from "babylonjs/Engines/engine";
  67251. import { Camera } from "babylonjs/Cameras/camera";
  67252. import "babylonjs/Shaders/bloomMerge.fragment";
  67253. /**
  67254. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67255. */
  67256. export class BloomMergePostProcess extends PostProcess {
  67257. /** Weight of the bloom to be added to the original input. */
  67258. weight: number;
  67259. /**
  67260. * Creates a new instance of @see BloomMergePostProcess
  67261. * @param name The name of the effect.
  67262. * @param originalFromInput Post process which's input will be used for the merge.
  67263. * @param blurred Blurred highlights post process which's output will be used.
  67264. * @param weight Weight of the bloom to be added to the original input.
  67265. * @param options The required width/height ratio to downsize to before computing the render pass.
  67266. * @param camera The camera to apply the render pass to.
  67267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67268. * @param engine The engine which the post process will be applied. (default: current engine)
  67269. * @param reusable If the post process can be reused on the same frame. (default: false)
  67270. * @param textureType Type of textures used when performing the post process. (default: 0)
  67271. * @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)
  67272. */
  67273. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67274. /** Weight of the bloom to be added to the original input. */
  67275. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67276. }
  67277. }
  67278. declare module "babylonjs/PostProcesses/bloomEffect" {
  67279. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67280. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67281. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67282. import { Camera } from "babylonjs/Cameras/camera";
  67283. import { Scene } from "babylonjs/scene";
  67284. /**
  67285. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67286. */
  67287. export class BloomEffect extends PostProcessRenderEffect {
  67288. private bloomScale;
  67289. /**
  67290. * @hidden Internal
  67291. */
  67292. _effects: Array<PostProcess>;
  67293. /**
  67294. * @hidden Internal
  67295. */
  67296. _downscale: ExtractHighlightsPostProcess;
  67297. private _blurX;
  67298. private _blurY;
  67299. private _merge;
  67300. /**
  67301. * The luminance threshold to find bright areas of the image to bloom.
  67302. */
  67303. get threshold(): number;
  67304. set threshold(value: number);
  67305. /**
  67306. * The strength of the bloom.
  67307. */
  67308. get weight(): number;
  67309. set weight(value: number);
  67310. /**
  67311. * Specifies the size of the bloom blur kernel, relative to the final output size
  67312. */
  67313. get kernel(): number;
  67314. set kernel(value: number);
  67315. /**
  67316. * Creates a new instance of @see BloomEffect
  67317. * @param scene The scene the effect belongs to.
  67318. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67319. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67320. * @param bloomWeight The the strength of bloom.
  67321. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67322. * @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)
  67323. */
  67324. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67325. /**
  67326. * Disposes each of the internal effects for a given camera.
  67327. * @param camera The camera to dispose the effect on.
  67328. */
  67329. disposeEffects(camera: Camera): void;
  67330. /**
  67331. * @hidden Internal
  67332. */
  67333. _updateEffects(): void;
  67334. /**
  67335. * Internal
  67336. * @returns if all the contained post processes are ready.
  67337. * @hidden
  67338. */
  67339. _isReady(): boolean;
  67340. }
  67341. }
  67342. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67343. /** @hidden */
  67344. export var chromaticAberrationPixelShader: {
  67345. name: string;
  67346. shader: string;
  67347. };
  67348. }
  67349. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67350. import { Vector2 } from "babylonjs/Maths/math.vector";
  67351. import { Nullable } from "babylonjs/types";
  67352. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67353. import { Camera } from "babylonjs/Cameras/camera";
  67354. import { Engine } from "babylonjs/Engines/engine";
  67355. import "babylonjs/Shaders/chromaticAberration.fragment";
  67356. /**
  67357. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67358. */
  67359. export class ChromaticAberrationPostProcess extends PostProcess {
  67360. /**
  67361. * The amount of seperation of rgb channels (default: 30)
  67362. */
  67363. aberrationAmount: number;
  67364. /**
  67365. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67366. */
  67367. radialIntensity: number;
  67368. /**
  67369. * 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))
  67370. */
  67371. direction: Vector2;
  67372. /**
  67373. * 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))
  67374. */
  67375. centerPosition: Vector2;
  67376. /**
  67377. * Creates a new instance ChromaticAberrationPostProcess
  67378. * @param name The name of the effect.
  67379. * @param screenWidth The width of the screen to apply the effect on.
  67380. * @param screenHeight The height of the screen to apply the effect on.
  67381. * @param options The required width/height ratio to downsize to before computing the render pass.
  67382. * @param camera The camera to apply the render pass to.
  67383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67384. * @param engine The engine which the post process will be applied. (default: current engine)
  67385. * @param reusable If the post process can be reused on the same frame. (default: false)
  67386. * @param textureType Type of textures used when performing the post process. (default: 0)
  67387. * @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)
  67388. */
  67389. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67390. }
  67391. }
  67392. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67393. /** @hidden */
  67394. export var circleOfConfusionPixelShader: {
  67395. name: string;
  67396. shader: string;
  67397. };
  67398. }
  67399. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67400. import { Nullable } from "babylonjs/types";
  67401. import { Engine } from "babylonjs/Engines/engine";
  67402. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67403. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67404. import { Camera } from "babylonjs/Cameras/camera";
  67405. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67406. /**
  67407. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67408. */
  67409. export class CircleOfConfusionPostProcess extends PostProcess {
  67410. /**
  67411. * 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.
  67412. */
  67413. lensSize: number;
  67414. /**
  67415. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67416. */
  67417. fStop: number;
  67418. /**
  67419. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67420. */
  67421. focusDistance: number;
  67422. /**
  67423. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67424. */
  67425. focalLength: number;
  67426. private _depthTexture;
  67427. /**
  67428. * Creates a new instance CircleOfConfusionPostProcess
  67429. * @param name The name of the effect.
  67430. * @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.
  67431. * @param options The required width/height ratio to downsize to before computing the render pass.
  67432. * @param camera The camera to apply the render pass to.
  67433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67434. * @param engine The engine which the post process will be applied. (default: current engine)
  67435. * @param reusable If the post process can be reused on the same frame. (default: false)
  67436. * @param textureType Type of textures used when performing the post process. (default: 0)
  67437. * @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)
  67438. */
  67439. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67440. /**
  67441. * 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.
  67442. */
  67443. set depthTexture(value: RenderTargetTexture);
  67444. }
  67445. }
  67446. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67447. /** @hidden */
  67448. export var colorCorrectionPixelShader: {
  67449. name: string;
  67450. shader: string;
  67451. };
  67452. }
  67453. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67454. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67455. import { Engine } from "babylonjs/Engines/engine";
  67456. import { Camera } from "babylonjs/Cameras/camera";
  67457. import "babylonjs/Shaders/colorCorrection.fragment";
  67458. /**
  67459. *
  67460. * This post-process allows the modification of rendered colors by using
  67461. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67462. *
  67463. * The object needs to be provided an url to a texture containing the color
  67464. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67465. * Use an image editing software to tweak the LUT to match your needs.
  67466. *
  67467. * For an example of a color LUT, see here:
  67468. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67469. * For explanations on color grading, see here:
  67470. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67471. *
  67472. */
  67473. export class ColorCorrectionPostProcess extends PostProcess {
  67474. private _colorTableTexture;
  67475. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67476. }
  67477. }
  67478. declare module "babylonjs/Shaders/convolution.fragment" {
  67479. /** @hidden */
  67480. export var convolutionPixelShader: {
  67481. name: string;
  67482. shader: string;
  67483. };
  67484. }
  67485. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67486. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67487. import { Nullable } from "babylonjs/types";
  67488. import { Camera } from "babylonjs/Cameras/camera";
  67489. import { Engine } from "babylonjs/Engines/engine";
  67490. import "babylonjs/Shaders/convolution.fragment";
  67491. /**
  67492. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67493. * input texture to perform effects such as edge detection or sharpening
  67494. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67495. */
  67496. export class ConvolutionPostProcess extends PostProcess {
  67497. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67498. kernel: number[];
  67499. /**
  67500. * Creates a new instance ConvolutionPostProcess
  67501. * @param name The name of the effect.
  67502. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67503. * @param options The required width/height ratio to downsize to before computing the render pass.
  67504. * @param camera The camera to apply the render pass to.
  67505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67506. * @param engine The engine which the post process will be applied. (default: current engine)
  67507. * @param reusable If the post process can be reused on the same frame. (default: false)
  67508. * @param textureType Type of textures used when performing the post process. (default: 0)
  67509. */
  67510. constructor(name: string,
  67511. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67512. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67513. /**
  67514. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67515. */
  67516. static EdgeDetect0Kernel: number[];
  67517. /**
  67518. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67519. */
  67520. static EdgeDetect1Kernel: number[];
  67521. /**
  67522. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67523. */
  67524. static EdgeDetect2Kernel: number[];
  67525. /**
  67526. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67527. */
  67528. static SharpenKernel: number[];
  67529. /**
  67530. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67531. */
  67532. static EmbossKernel: number[];
  67533. /**
  67534. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67535. */
  67536. static GaussianKernel: number[];
  67537. }
  67538. }
  67539. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67540. import { Nullable } from "babylonjs/types";
  67541. import { Vector2 } from "babylonjs/Maths/math.vector";
  67542. import { Camera } from "babylonjs/Cameras/camera";
  67543. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67544. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67545. import { Engine } from "babylonjs/Engines/engine";
  67546. import { Scene } from "babylonjs/scene";
  67547. /**
  67548. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67549. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67550. * based on samples that have a large difference in distance than the center pixel.
  67551. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67552. */
  67553. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67554. direction: Vector2;
  67555. /**
  67556. * Creates a new instance CircleOfConfusionPostProcess
  67557. * @param name The name of the effect.
  67558. * @param scene The scene the effect belongs to.
  67559. * @param direction The direction the blur should be applied.
  67560. * @param kernel The size of the kernel used to blur.
  67561. * @param options The required width/height ratio to downsize to before computing the render pass.
  67562. * @param camera The camera to apply the render pass to.
  67563. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67564. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67566. * @param engine The engine which the post process will be applied. (default: current engine)
  67567. * @param reusable If the post process can be reused on the same frame. (default: false)
  67568. * @param textureType Type of textures used when performing the post process. (default: 0)
  67569. * @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)
  67570. */
  67571. 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);
  67572. }
  67573. }
  67574. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67575. /** @hidden */
  67576. export var depthOfFieldMergePixelShader: {
  67577. name: string;
  67578. shader: string;
  67579. };
  67580. }
  67581. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67582. import { Nullable } from "babylonjs/types";
  67583. import { Camera } from "babylonjs/Cameras/camera";
  67584. import { Effect } from "babylonjs/Materials/effect";
  67585. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67586. import { Engine } from "babylonjs/Engines/engine";
  67587. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67588. /**
  67589. * Options to be set when merging outputs from the default pipeline.
  67590. */
  67591. export class DepthOfFieldMergePostProcessOptions {
  67592. /**
  67593. * The original image to merge on top of
  67594. */
  67595. originalFromInput: PostProcess;
  67596. /**
  67597. * Parameters to perform the merge of the depth of field effect
  67598. */
  67599. depthOfField?: {
  67600. circleOfConfusion: PostProcess;
  67601. blurSteps: Array<PostProcess>;
  67602. };
  67603. /**
  67604. * Parameters to perform the merge of bloom effect
  67605. */
  67606. bloom?: {
  67607. blurred: PostProcess;
  67608. weight: number;
  67609. };
  67610. }
  67611. /**
  67612. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67613. */
  67614. export class DepthOfFieldMergePostProcess extends PostProcess {
  67615. private blurSteps;
  67616. /**
  67617. * Creates a new instance of DepthOfFieldMergePostProcess
  67618. * @param name The name of the effect.
  67619. * @param originalFromInput Post process which's input will be used for the merge.
  67620. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67621. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67622. * @param options The required width/height ratio to downsize to before computing the render pass.
  67623. * @param camera The camera to apply the render pass to.
  67624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67625. * @param engine The engine which the post process will be applied. (default: current engine)
  67626. * @param reusable If the post process can be reused on the same frame. (default: false)
  67627. * @param textureType Type of textures used when performing the post process. (default: 0)
  67628. * @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)
  67629. */
  67630. 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);
  67631. /**
  67632. * Updates the effect with the current post process compile time values and recompiles the shader.
  67633. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67634. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67635. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67636. * @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
  67637. * @param onCompiled Called when the shader has been compiled.
  67638. * @param onError Called if there is an error when compiling a shader.
  67639. */
  67640. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67641. }
  67642. }
  67643. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67644. import { Nullable } from "babylonjs/types";
  67645. import { Camera } from "babylonjs/Cameras/camera";
  67646. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67647. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67648. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67649. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67650. import { Scene } from "babylonjs/scene";
  67651. /**
  67652. * Specifies the level of max blur that should be applied when using the depth of field effect
  67653. */
  67654. export enum DepthOfFieldEffectBlurLevel {
  67655. /**
  67656. * Subtle blur
  67657. */
  67658. Low = 0,
  67659. /**
  67660. * Medium blur
  67661. */
  67662. Medium = 1,
  67663. /**
  67664. * Large blur
  67665. */
  67666. High = 2
  67667. }
  67668. /**
  67669. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67670. */
  67671. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67672. private _circleOfConfusion;
  67673. /**
  67674. * @hidden Internal, blurs from high to low
  67675. */
  67676. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67677. private _depthOfFieldBlurY;
  67678. private _dofMerge;
  67679. /**
  67680. * @hidden Internal post processes in depth of field effect
  67681. */
  67682. _effects: Array<PostProcess>;
  67683. /**
  67684. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67685. */
  67686. set focalLength(value: number);
  67687. get focalLength(): number;
  67688. /**
  67689. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67690. */
  67691. set fStop(value: number);
  67692. get fStop(): number;
  67693. /**
  67694. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67695. */
  67696. set focusDistance(value: number);
  67697. get focusDistance(): number;
  67698. /**
  67699. * 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.
  67700. */
  67701. set lensSize(value: number);
  67702. get lensSize(): number;
  67703. /**
  67704. * Creates a new instance DepthOfFieldEffect
  67705. * @param scene The scene the effect belongs to.
  67706. * @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.
  67707. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67708. * @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)
  67709. */
  67710. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67711. /**
  67712. * Get the current class name of the current effet
  67713. * @returns "DepthOfFieldEffect"
  67714. */
  67715. getClassName(): string;
  67716. /**
  67717. * 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.
  67718. */
  67719. set depthTexture(value: RenderTargetTexture);
  67720. /**
  67721. * Disposes each of the internal effects for a given camera.
  67722. * @param camera The camera to dispose the effect on.
  67723. */
  67724. disposeEffects(camera: Camera): void;
  67725. /**
  67726. * @hidden Internal
  67727. */
  67728. _updateEffects(): void;
  67729. /**
  67730. * Internal
  67731. * @returns if all the contained post processes are ready.
  67732. * @hidden
  67733. */
  67734. _isReady(): boolean;
  67735. }
  67736. }
  67737. declare module "babylonjs/Shaders/displayPass.fragment" {
  67738. /** @hidden */
  67739. export var displayPassPixelShader: {
  67740. name: string;
  67741. shader: string;
  67742. };
  67743. }
  67744. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67745. import { Nullable } from "babylonjs/types";
  67746. import { Camera } from "babylonjs/Cameras/camera";
  67747. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67748. import { Engine } from "babylonjs/Engines/engine";
  67749. import "babylonjs/Shaders/displayPass.fragment";
  67750. /**
  67751. * DisplayPassPostProcess which produces an output the same as it's input
  67752. */
  67753. export class DisplayPassPostProcess extends PostProcess {
  67754. /**
  67755. * Creates the DisplayPassPostProcess
  67756. * @param name The name of the effect.
  67757. * @param options The required width/height ratio to downsize to before computing the render pass.
  67758. * @param camera The camera to apply the render pass to.
  67759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67760. * @param engine The engine which the post process will be applied. (default: current engine)
  67761. * @param reusable If the post process can be reused on the same frame. (default: false)
  67762. */
  67763. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67764. }
  67765. }
  67766. declare module "babylonjs/Shaders/filter.fragment" {
  67767. /** @hidden */
  67768. export var filterPixelShader: {
  67769. name: string;
  67770. shader: string;
  67771. };
  67772. }
  67773. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67774. import { Nullable } from "babylonjs/types";
  67775. import { Matrix } from "babylonjs/Maths/math.vector";
  67776. import { Camera } from "babylonjs/Cameras/camera";
  67777. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67778. import { Engine } from "babylonjs/Engines/engine";
  67779. import "babylonjs/Shaders/filter.fragment";
  67780. /**
  67781. * Applies a kernel filter to the image
  67782. */
  67783. export class FilterPostProcess extends PostProcess {
  67784. /** The matrix to be applied to the image */
  67785. kernelMatrix: Matrix;
  67786. /**
  67787. *
  67788. * @param name The name of the effect.
  67789. * @param kernelMatrix The matrix to be applied to the image
  67790. * @param options The required width/height ratio to downsize to before computing the render pass.
  67791. * @param camera The camera to apply the render pass to.
  67792. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67793. * @param engine The engine which the post process will be applied. (default: current engine)
  67794. * @param reusable If the post process can be reused on the same frame. (default: false)
  67795. */
  67796. constructor(name: string,
  67797. /** The matrix to be applied to the image */
  67798. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67799. }
  67800. }
  67801. declare module "babylonjs/Shaders/fxaa.fragment" {
  67802. /** @hidden */
  67803. export var fxaaPixelShader: {
  67804. name: string;
  67805. shader: string;
  67806. };
  67807. }
  67808. declare module "babylonjs/Shaders/fxaa.vertex" {
  67809. /** @hidden */
  67810. export var fxaaVertexShader: {
  67811. name: string;
  67812. shader: string;
  67813. };
  67814. }
  67815. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67816. import { Nullable } from "babylonjs/types";
  67817. import { Camera } from "babylonjs/Cameras/camera";
  67818. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67819. import { Engine } from "babylonjs/Engines/engine";
  67820. import "babylonjs/Shaders/fxaa.fragment";
  67821. import "babylonjs/Shaders/fxaa.vertex";
  67822. /**
  67823. * Fxaa post process
  67824. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67825. */
  67826. export class FxaaPostProcess extends PostProcess {
  67827. /** @hidden */
  67828. texelWidth: number;
  67829. /** @hidden */
  67830. texelHeight: number;
  67831. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67832. private _getDefines;
  67833. }
  67834. }
  67835. declare module "babylonjs/Shaders/grain.fragment" {
  67836. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67837. /** @hidden */
  67838. export var grainPixelShader: {
  67839. name: string;
  67840. shader: string;
  67841. };
  67842. }
  67843. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67844. import { Nullable } from "babylonjs/types";
  67845. import { Camera } from "babylonjs/Cameras/camera";
  67846. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67847. import { Engine } from "babylonjs/Engines/engine";
  67848. import "babylonjs/Shaders/grain.fragment";
  67849. /**
  67850. * The GrainPostProcess adds noise to the image at mid luminance levels
  67851. */
  67852. export class GrainPostProcess extends PostProcess {
  67853. /**
  67854. * The intensity of the grain added (default: 30)
  67855. */
  67856. intensity: number;
  67857. /**
  67858. * If the grain should be randomized on every frame
  67859. */
  67860. animated: boolean;
  67861. /**
  67862. * Creates a new instance of @see GrainPostProcess
  67863. * @param name The name of the effect.
  67864. * @param options The required width/height ratio to downsize to before computing the render pass.
  67865. * @param camera The camera to apply the render pass to.
  67866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67867. * @param engine The engine which the post process will be applied. (default: current engine)
  67868. * @param reusable If the post process can be reused on the same frame. (default: false)
  67869. * @param textureType Type of textures used when performing the post process. (default: 0)
  67870. * @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)
  67871. */
  67872. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67873. }
  67874. }
  67875. declare module "babylonjs/Shaders/highlights.fragment" {
  67876. /** @hidden */
  67877. export var highlightsPixelShader: {
  67878. name: string;
  67879. shader: string;
  67880. };
  67881. }
  67882. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67883. import { Nullable } from "babylonjs/types";
  67884. import { Camera } from "babylonjs/Cameras/camera";
  67885. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67886. import { Engine } from "babylonjs/Engines/engine";
  67887. import "babylonjs/Shaders/highlights.fragment";
  67888. /**
  67889. * Extracts highlights from the image
  67890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67891. */
  67892. export class HighlightsPostProcess extends PostProcess {
  67893. /**
  67894. * Extracts highlights from the image
  67895. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67896. * @param name The name of the effect.
  67897. * @param options The required width/height ratio to downsize to before computing the render pass.
  67898. * @param camera The camera to apply the render pass to.
  67899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67900. * @param engine The engine which the post process will be applied. (default: current engine)
  67901. * @param reusable If the post process can be reused on the same frame. (default: false)
  67902. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67903. */
  67904. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67905. }
  67906. }
  67907. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67908. /** @hidden */
  67909. export var mrtFragmentDeclaration: {
  67910. name: string;
  67911. shader: string;
  67912. };
  67913. }
  67914. declare module "babylonjs/Shaders/geometry.fragment" {
  67915. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67916. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67917. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67918. /** @hidden */
  67919. export var geometryPixelShader: {
  67920. name: string;
  67921. shader: string;
  67922. };
  67923. }
  67924. declare module "babylonjs/Shaders/geometry.vertex" {
  67925. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67926. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67927. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67928. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67929. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67930. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67931. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67932. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67933. /** @hidden */
  67934. export var geometryVertexShader: {
  67935. name: string;
  67936. shader: string;
  67937. };
  67938. }
  67939. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67940. import { Matrix } from "babylonjs/Maths/math.vector";
  67941. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67942. import { Mesh } from "babylonjs/Meshes/mesh";
  67943. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67944. import { Effect } from "babylonjs/Materials/effect";
  67945. import { Scene } from "babylonjs/scene";
  67946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67947. import "babylonjs/Shaders/geometry.fragment";
  67948. import "babylonjs/Shaders/geometry.vertex";
  67949. /** @hidden */
  67950. interface ISavedTransformationMatrix {
  67951. world: Matrix;
  67952. viewProjection: Matrix;
  67953. }
  67954. /**
  67955. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67956. */
  67957. export class GeometryBufferRenderer {
  67958. /**
  67959. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67960. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67961. */
  67962. static readonly POSITION_TEXTURE_TYPE: number;
  67963. /**
  67964. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67965. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67966. */
  67967. static readonly VELOCITY_TEXTURE_TYPE: number;
  67968. /**
  67969. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67970. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67971. */
  67972. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67973. /**
  67974. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67975. * in order to compute objects velocities when enableVelocity is set to "true"
  67976. * @hidden
  67977. */
  67978. _previousTransformationMatrices: {
  67979. [index: number]: ISavedTransformationMatrix;
  67980. };
  67981. /**
  67982. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67983. * in order to compute objects velocities when enableVelocity is set to "true"
  67984. * @hidden
  67985. */
  67986. _previousBonesTransformationMatrices: {
  67987. [index: number]: Float32Array;
  67988. };
  67989. /**
  67990. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67991. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67992. */
  67993. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67994. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67995. renderTransparentMeshes: boolean;
  67996. private _scene;
  67997. private _multiRenderTarget;
  67998. private _ratio;
  67999. private _enablePosition;
  68000. private _enableVelocity;
  68001. private _enableReflectivity;
  68002. private _positionIndex;
  68003. private _velocityIndex;
  68004. private _reflectivityIndex;
  68005. protected _effect: Effect;
  68006. protected _cachedDefines: string;
  68007. /**
  68008. * Set the render list (meshes to be rendered) used in the G buffer.
  68009. */
  68010. set renderList(meshes: Mesh[]);
  68011. /**
  68012. * Gets wether or not G buffer are supported by the running hardware.
  68013. * This requires draw buffer supports
  68014. */
  68015. get isSupported(): boolean;
  68016. /**
  68017. * Returns the index of the given texture type in the G-Buffer textures array
  68018. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68019. * @returns the index of the given texture type in the G-Buffer textures array
  68020. */
  68021. getTextureIndex(textureType: number): number;
  68022. /**
  68023. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68024. */
  68025. get enablePosition(): boolean;
  68026. /**
  68027. * Sets whether or not objects positions are enabled for the G buffer.
  68028. */
  68029. set enablePosition(enable: boolean);
  68030. /**
  68031. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68032. */
  68033. get enableVelocity(): boolean;
  68034. /**
  68035. * Sets wether or not objects velocities are enabled for the G buffer.
  68036. */
  68037. set enableVelocity(enable: boolean);
  68038. /**
  68039. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68040. */
  68041. get enableReflectivity(): boolean;
  68042. /**
  68043. * Sets wether or not objects roughness are enabled for the G buffer.
  68044. */
  68045. set enableReflectivity(enable: boolean);
  68046. /**
  68047. * Gets the scene associated with the buffer.
  68048. */
  68049. get scene(): Scene;
  68050. /**
  68051. * Gets the ratio used by the buffer during its creation.
  68052. * How big is the buffer related to the main canvas.
  68053. */
  68054. get ratio(): number;
  68055. /** @hidden */
  68056. static _SceneComponentInitialization: (scene: Scene) => void;
  68057. /**
  68058. * Creates a new G Buffer for the scene
  68059. * @param scene The scene the buffer belongs to
  68060. * @param ratio How big is the buffer related to the main canvas.
  68061. */
  68062. constructor(scene: Scene, ratio?: number);
  68063. /**
  68064. * Checks wether everything is ready to render a submesh to the G buffer.
  68065. * @param subMesh the submesh to check readiness for
  68066. * @param useInstances is the mesh drawn using instance or not
  68067. * @returns true if ready otherwise false
  68068. */
  68069. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68070. /**
  68071. * Gets the current underlying G Buffer.
  68072. * @returns the buffer
  68073. */
  68074. getGBuffer(): MultiRenderTarget;
  68075. /**
  68076. * Gets the number of samples used to render the buffer (anti aliasing).
  68077. */
  68078. get samples(): number;
  68079. /**
  68080. * Sets the number of samples used to render the buffer (anti aliasing).
  68081. */
  68082. set samples(value: number);
  68083. /**
  68084. * Disposes the renderer and frees up associated resources.
  68085. */
  68086. dispose(): void;
  68087. protected _createRenderTargets(): void;
  68088. private _copyBonesTransformationMatrices;
  68089. }
  68090. }
  68091. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68092. import { Nullable } from "babylonjs/types";
  68093. import { Scene } from "babylonjs/scene";
  68094. import { ISceneComponent } from "babylonjs/sceneComponent";
  68095. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68096. module "babylonjs/scene" {
  68097. interface Scene {
  68098. /** @hidden (Backing field) */
  68099. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68100. /**
  68101. * Gets or Sets the current geometry buffer associated to the scene.
  68102. */
  68103. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68104. /**
  68105. * Enables a GeometryBufferRender and associates it with the scene
  68106. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68107. * @returns the GeometryBufferRenderer
  68108. */
  68109. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68110. /**
  68111. * Disables the GeometryBufferRender associated with the scene
  68112. */
  68113. disableGeometryBufferRenderer(): void;
  68114. }
  68115. }
  68116. /**
  68117. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68118. * in several rendering techniques.
  68119. */
  68120. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68121. /**
  68122. * The component name helpful to identify the component in the list of scene components.
  68123. */
  68124. readonly name: string;
  68125. /**
  68126. * The scene the component belongs to.
  68127. */
  68128. scene: Scene;
  68129. /**
  68130. * Creates a new instance of the component for the given scene
  68131. * @param scene Defines the scene to register the component in
  68132. */
  68133. constructor(scene: Scene);
  68134. /**
  68135. * Registers the component in a given scene
  68136. */
  68137. register(): void;
  68138. /**
  68139. * Rebuilds the elements related to this component in case of
  68140. * context lost for instance.
  68141. */
  68142. rebuild(): void;
  68143. /**
  68144. * Disposes the component and the associated ressources
  68145. */
  68146. dispose(): void;
  68147. private _gatherRenderTargets;
  68148. }
  68149. }
  68150. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68151. /** @hidden */
  68152. export var motionBlurPixelShader: {
  68153. name: string;
  68154. shader: string;
  68155. };
  68156. }
  68157. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68158. import { Nullable } from "babylonjs/types";
  68159. import { Camera } from "babylonjs/Cameras/camera";
  68160. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68161. import { Scene } from "babylonjs/scene";
  68162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68163. import "babylonjs/Animations/animatable";
  68164. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68165. import "babylonjs/Shaders/motionBlur.fragment";
  68166. import { Engine } from "babylonjs/Engines/engine";
  68167. /**
  68168. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68169. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68170. * As an example, all you have to do is to create the post-process:
  68171. * var mb = new BABYLON.MotionBlurPostProcess(
  68172. * 'mb', // The name of the effect.
  68173. * scene, // The scene containing the objects to blur according to their velocity.
  68174. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68175. * camera // The camera to apply the render pass to.
  68176. * );
  68177. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68178. */
  68179. export class MotionBlurPostProcess extends PostProcess {
  68180. /**
  68181. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68182. */
  68183. motionStrength: number;
  68184. /**
  68185. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68186. */
  68187. get motionBlurSamples(): number;
  68188. /**
  68189. * Sets the number of iterations to be used for motion blur quality
  68190. */
  68191. set motionBlurSamples(samples: number);
  68192. private _motionBlurSamples;
  68193. private _geometryBufferRenderer;
  68194. /**
  68195. * Creates a new instance MotionBlurPostProcess
  68196. * @param name The name of the effect.
  68197. * @param scene The scene containing the objects to blur according to their velocity.
  68198. * @param options The required width/height ratio to downsize to before computing the render pass.
  68199. * @param camera The camera to apply the render pass to.
  68200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68201. * @param engine The engine which the post process will be applied. (default: current engine)
  68202. * @param reusable If the post process can be reused on the same frame. (default: false)
  68203. * @param textureType Type of textures used when performing the post process. (default: 0)
  68204. * @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)
  68205. */
  68206. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68207. /**
  68208. * Excludes the given skinned mesh from computing bones velocities.
  68209. * 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.
  68210. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68211. */
  68212. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68213. /**
  68214. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68215. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68216. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68217. */
  68218. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68219. /**
  68220. * Disposes the post process.
  68221. * @param camera The camera to dispose the post process on.
  68222. */
  68223. dispose(camera?: Camera): void;
  68224. }
  68225. }
  68226. declare module "babylonjs/Shaders/refraction.fragment" {
  68227. /** @hidden */
  68228. export var refractionPixelShader: {
  68229. name: string;
  68230. shader: string;
  68231. };
  68232. }
  68233. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68234. import { Color3 } from "babylonjs/Maths/math.color";
  68235. import { Camera } from "babylonjs/Cameras/camera";
  68236. import { Texture } from "babylonjs/Materials/Textures/texture";
  68237. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68238. import { Engine } from "babylonjs/Engines/engine";
  68239. import "babylonjs/Shaders/refraction.fragment";
  68240. /**
  68241. * Post process which applies a refractin texture
  68242. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68243. */
  68244. export class RefractionPostProcess extends PostProcess {
  68245. /** the base color of the refraction (used to taint the rendering) */
  68246. color: Color3;
  68247. /** simulated refraction depth */
  68248. depth: number;
  68249. /** the coefficient of the base color (0 to remove base color tainting) */
  68250. colorLevel: number;
  68251. private _refTexture;
  68252. private _ownRefractionTexture;
  68253. /**
  68254. * Gets or sets the refraction texture
  68255. * Please note that you are responsible for disposing the texture if you set it manually
  68256. */
  68257. get refractionTexture(): Texture;
  68258. set refractionTexture(value: Texture);
  68259. /**
  68260. * Initializes the RefractionPostProcess
  68261. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68262. * @param name The name of the effect.
  68263. * @param refractionTextureUrl Url of the refraction texture to use
  68264. * @param color the base color of the refraction (used to taint the rendering)
  68265. * @param depth simulated refraction depth
  68266. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68267. * @param camera The camera to apply the render pass to.
  68268. * @param options The required width/height ratio to downsize to before computing the render pass.
  68269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68270. * @param engine The engine which the post process will be applied. (default: current engine)
  68271. * @param reusable If the post process can be reused on the same frame. (default: false)
  68272. */
  68273. constructor(name: string, refractionTextureUrl: string,
  68274. /** the base color of the refraction (used to taint the rendering) */
  68275. color: Color3,
  68276. /** simulated refraction depth */
  68277. depth: number,
  68278. /** the coefficient of the base color (0 to remove base color tainting) */
  68279. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68280. /**
  68281. * Disposes of the post process
  68282. * @param camera Camera to dispose post process on
  68283. */
  68284. dispose(camera: Camera): void;
  68285. }
  68286. }
  68287. declare module "babylonjs/Shaders/sharpen.fragment" {
  68288. /** @hidden */
  68289. export var sharpenPixelShader: {
  68290. name: string;
  68291. shader: string;
  68292. };
  68293. }
  68294. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68295. import { Nullable } from "babylonjs/types";
  68296. import { Camera } from "babylonjs/Cameras/camera";
  68297. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68298. import "babylonjs/Shaders/sharpen.fragment";
  68299. import { Engine } from "babylonjs/Engines/engine";
  68300. /**
  68301. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68302. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68303. */
  68304. export class SharpenPostProcess extends PostProcess {
  68305. /**
  68306. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68307. */
  68308. colorAmount: number;
  68309. /**
  68310. * How much sharpness should be applied (default: 0.3)
  68311. */
  68312. edgeAmount: number;
  68313. /**
  68314. * Creates a new instance ConvolutionPostProcess
  68315. * @param name The name of the effect.
  68316. * @param options The required width/height ratio to downsize to before computing the render pass.
  68317. * @param camera The camera to apply the render pass to.
  68318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68319. * @param engine The engine which the post process will be applied. (default: current engine)
  68320. * @param reusable If the post process can be reused on the same frame. (default: false)
  68321. * @param textureType Type of textures used when performing the post process. (default: 0)
  68322. * @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)
  68323. */
  68324. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68325. }
  68326. }
  68327. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68328. import { Nullable } from "babylonjs/types";
  68329. import { Camera } from "babylonjs/Cameras/camera";
  68330. import { Engine } from "babylonjs/Engines/engine";
  68331. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68332. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68333. /**
  68334. * PostProcessRenderPipeline
  68335. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68336. */
  68337. export class PostProcessRenderPipeline {
  68338. private engine;
  68339. private _renderEffects;
  68340. private _renderEffectsForIsolatedPass;
  68341. /**
  68342. * List of inspectable custom properties (used by the Inspector)
  68343. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68344. */
  68345. inspectableCustomProperties: IInspectable[];
  68346. /**
  68347. * @hidden
  68348. */
  68349. protected _cameras: Camera[];
  68350. /** @hidden */
  68351. _name: string;
  68352. /**
  68353. * Gets pipeline name
  68354. */
  68355. get name(): string;
  68356. /** Gets the list of attached cameras */
  68357. get cameras(): Camera[];
  68358. /**
  68359. * Initializes a PostProcessRenderPipeline
  68360. * @param engine engine to add the pipeline to
  68361. * @param name name of the pipeline
  68362. */
  68363. constructor(engine: Engine, name: string);
  68364. /**
  68365. * Gets the class name
  68366. * @returns "PostProcessRenderPipeline"
  68367. */
  68368. getClassName(): string;
  68369. /**
  68370. * If all the render effects in the pipeline are supported
  68371. */
  68372. get isSupported(): boolean;
  68373. /**
  68374. * Adds an effect to the pipeline
  68375. * @param renderEffect the effect to add
  68376. */
  68377. addEffect(renderEffect: PostProcessRenderEffect): void;
  68378. /** @hidden */
  68379. _rebuild(): void;
  68380. /** @hidden */
  68381. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68382. /** @hidden */
  68383. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68384. /** @hidden */
  68385. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68386. /** @hidden */
  68387. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68388. /** @hidden */
  68389. _attachCameras(cameras: Camera, unique: boolean): void;
  68390. /** @hidden */
  68391. _attachCameras(cameras: Camera[], unique: boolean): void;
  68392. /** @hidden */
  68393. _detachCameras(cameras: Camera): void;
  68394. /** @hidden */
  68395. _detachCameras(cameras: Nullable<Camera[]>): void;
  68396. /** @hidden */
  68397. _update(): void;
  68398. /** @hidden */
  68399. _reset(): void;
  68400. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68401. /**
  68402. * Disposes of the pipeline
  68403. */
  68404. dispose(): void;
  68405. }
  68406. }
  68407. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68408. import { Camera } from "babylonjs/Cameras/camera";
  68409. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68410. /**
  68411. * PostProcessRenderPipelineManager class
  68412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68413. */
  68414. export class PostProcessRenderPipelineManager {
  68415. private _renderPipelines;
  68416. /**
  68417. * Initializes a PostProcessRenderPipelineManager
  68418. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68419. */
  68420. constructor();
  68421. /**
  68422. * Gets the list of supported render pipelines
  68423. */
  68424. get supportedPipelines(): PostProcessRenderPipeline[];
  68425. /**
  68426. * Adds a pipeline to the manager
  68427. * @param renderPipeline The pipeline to add
  68428. */
  68429. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68430. /**
  68431. * Attaches a camera to the pipeline
  68432. * @param renderPipelineName The name of the pipeline to attach to
  68433. * @param cameras the camera to attach
  68434. * @param unique if the camera can be attached multiple times to the pipeline
  68435. */
  68436. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68437. /**
  68438. * Detaches a camera from the pipeline
  68439. * @param renderPipelineName The name of the pipeline to detach from
  68440. * @param cameras the camera to detach
  68441. */
  68442. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68443. /**
  68444. * Enables an effect by name on a pipeline
  68445. * @param renderPipelineName the name of the pipeline to enable the effect in
  68446. * @param renderEffectName the name of the effect to enable
  68447. * @param cameras the cameras that the effect should be enabled on
  68448. */
  68449. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68450. /**
  68451. * Disables an effect by name on a pipeline
  68452. * @param renderPipelineName the name of the pipeline to disable the effect in
  68453. * @param renderEffectName the name of the effect to disable
  68454. * @param cameras the cameras that the effect should be disabled on
  68455. */
  68456. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68457. /**
  68458. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68459. */
  68460. update(): void;
  68461. /** @hidden */
  68462. _rebuild(): void;
  68463. /**
  68464. * Disposes of the manager and pipelines
  68465. */
  68466. dispose(): void;
  68467. }
  68468. }
  68469. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68470. import { ISceneComponent } from "babylonjs/sceneComponent";
  68471. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68472. import { Scene } from "babylonjs/scene";
  68473. module "babylonjs/scene" {
  68474. interface Scene {
  68475. /** @hidden (Backing field) */
  68476. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68477. /**
  68478. * Gets the postprocess render pipeline manager
  68479. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68480. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68481. */
  68482. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68483. }
  68484. }
  68485. /**
  68486. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68487. */
  68488. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68489. /**
  68490. * The component name helpfull to identify the component in the list of scene components.
  68491. */
  68492. readonly name: string;
  68493. /**
  68494. * The scene the component belongs to.
  68495. */
  68496. scene: Scene;
  68497. /**
  68498. * Creates a new instance of the component for the given scene
  68499. * @param scene Defines the scene to register the component in
  68500. */
  68501. constructor(scene: Scene);
  68502. /**
  68503. * Registers the component in a given scene
  68504. */
  68505. register(): void;
  68506. /**
  68507. * Rebuilds the elements related to this component in case of
  68508. * context lost for instance.
  68509. */
  68510. rebuild(): void;
  68511. /**
  68512. * Disposes the component and the associated ressources
  68513. */
  68514. dispose(): void;
  68515. private _gatherRenderTargets;
  68516. }
  68517. }
  68518. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68519. import { Nullable } from "babylonjs/types";
  68520. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68521. import { Camera } from "babylonjs/Cameras/camera";
  68522. import { IDisposable } from "babylonjs/scene";
  68523. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68524. import { Scene } from "babylonjs/scene";
  68525. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68526. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68527. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68528. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68529. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68530. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68531. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68532. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68533. import { Animation } from "babylonjs/Animations/animation";
  68534. /**
  68535. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68536. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68537. */
  68538. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68539. private _scene;
  68540. private _camerasToBeAttached;
  68541. /**
  68542. * ID of the sharpen post process,
  68543. */
  68544. private readonly SharpenPostProcessId;
  68545. /**
  68546. * @ignore
  68547. * ID of the image processing post process;
  68548. */
  68549. readonly ImageProcessingPostProcessId: string;
  68550. /**
  68551. * @ignore
  68552. * ID of the Fast Approximate Anti-Aliasing post process;
  68553. */
  68554. readonly FxaaPostProcessId: string;
  68555. /**
  68556. * ID of the chromatic aberration post process,
  68557. */
  68558. private readonly ChromaticAberrationPostProcessId;
  68559. /**
  68560. * ID of the grain post process
  68561. */
  68562. private readonly GrainPostProcessId;
  68563. /**
  68564. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68565. */
  68566. sharpen: SharpenPostProcess;
  68567. private _sharpenEffect;
  68568. private bloom;
  68569. /**
  68570. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68571. */
  68572. depthOfField: DepthOfFieldEffect;
  68573. /**
  68574. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68575. */
  68576. fxaa: FxaaPostProcess;
  68577. /**
  68578. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68579. */
  68580. imageProcessing: ImageProcessingPostProcess;
  68581. /**
  68582. * Chromatic aberration post process which will shift rgb colors in the image
  68583. */
  68584. chromaticAberration: ChromaticAberrationPostProcess;
  68585. private _chromaticAberrationEffect;
  68586. /**
  68587. * Grain post process which add noise to the image
  68588. */
  68589. grain: GrainPostProcess;
  68590. private _grainEffect;
  68591. /**
  68592. * Glow post process which adds a glow to emissive areas of the image
  68593. */
  68594. private _glowLayer;
  68595. /**
  68596. * Animations which can be used to tweak settings over a period of time
  68597. */
  68598. animations: Animation[];
  68599. private _imageProcessingConfigurationObserver;
  68600. private _sharpenEnabled;
  68601. private _bloomEnabled;
  68602. private _depthOfFieldEnabled;
  68603. private _depthOfFieldBlurLevel;
  68604. private _fxaaEnabled;
  68605. private _imageProcessingEnabled;
  68606. private _defaultPipelineTextureType;
  68607. private _bloomScale;
  68608. private _chromaticAberrationEnabled;
  68609. private _grainEnabled;
  68610. private _buildAllowed;
  68611. /**
  68612. * Gets active scene
  68613. */
  68614. get scene(): Scene;
  68615. /**
  68616. * Enable or disable the sharpen process from the pipeline
  68617. */
  68618. set sharpenEnabled(enabled: boolean);
  68619. get sharpenEnabled(): boolean;
  68620. private _resizeObserver;
  68621. private _hardwareScaleLevel;
  68622. private _bloomKernel;
  68623. /**
  68624. * Specifies the size of the bloom blur kernel, relative to the final output size
  68625. */
  68626. get bloomKernel(): number;
  68627. set bloomKernel(value: number);
  68628. /**
  68629. * Specifies the weight of the bloom in the final rendering
  68630. */
  68631. private _bloomWeight;
  68632. /**
  68633. * Specifies the luma threshold for the area that will be blurred by the bloom
  68634. */
  68635. private _bloomThreshold;
  68636. private _hdr;
  68637. /**
  68638. * The strength of the bloom.
  68639. */
  68640. set bloomWeight(value: number);
  68641. get bloomWeight(): number;
  68642. /**
  68643. * The strength of the bloom.
  68644. */
  68645. set bloomThreshold(value: number);
  68646. get bloomThreshold(): number;
  68647. /**
  68648. * The scale of the bloom, lower value will provide better performance.
  68649. */
  68650. set bloomScale(value: number);
  68651. get bloomScale(): number;
  68652. /**
  68653. * Enable or disable the bloom from the pipeline
  68654. */
  68655. set bloomEnabled(enabled: boolean);
  68656. get bloomEnabled(): boolean;
  68657. private _rebuildBloom;
  68658. /**
  68659. * If the depth of field is enabled.
  68660. */
  68661. get depthOfFieldEnabled(): boolean;
  68662. set depthOfFieldEnabled(enabled: boolean);
  68663. /**
  68664. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68665. */
  68666. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68667. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68668. /**
  68669. * If the anti aliasing is enabled.
  68670. */
  68671. set fxaaEnabled(enabled: boolean);
  68672. get fxaaEnabled(): boolean;
  68673. private _samples;
  68674. /**
  68675. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68676. */
  68677. set samples(sampleCount: number);
  68678. get samples(): number;
  68679. /**
  68680. * If image processing is enabled.
  68681. */
  68682. set imageProcessingEnabled(enabled: boolean);
  68683. get imageProcessingEnabled(): boolean;
  68684. /**
  68685. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68686. */
  68687. set glowLayerEnabled(enabled: boolean);
  68688. get glowLayerEnabled(): boolean;
  68689. /**
  68690. * Gets the glow layer (or null if not defined)
  68691. */
  68692. get glowLayer(): Nullable<GlowLayer>;
  68693. /**
  68694. * Enable or disable the chromaticAberration process from the pipeline
  68695. */
  68696. set chromaticAberrationEnabled(enabled: boolean);
  68697. get chromaticAberrationEnabled(): boolean;
  68698. /**
  68699. * Enable or disable the grain process from the pipeline
  68700. */
  68701. set grainEnabled(enabled: boolean);
  68702. get grainEnabled(): boolean;
  68703. /**
  68704. * @constructor
  68705. * @param name - The rendering pipeline name (default: "")
  68706. * @param hdr - If high dynamic range textures should be used (default: true)
  68707. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68708. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68709. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68710. */
  68711. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68712. /**
  68713. * Get the class name
  68714. * @returns "DefaultRenderingPipeline"
  68715. */
  68716. getClassName(): string;
  68717. /**
  68718. * Force the compilation of the entire pipeline.
  68719. */
  68720. prepare(): void;
  68721. private _hasCleared;
  68722. private _prevPostProcess;
  68723. private _prevPrevPostProcess;
  68724. private _setAutoClearAndTextureSharing;
  68725. private _depthOfFieldSceneObserver;
  68726. private _buildPipeline;
  68727. private _disposePostProcesses;
  68728. /**
  68729. * Adds a camera to the pipeline
  68730. * @param camera the camera to be added
  68731. */
  68732. addCamera(camera: Camera): void;
  68733. /**
  68734. * Removes a camera from the pipeline
  68735. * @param camera the camera to remove
  68736. */
  68737. removeCamera(camera: Camera): void;
  68738. /**
  68739. * Dispose of the pipeline and stop all post processes
  68740. */
  68741. dispose(): void;
  68742. /**
  68743. * Serialize the rendering pipeline (Used when exporting)
  68744. * @returns the serialized object
  68745. */
  68746. serialize(): any;
  68747. /**
  68748. * Parse the serialized pipeline
  68749. * @param source Source pipeline.
  68750. * @param scene The scene to load the pipeline to.
  68751. * @param rootUrl The URL of the serialized pipeline.
  68752. * @returns An instantiated pipeline from the serialized object.
  68753. */
  68754. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68755. }
  68756. }
  68757. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68758. /** @hidden */
  68759. export var lensHighlightsPixelShader: {
  68760. name: string;
  68761. shader: string;
  68762. };
  68763. }
  68764. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68765. /** @hidden */
  68766. export var depthOfFieldPixelShader: {
  68767. name: string;
  68768. shader: string;
  68769. };
  68770. }
  68771. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68772. import { Camera } from "babylonjs/Cameras/camera";
  68773. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68774. import { Scene } from "babylonjs/scene";
  68775. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68776. import "babylonjs/Shaders/chromaticAberration.fragment";
  68777. import "babylonjs/Shaders/lensHighlights.fragment";
  68778. import "babylonjs/Shaders/depthOfField.fragment";
  68779. /**
  68780. * BABYLON.JS Chromatic Aberration GLSL Shader
  68781. * Author: Olivier Guyot
  68782. * Separates very slightly R, G and B colors on the edges of the screen
  68783. * Inspired by Francois Tarlier & Martins Upitis
  68784. */
  68785. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68786. /**
  68787. * @ignore
  68788. * The chromatic aberration PostProcess id in the pipeline
  68789. */
  68790. LensChromaticAberrationEffect: string;
  68791. /**
  68792. * @ignore
  68793. * The highlights enhancing PostProcess id in the pipeline
  68794. */
  68795. HighlightsEnhancingEffect: string;
  68796. /**
  68797. * @ignore
  68798. * The depth-of-field PostProcess id in the pipeline
  68799. */
  68800. LensDepthOfFieldEffect: string;
  68801. private _scene;
  68802. private _depthTexture;
  68803. private _grainTexture;
  68804. private _chromaticAberrationPostProcess;
  68805. private _highlightsPostProcess;
  68806. private _depthOfFieldPostProcess;
  68807. private _edgeBlur;
  68808. private _grainAmount;
  68809. private _chromaticAberration;
  68810. private _distortion;
  68811. private _highlightsGain;
  68812. private _highlightsThreshold;
  68813. private _dofDistance;
  68814. private _dofAperture;
  68815. private _dofDarken;
  68816. private _dofPentagon;
  68817. private _blurNoise;
  68818. /**
  68819. * @constructor
  68820. *
  68821. * Effect parameters are as follow:
  68822. * {
  68823. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68824. * edge_blur: number; // from 0 to x (1 for realism)
  68825. * distortion: number; // from 0 to x (1 for realism)
  68826. * grain_amount: number; // from 0 to 1
  68827. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68828. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68829. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68830. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68831. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68832. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68833. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68834. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68835. * }
  68836. * Note: if an effect parameter is unset, effect is disabled
  68837. *
  68838. * @param name The rendering pipeline name
  68839. * @param parameters - An object containing all parameters (see above)
  68840. * @param scene The scene linked to this pipeline
  68841. * @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)
  68842. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68843. */
  68844. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68845. /**
  68846. * Get the class name
  68847. * @returns "LensRenderingPipeline"
  68848. */
  68849. getClassName(): string;
  68850. /**
  68851. * Gets associated scene
  68852. */
  68853. get scene(): Scene;
  68854. /**
  68855. * Gets or sets the edge blur
  68856. */
  68857. get edgeBlur(): number;
  68858. set edgeBlur(value: number);
  68859. /**
  68860. * Gets or sets the grain amount
  68861. */
  68862. get grainAmount(): number;
  68863. set grainAmount(value: number);
  68864. /**
  68865. * Gets or sets the chromatic aberration amount
  68866. */
  68867. get chromaticAberration(): number;
  68868. set chromaticAberration(value: number);
  68869. /**
  68870. * Gets or sets the depth of field aperture
  68871. */
  68872. get dofAperture(): number;
  68873. set dofAperture(value: number);
  68874. /**
  68875. * Gets or sets the edge distortion
  68876. */
  68877. get edgeDistortion(): number;
  68878. set edgeDistortion(value: number);
  68879. /**
  68880. * Gets or sets the depth of field distortion
  68881. */
  68882. get dofDistortion(): number;
  68883. set dofDistortion(value: number);
  68884. /**
  68885. * Gets or sets the darken out of focus amount
  68886. */
  68887. get darkenOutOfFocus(): number;
  68888. set darkenOutOfFocus(value: number);
  68889. /**
  68890. * Gets or sets a boolean indicating if blur noise is enabled
  68891. */
  68892. get blurNoise(): boolean;
  68893. set blurNoise(value: boolean);
  68894. /**
  68895. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68896. */
  68897. get pentagonBokeh(): boolean;
  68898. set pentagonBokeh(value: boolean);
  68899. /**
  68900. * Gets or sets the highlight grain amount
  68901. */
  68902. get highlightsGain(): number;
  68903. set highlightsGain(value: number);
  68904. /**
  68905. * Gets or sets the highlight threshold
  68906. */
  68907. get highlightsThreshold(): number;
  68908. set highlightsThreshold(value: number);
  68909. /**
  68910. * Sets the amount of blur at the edges
  68911. * @param amount blur amount
  68912. */
  68913. setEdgeBlur(amount: number): void;
  68914. /**
  68915. * Sets edge blur to 0
  68916. */
  68917. disableEdgeBlur(): void;
  68918. /**
  68919. * Sets the amout of grain
  68920. * @param amount Amount of grain
  68921. */
  68922. setGrainAmount(amount: number): void;
  68923. /**
  68924. * Set grain amount to 0
  68925. */
  68926. disableGrain(): void;
  68927. /**
  68928. * Sets the chromatic aberration amount
  68929. * @param amount amount of chromatic aberration
  68930. */
  68931. setChromaticAberration(amount: number): void;
  68932. /**
  68933. * Sets chromatic aberration amount to 0
  68934. */
  68935. disableChromaticAberration(): void;
  68936. /**
  68937. * Sets the EdgeDistortion amount
  68938. * @param amount amount of EdgeDistortion
  68939. */
  68940. setEdgeDistortion(amount: number): void;
  68941. /**
  68942. * Sets edge distortion to 0
  68943. */
  68944. disableEdgeDistortion(): void;
  68945. /**
  68946. * Sets the FocusDistance amount
  68947. * @param amount amount of FocusDistance
  68948. */
  68949. setFocusDistance(amount: number): void;
  68950. /**
  68951. * Disables depth of field
  68952. */
  68953. disableDepthOfField(): void;
  68954. /**
  68955. * Sets the Aperture amount
  68956. * @param amount amount of Aperture
  68957. */
  68958. setAperture(amount: number): void;
  68959. /**
  68960. * Sets the DarkenOutOfFocus amount
  68961. * @param amount amount of DarkenOutOfFocus
  68962. */
  68963. setDarkenOutOfFocus(amount: number): void;
  68964. private _pentagonBokehIsEnabled;
  68965. /**
  68966. * Creates a pentagon bokeh effect
  68967. */
  68968. enablePentagonBokeh(): void;
  68969. /**
  68970. * Disables the pentagon bokeh effect
  68971. */
  68972. disablePentagonBokeh(): void;
  68973. /**
  68974. * Enables noise blur
  68975. */
  68976. enableNoiseBlur(): void;
  68977. /**
  68978. * Disables noise blur
  68979. */
  68980. disableNoiseBlur(): void;
  68981. /**
  68982. * Sets the HighlightsGain amount
  68983. * @param amount amount of HighlightsGain
  68984. */
  68985. setHighlightsGain(amount: number): void;
  68986. /**
  68987. * Sets the HighlightsThreshold amount
  68988. * @param amount amount of HighlightsThreshold
  68989. */
  68990. setHighlightsThreshold(amount: number): void;
  68991. /**
  68992. * Disables highlights
  68993. */
  68994. disableHighlights(): void;
  68995. /**
  68996. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68997. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68998. */
  68999. dispose(disableDepthRender?: boolean): void;
  69000. private _createChromaticAberrationPostProcess;
  69001. private _createHighlightsPostProcess;
  69002. private _createDepthOfFieldPostProcess;
  69003. private _createGrainTexture;
  69004. }
  69005. }
  69006. declare module "babylonjs/Shaders/ssao2.fragment" {
  69007. /** @hidden */
  69008. export var ssao2PixelShader: {
  69009. name: string;
  69010. shader: string;
  69011. };
  69012. }
  69013. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69014. /** @hidden */
  69015. export var ssaoCombinePixelShader: {
  69016. name: string;
  69017. shader: string;
  69018. };
  69019. }
  69020. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69021. import { Camera } from "babylonjs/Cameras/camera";
  69022. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69023. import { Scene } from "babylonjs/scene";
  69024. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69025. import "babylonjs/Shaders/ssao2.fragment";
  69026. import "babylonjs/Shaders/ssaoCombine.fragment";
  69027. /**
  69028. * Render pipeline to produce ssao effect
  69029. */
  69030. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69031. /**
  69032. * @ignore
  69033. * The PassPostProcess id in the pipeline that contains the original scene color
  69034. */
  69035. SSAOOriginalSceneColorEffect: string;
  69036. /**
  69037. * @ignore
  69038. * The SSAO PostProcess id in the pipeline
  69039. */
  69040. SSAORenderEffect: string;
  69041. /**
  69042. * @ignore
  69043. * The horizontal blur PostProcess id in the pipeline
  69044. */
  69045. SSAOBlurHRenderEffect: string;
  69046. /**
  69047. * @ignore
  69048. * The vertical blur PostProcess id in the pipeline
  69049. */
  69050. SSAOBlurVRenderEffect: string;
  69051. /**
  69052. * @ignore
  69053. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69054. */
  69055. SSAOCombineRenderEffect: string;
  69056. /**
  69057. * The output strength of the SSAO post-process. Default value is 1.0.
  69058. */
  69059. totalStrength: number;
  69060. /**
  69061. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69062. */
  69063. maxZ: number;
  69064. /**
  69065. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69066. */
  69067. minZAspect: number;
  69068. private _samples;
  69069. /**
  69070. * Number of samples used for the SSAO calculations. Default value is 8
  69071. */
  69072. set samples(n: number);
  69073. get samples(): number;
  69074. private _textureSamples;
  69075. /**
  69076. * Number of samples to use for antialiasing
  69077. */
  69078. set textureSamples(n: number);
  69079. get textureSamples(): number;
  69080. /**
  69081. * Ratio object used for SSAO ratio and blur ratio
  69082. */
  69083. private _ratio;
  69084. /**
  69085. * Dynamically generated sphere sampler.
  69086. */
  69087. private _sampleSphere;
  69088. /**
  69089. * Blur filter offsets
  69090. */
  69091. private _samplerOffsets;
  69092. private _expensiveBlur;
  69093. /**
  69094. * If bilateral blur should be used
  69095. */
  69096. set expensiveBlur(b: boolean);
  69097. get expensiveBlur(): boolean;
  69098. /**
  69099. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69100. */
  69101. radius: number;
  69102. /**
  69103. * The base color of the SSAO post-process
  69104. * The final result is "base + ssao" between [0, 1]
  69105. */
  69106. base: number;
  69107. /**
  69108. * Support test.
  69109. */
  69110. static get IsSupported(): boolean;
  69111. private _scene;
  69112. private _depthTexture;
  69113. private _normalTexture;
  69114. private _randomTexture;
  69115. private _originalColorPostProcess;
  69116. private _ssaoPostProcess;
  69117. private _blurHPostProcess;
  69118. private _blurVPostProcess;
  69119. private _ssaoCombinePostProcess;
  69120. /**
  69121. * Gets active scene
  69122. */
  69123. get scene(): Scene;
  69124. /**
  69125. * @constructor
  69126. * @param name The rendering pipeline name
  69127. * @param scene The scene linked to this pipeline
  69128. * @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 }
  69129. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69130. */
  69131. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69132. /**
  69133. * Get the class name
  69134. * @returns "SSAO2RenderingPipeline"
  69135. */
  69136. getClassName(): string;
  69137. /**
  69138. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69139. */
  69140. dispose(disableGeometryBufferRenderer?: boolean): void;
  69141. private _createBlurPostProcess;
  69142. /** @hidden */
  69143. _rebuild(): void;
  69144. private _bits;
  69145. private _radicalInverse_VdC;
  69146. private _hammersley;
  69147. private _hemisphereSample_uniform;
  69148. private _generateHemisphere;
  69149. private _createSSAOPostProcess;
  69150. private _createSSAOCombinePostProcess;
  69151. private _createRandomTexture;
  69152. /**
  69153. * Serialize the rendering pipeline (Used when exporting)
  69154. * @returns the serialized object
  69155. */
  69156. serialize(): any;
  69157. /**
  69158. * Parse the serialized pipeline
  69159. * @param source Source pipeline.
  69160. * @param scene The scene to load the pipeline to.
  69161. * @param rootUrl The URL of the serialized pipeline.
  69162. * @returns An instantiated pipeline from the serialized object.
  69163. */
  69164. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69165. }
  69166. }
  69167. declare module "babylonjs/Shaders/ssao.fragment" {
  69168. /** @hidden */
  69169. export var ssaoPixelShader: {
  69170. name: string;
  69171. shader: string;
  69172. };
  69173. }
  69174. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69175. import { Camera } from "babylonjs/Cameras/camera";
  69176. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69177. import { Scene } from "babylonjs/scene";
  69178. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69179. import "babylonjs/Shaders/ssao.fragment";
  69180. import "babylonjs/Shaders/ssaoCombine.fragment";
  69181. /**
  69182. * Render pipeline to produce ssao effect
  69183. */
  69184. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69185. /**
  69186. * @ignore
  69187. * The PassPostProcess id in the pipeline that contains the original scene color
  69188. */
  69189. SSAOOriginalSceneColorEffect: string;
  69190. /**
  69191. * @ignore
  69192. * The SSAO PostProcess id in the pipeline
  69193. */
  69194. SSAORenderEffect: string;
  69195. /**
  69196. * @ignore
  69197. * The horizontal blur PostProcess id in the pipeline
  69198. */
  69199. SSAOBlurHRenderEffect: string;
  69200. /**
  69201. * @ignore
  69202. * The vertical blur PostProcess id in the pipeline
  69203. */
  69204. SSAOBlurVRenderEffect: string;
  69205. /**
  69206. * @ignore
  69207. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69208. */
  69209. SSAOCombineRenderEffect: string;
  69210. /**
  69211. * The output strength of the SSAO post-process. Default value is 1.0.
  69212. */
  69213. totalStrength: number;
  69214. /**
  69215. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69216. */
  69217. radius: number;
  69218. /**
  69219. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69220. * Must not be equal to fallOff and superior to fallOff.
  69221. * Default value is 0.0075
  69222. */
  69223. area: number;
  69224. /**
  69225. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69226. * Must not be equal to area and inferior to area.
  69227. * Default value is 0.000001
  69228. */
  69229. fallOff: number;
  69230. /**
  69231. * The base color of the SSAO post-process
  69232. * The final result is "base + ssao" between [0, 1]
  69233. */
  69234. base: number;
  69235. private _scene;
  69236. private _depthTexture;
  69237. private _randomTexture;
  69238. private _originalColorPostProcess;
  69239. private _ssaoPostProcess;
  69240. private _blurHPostProcess;
  69241. private _blurVPostProcess;
  69242. private _ssaoCombinePostProcess;
  69243. private _firstUpdate;
  69244. /**
  69245. * Gets active scene
  69246. */
  69247. get scene(): Scene;
  69248. /**
  69249. * @constructor
  69250. * @param name - The rendering pipeline name
  69251. * @param scene - The scene linked to this pipeline
  69252. * @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 }
  69253. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69254. */
  69255. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69256. /**
  69257. * Get the class name
  69258. * @returns "SSAORenderingPipeline"
  69259. */
  69260. getClassName(): string;
  69261. /**
  69262. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69263. */
  69264. dispose(disableDepthRender?: boolean): void;
  69265. private _createBlurPostProcess;
  69266. /** @hidden */
  69267. _rebuild(): void;
  69268. private _createSSAOPostProcess;
  69269. private _createSSAOCombinePostProcess;
  69270. private _createRandomTexture;
  69271. }
  69272. }
  69273. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69274. /** @hidden */
  69275. export var screenSpaceReflectionPixelShader: {
  69276. name: string;
  69277. shader: string;
  69278. };
  69279. }
  69280. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69281. import { Nullable } from "babylonjs/types";
  69282. import { Camera } from "babylonjs/Cameras/camera";
  69283. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69284. import { Scene } from "babylonjs/scene";
  69285. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69286. import { Engine } from "babylonjs/Engines/engine";
  69287. /**
  69288. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69289. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69290. */
  69291. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69292. /**
  69293. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69294. */
  69295. threshold: number;
  69296. /**
  69297. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69298. */
  69299. strength: number;
  69300. /**
  69301. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69302. */
  69303. reflectionSpecularFalloffExponent: number;
  69304. /**
  69305. * 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]
  69306. */
  69307. step: number;
  69308. /**
  69309. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69310. */
  69311. roughnessFactor: number;
  69312. private _geometryBufferRenderer;
  69313. private _enableSmoothReflections;
  69314. private _reflectionSamples;
  69315. private _smoothSteps;
  69316. /**
  69317. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69318. * @param name The name of the effect.
  69319. * @param scene The scene containing the objects to calculate reflections.
  69320. * @param options The required width/height ratio to downsize to before computing the render pass.
  69321. * @param camera The camera to apply the render pass to.
  69322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69323. * @param engine The engine which the post process will be applied. (default: current engine)
  69324. * @param reusable If the post process can be reused on the same frame. (default: false)
  69325. * @param textureType Type of textures used when performing the post process. (default: 0)
  69326. * @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)
  69327. */
  69328. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69329. /**
  69330. * Gets wether or not smoothing reflections is enabled.
  69331. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69332. */
  69333. get enableSmoothReflections(): boolean;
  69334. /**
  69335. * Sets wether or not smoothing reflections is enabled.
  69336. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69337. */
  69338. set enableSmoothReflections(enabled: boolean);
  69339. /**
  69340. * Gets the number of samples taken while computing reflections. More samples count is high,
  69341. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69342. */
  69343. get reflectionSamples(): number;
  69344. /**
  69345. * Sets the number of samples taken while computing reflections. More samples count is high,
  69346. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69347. */
  69348. set reflectionSamples(samples: number);
  69349. /**
  69350. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69351. * more the post-process will require GPU power and can generate a drop in FPS.
  69352. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69353. */
  69354. get smoothSteps(): number;
  69355. set smoothSteps(steps: number);
  69356. private _updateEffectDefines;
  69357. }
  69358. }
  69359. declare module "babylonjs/Shaders/standard.fragment" {
  69360. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69361. /** @hidden */
  69362. export var standardPixelShader: {
  69363. name: string;
  69364. shader: string;
  69365. };
  69366. }
  69367. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69368. import { Nullable } from "babylonjs/types";
  69369. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69370. import { Camera } from "babylonjs/Cameras/camera";
  69371. import { Texture } from "babylonjs/Materials/Textures/texture";
  69372. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69373. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69374. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69375. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69376. import { IDisposable } from "babylonjs/scene";
  69377. import { SpotLight } from "babylonjs/Lights/spotLight";
  69378. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69379. import { Scene } from "babylonjs/scene";
  69380. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69381. import { Animation } from "babylonjs/Animations/animation";
  69382. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69383. import "babylonjs/Shaders/standard.fragment";
  69384. /**
  69385. * Standard rendering pipeline
  69386. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69387. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69388. */
  69389. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69390. /**
  69391. * Public members
  69392. */
  69393. /**
  69394. * Post-process which contains the original scene color before the pipeline applies all the effects
  69395. */
  69396. originalPostProcess: Nullable<PostProcess>;
  69397. /**
  69398. * Post-process used to down scale an image x4
  69399. */
  69400. downSampleX4PostProcess: Nullable<PostProcess>;
  69401. /**
  69402. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69403. */
  69404. brightPassPostProcess: Nullable<PostProcess>;
  69405. /**
  69406. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69407. */
  69408. blurHPostProcesses: PostProcess[];
  69409. /**
  69410. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69411. */
  69412. blurVPostProcesses: PostProcess[];
  69413. /**
  69414. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69415. */
  69416. textureAdderPostProcess: Nullable<PostProcess>;
  69417. /**
  69418. * Post-process used to create volumetric lighting effect
  69419. */
  69420. volumetricLightPostProcess: Nullable<PostProcess>;
  69421. /**
  69422. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69423. */
  69424. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69425. /**
  69426. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69427. */
  69428. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69429. /**
  69430. * Post-process used to merge the volumetric light effect and the real scene color
  69431. */
  69432. volumetricLightMergePostProces: Nullable<PostProcess>;
  69433. /**
  69434. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69435. */
  69436. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69437. /**
  69438. * Base post-process used to calculate the average luminance of the final image for HDR
  69439. */
  69440. luminancePostProcess: Nullable<PostProcess>;
  69441. /**
  69442. * Post-processes used to create down sample post-processes in order to get
  69443. * the average luminance of the final image for HDR
  69444. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69445. */
  69446. luminanceDownSamplePostProcesses: PostProcess[];
  69447. /**
  69448. * Post-process used to create a HDR effect (light adaptation)
  69449. */
  69450. hdrPostProcess: Nullable<PostProcess>;
  69451. /**
  69452. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69453. */
  69454. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69455. /**
  69456. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69457. */
  69458. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69459. /**
  69460. * Post-process used to merge the final HDR post-process and the real scene color
  69461. */
  69462. hdrFinalPostProcess: Nullable<PostProcess>;
  69463. /**
  69464. * Post-process used to create a lens flare effect
  69465. */
  69466. lensFlarePostProcess: Nullable<PostProcess>;
  69467. /**
  69468. * Post-process that merges the result of the lens flare post-process and the real scene color
  69469. */
  69470. lensFlareComposePostProcess: Nullable<PostProcess>;
  69471. /**
  69472. * Post-process used to create a motion blur effect
  69473. */
  69474. motionBlurPostProcess: Nullable<PostProcess>;
  69475. /**
  69476. * Post-process used to create a depth of field effect
  69477. */
  69478. depthOfFieldPostProcess: Nullable<PostProcess>;
  69479. /**
  69480. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69481. */
  69482. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69483. /**
  69484. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69485. */
  69486. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69487. /**
  69488. * Represents the brightness threshold in order to configure the illuminated surfaces
  69489. */
  69490. brightThreshold: number;
  69491. /**
  69492. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69493. */
  69494. blurWidth: number;
  69495. /**
  69496. * Sets if the blur for highlighted surfaces must be only horizontal
  69497. */
  69498. horizontalBlur: boolean;
  69499. /**
  69500. * Gets the overall exposure used by the pipeline
  69501. */
  69502. get exposure(): number;
  69503. /**
  69504. * Sets the overall exposure used by the pipeline
  69505. */
  69506. set exposure(value: number);
  69507. /**
  69508. * Texture used typically to simulate "dirty" on camera lens
  69509. */
  69510. lensTexture: Nullable<Texture>;
  69511. /**
  69512. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69513. */
  69514. volumetricLightCoefficient: number;
  69515. /**
  69516. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69517. */
  69518. volumetricLightPower: number;
  69519. /**
  69520. * Used the set the blur intensity to smooth the volumetric lights
  69521. */
  69522. volumetricLightBlurScale: number;
  69523. /**
  69524. * Light (spot or directional) used to generate the volumetric lights rays
  69525. * The source light must have a shadow generate so the pipeline can get its
  69526. * depth map
  69527. */
  69528. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69529. /**
  69530. * For eye adaptation, represents the minimum luminance the eye can see
  69531. */
  69532. hdrMinimumLuminance: number;
  69533. /**
  69534. * For eye adaptation, represents the decrease luminance speed
  69535. */
  69536. hdrDecreaseRate: number;
  69537. /**
  69538. * For eye adaptation, represents the increase luminance speed
  69539. */
  69540. hdrIncreaseRate: number;
  69541. /**
  69542. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69543. */
  69544. get hdrAutoExposure(): boolean;
  69545. /**
  69546. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69547. */
  69548. set hdrAutoExposure(value: boolean);
  69549. /**
  69550. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69551. */
  69552. lensColorTexture: Nullable<Texture>;
  69553. /**
  69554. * The overall strengh for the lens flare effect
  69555. */
  69556. lensFlareStrength: number;
  69557. /**
  69558. * Dispersion coefficient for lens flare ghosts
  69559. */
  69560. lensFlareGhostDispersal: number;
  69561. /**
  69562. * Main lens flare halo width
  69563. */
  69564. lensFlareHaloWidth: number;
  69565. /**
  69566. * Based on the lens distortion effect, defines how much the lens flare result
  69567. * is distorted
  69568. */
  69569. lensFlareDistortionStrength: number;
  69570. /**
  69571. * Configures the blur intensity used for for lens flare (halo)
  69572. */
  69573. lensFlareBlurWidth: number;
  69574. /**
  69575. * Lens star texture must be used to simulate rays on the flares and is available
  69576. * in the documentation
  69577. */
  69578. lensStarTexture: Nullable<Texture>;
  69579. /**
  69580. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69581. * flare effect by taking account of the dirt texture
  69582. */
  69583. lensFlareDirtTexture: Nullable<Texture>;
  69584. /**
  69585. * Represents the focal length for the depth of field effect
  69586. */
  69587. depthOfFieldDistance: number;
  69588. /**
  69589. * Represents the blur intensity for the blurred part of the depth of field effect
  69590. */
  69591. depthOfFieldBlurWidth: number;
  69592. /**
  69593. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69594. */
  69595. get motionStrength(): number;
  69596. /**
  69597. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69598. */
  69599. set motionStrength(strength: number);
  69600. /**
  69601. * Gets wether or not the motion blur post-process is object based or screen based.
  69602. */
  69603. get objectBasedMotionBlur(): boolean;
  69604. /**
  69605. * Sets wether or not the motion blur post-process should be object based or screen based
  69606. */
  69607. set objectBasedMotionBlur(value: boolean);
  69608. /**
  69609. * List of animations for the pipeline (IAnimatable implementation)
  69610. */
  69611. animations: Animation[];
  69612. /**
  69613. * Private members
  69614. */
  69615. private _scene;
  69616. private _currentDepthOfFieldSource;
  69617. private _basePostProcess;
  69618. private _fixedExposure;
  69619. private _currentExposure;
  69620. private _hdrAutoExposure;
  69621. private _hdrCurrentLuminance;
  69622. private _motionStrength;
  69623. private _isObjectBasedMotionBlur;
  69624. private _floatTextureType;
  69625. private _camerasToBeAttached;
  69626. private _ratio;
  69627. private _bloomEnabled;
  69628. private _depthOfFieldEnabled;
  69629. private _vlsEnabled;
  69630. private _lensFlareEnabled;
  69631. private _hdrEnabled;
  69632. private _motionBlurEnabled;
  69633. private _fxaaEnabled;
  69634. private _screenSpaceReflectionsEnabled;
  69635. private _motionBlurSamples;
  69636. private _volumetricLightStepsCount;
  69637. private _samples;
  69638. /**
  69639. * @ignore
  69640. * Specifies if the bloom pipeline is enabled
  69641. */
  69642. get BloomEnabled(): boolean;
  69643. set BloomEnabled(enabled: boolean);
  69644. /**
  69645. * @ignore
  69646. * Specifies if the depth of field pipeline is enabed
  69647. */
  69648. get DepthOfFieldEnabled(): boolean;
  69649. set DepthOfFieldEnabled(enabled: boolean);
  69650. /**
  69651. * @ignore
  69652. * Specifies if the lens flare pipeline is enabed
  69653. */
  69654. get LensFlareEnabled(): boolean;
  69655. set LensFlareEnabled(enabled: boolean);
  69656. /**
  69657. * @ignore
  69658. * Specifies if the HDR pipeline is enabled
  69659. */
  69660. get HDREnabled(): boolean;
  69661. set HDREnabled(enabled: boolean);
  69662. /**
  69663. * @ignore
  69664. * Specifies if the volumetric lights scattering effect is enabled
  69665. */
  69666. get VLSEnabled(): boolean;
  69667. set VLSEnabled(enabled: boolean);
  69668. /**
  69669. * @ignore
  69670. * Specifies if the motion blur effect is enabled
  69671. */
  69672. get MotionBlurEnabled(): boolean;
  69673. set MotionBlurEnabled(enabled: boolean);
  69674. /**
  69675. * Specifies if anti-aliasing is enabled
  69676. */
  69677. get fxaaEnabled(): boolean;
  69678. set fxaaEnabled(enabled: boolean);
  69679. /**
  69680. * Specifies if screen space reflections are enabled.
  69681. */
  69682. get screenSpaceReflectionsEnabled(): boolean;
  69683. set screenSpaceReflectionsEnabled(enabled: boolean);
  69684. /**
  69685. * Specifies the number of steps used to calculate the volumetric lights
  69686. * Typically in interval [50, 200]
  69687. */
  69688. get volumetricLightStepsCount(): number;
  69689. set volumetricLightStepsCount(count: number);
  69690. /**
  69691. * Specifies the number of samples used for the motion blur effect
  69692. * Typically in interval [16, 64]
  69693. */
  69694. get motionBlurSamples(): number;
  69695. set motionBlurSamples(samples: number);
  69696. /**
  69697. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69698. */
  69699. get samples(): number;
  69700. set samples(sampleCount: number);
  69701. /**
  69702. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69703. * @constructor
  69704. * @param name The rendering pipeline name
  69705. * @param scene The scene linked to this pipeline
  69706. * @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)
  69707. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69708. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69709. */
  69710. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69711. private _buildPipeline;
  69712. private _createDownSampleX4PostProcess;
  69713. private _createBrightPassPostProcess;
  69714. private _createBlurPostProcesses;
  69715. private _createTextureAdderPostProcess;
  69716. private _createVolumetricLightPostProcess;
  69717. private _createLuminancePostProcesses;
  69718. private _createHdrPostProcess;
  69719. private _createLensFlarePostProcess;
  69720. private _createDepthOfFieldPostProcess;
  69721. private _createMotionBlurPostProcess;
  69722. private _getDepthTexture;
  69723. private _disposePostProcesses;
  69724. /**
  69725. * Dispose of the pipeline and stop all post processes
  69726. */
  69727. dispose(): void;
  69728. /**
  69729. * Serialize the rendering pipeline (Used when exporting)
  69730. * @returns the serialized object
  69731. */
  69732. serialize(): any;
  69733. /**
  69734. * Parse the serialized pipeline
  69735. * @param source Source pipeline.
  69736. * @param scene The scene to load the pipeline to.
  69737. * @param rootUrl The URL of the serialized pipeline.
  69738. * @returns An instantiated pipeline from the serialized object.
  69739. */
  69740. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69741. /**
  69742. * Luminance steps
  69743. */
  69744. static LuminanceSteps: number;
  69745. }
  69746. }
  69747. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69748. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69749. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69750. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69751. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69752. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69753. }
  69754. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69755. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69756. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69757. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69758. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69759. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69760. }
  69761. declare module "babylonjs/Shaders/tonemap.fragment" {
  69762. /** @hidden */
  69763. export var tonemapPixelShader: {
  69764. name: string;
  69765. shader: string;
  69766. };
  69767. }
  69768. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69769. import { Camera } from "babylonjs/Cameras/camera";
  69770. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69771. import "babylonjs/Shaders/tonemap.fragment";
  69772. import { Engine } from "babylonjs/Engines/engine";
  69773. /** Defines operator used for tonemapping */
  69774. export enum TonemappingOperator {
  69775. /** Hable */
  69776. Hable = 0,
  69777. /** Reinhard */
  69778. Reinhard = 1,
  69779. /** HejiDawson */
  69780. HejiDawson = 2,
  69781. /** Photographic */
  69782. Photographic = 3
  69783. }
  69784. /**
  69785. * Defines a post process to apply tone mapping
  69786. */
  69787. export class TonemapPostProcess extends PostProcess {
  69788. private _operator;
  69789. /** Defines the required exposure adjustement */
  69790. exposureAdjustment: number;
  69791. /**
  69792. * Creates a new TonemapPostProcess
  69793. * @param name defines the name of the postprocess
  69794. * @param _operator defines the operator to use
  69795. * @param exposureAdjustment defines the required exposure adjustement
  69796. * @param camera defines the camera to use (can be null)
  69797. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69798. * @param engine defines the hosting engine (can be ignore if camera is set)
  69799. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69800. */
  69801. constructor(name: string, _operator: TonemappingOperator,
  69802. /** Defines the required exposure adjustement */
  69803. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69804. }
  69805. }
  69806. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69807. /** @hidden */
  69808. export var volumetricLightScatteringPixelShader: {
  69809. name: string;
  69810. shader: string;
  69811. };
  69812. }
  69813. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69814. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69815. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69816. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69817. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69818. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69819. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69820. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69821. /** @hidden */
  69822. export var volumetricLightScatteringPassVertexShader: {
  69823. name: string;
  69824. shader: string;
  69825. };
  69826. }
  69827. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69828. /** @hidden */
  69829. export var volumetricLightScatteringPassPixelShader: {
  69830. name: string;
  69831. shader: string;
  69832. };
  69833. }
  69834. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69835. import { Vector3 } from "babylonjs/Maths/math.vector";
  69836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69837. import { Mesh } from "babylonjs/Meshes/mesh";
  69838. import { Camera } from "babylonjs/Cameras/camera";
  69839. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69840. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69841. import { Scene } from "babylonjs/scene";
  69842. import "babylonjs/Meshes/Builders/planeBuilder";
  69843. import "babylonjs/Shaders/depth.vertex";
  69844. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69845. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69846. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69847. import { Engine } from "babylonjs/Engines/engine";
  69848. /**
  69849. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69850. */
  69851. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69852. private _volumetricLightScatteringPass;
  69853. private _volumetricLightScatteringRTT;
  69854. private _viewPort;
  69855. private _screenCoordinates;
  69856. private _cachedDefines;
  69857. /**
  69858. * If not undefined, the mesh position is computed from the attached node position
  69859. */
  69860. attachedNode: {
  69861. position: Vector3;
  69862. };
  69863. /**
  69864. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69865. */
  69866. customMeshPosition: Vector3;
  69867. /**
  69868. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69869. */
  69870. useCustomMeshPosition: boolean;
  69871. /**
  69872. * If the post-process should inverse the light scattering direction
  69873. */
  69874. invert: boolean;
  69875. /**
  69876. * The internal mesh used by the post-process
  69877. */
  69878. mesh: Mesh;
  69879. /**
  69880. * @hidden
  69881. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69882. */
  69883. get useDiffuseColor(): boolean;
  69884. set useDiffuseColor(useDiffuseColor: boolean);
  69885. /**
  69886. * Array containing the excluded meshes not rendered in the internal pass
  69887. */
  69888. excludedMeshes: AbstractMesh[];
  69889. /**
  69890. * Controls the overall intensity of the post-process
  69891. */
  69892. exposure: number;
  69893. /**
  69894. * Dissipates each sample's contribution in range [0, 1]
  69895. */
  69896. decay: number;
  69897. /**
  69898. * Controls the overall intensity of each sample
  69899. */
  69900. weight: number;
  69901. /**
  69902. * Controls the density of each sample
  69903. */
  69904. density: number;
  69905. /**
  69906. * @constructor
  69907. * @param name The post-process name
  69908. * @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)
  69909. * @param camera The camera that the post-process will be attached to
  69910. * @param mesh The mesh used to create the light scattering
  69911. * @param samples The post-process quality, default 100
  69912. * @param samplingModeThe post-process filtering mode
  69913. * @param engine The babylon engine
  69914. * @param reusable If the post-process is reusable
  69915. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69916. */
  69917. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69918. /**
  69919. * Returns the string "VolumetricLightScatteringPostProcess"
  69920. * @returns "VolumetricLightScatteringPostProcess"
  69921. */
  69922. getClassName(): string;
  69923. private _isReady;
  69924. /**
  69925. * Sets the new light position for light scattering effect
  69926. * @param position The new custom light position
  69927. */
  69928. setCustomMeshPosition(position: Vector3): void;
  69929. /**
  69930. * Returns the light position for light scattering effect
  69931. * @return Vector3 The custom light position
  69932. */
  69933. getCustomMeshPosition(): Vector3;
  69934. /**
  69935. * Disposes the internal assets and detaches the post-process from the camera
  69936. */
  69937. dispose(camera: Camera): void;
  69938. /**
  69939. * Returns the render target texture used by the post-process
  69940. * @return the render target texture used by the post-process
  69941. */
  69942. getPass(): RenderTargetTexture;
  69943. private _meshExcluded;
  69944. private _createPass;
  69945. private _updateMeshScreenCoordinates;
  69946. /**
  69947. * Creates a default mesh for the Volumeric Light Scattering post-process
  69948. * @param name The mesh name
  69949. * @param scene The scene where to create the mesh
  69950. * @return the default mesh
  69951. */
  69952. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69953. }
  69954. }
  69955. declare module "babylonjs/PostProcesses/index" {
  69956. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69957. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69958. export * from "babylonjs/PostProcesses/bloomEffect";
  69959. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69960. export * from "babylonjs/PostProcesses/blurPostProcess";
  69961. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69962. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69963. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69964. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69965. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69966. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69967. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69968. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69969. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69970. export * from "babylonjs/PostProcesses/filterPostProcess";
  69971. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69972. export * from "babylonjs/PostProcesses/grainPostProcess";
  69973. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69974. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69975. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69976. export * from "babylonjs/PostProcesses/passPostProcess";
  69977. export * from "babylonjs/PostProcesses/postProcess";
  69978. export * from "babylonjs/PostProcesses/postProcessManager";
  69979. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69980. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69981. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69982. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69983. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69984. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69985. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69986. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69987. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69988. }
  69989. declare module "babylonjs/Probes/index" {
  69990. export * from "babylonjs/Probes/reflectionProbe";
  69991. }
  69992. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69993. import { Scene } from "babylonjs/scene";
  69994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69995. import { SmartArray } from "babylonjs/Misc/smartArray";
  69996. import { ISceneComponent } from "babylonjs/sceneComponent";
  69997. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69998. import "babylonjs/Meshes/Builders/boxBuilder";
  69999. import "babylonjs/Shaders/color.fragment";
  70000. import "babylonjs/Shaders/color.vertex";
  70001. import { Color3 } from "babylonjs/Maths/math.color";
  70002. module "babylonjs/scene" {
  70003. interface Scene {
  70004. /** @hidden (Backing field) */
  70005. _boundingBoxRenderer: BoundingBoxRenderer;
  70006. /** @hidden (Backing field) */
  70007. _forceShowBoundingBoxes: boolean;
  70008. /**
  70009. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70010. */
  70011. forceShowBoundingBoxes: boolean;
  70012. /**
  70013. * Gets the bounding box renderer associated with the scene
  70014. * @returns a BoundingBoxRenderer
  70015. */
  70016. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70017. }
  70018. }
  70019. module "babylonjs/Meshes/abstractMesh" {
  70020. interface AbstractMesh {
  70021. /** @hidden (Backing field) */
  70022. _showBoundingBox: boolean;
  70023. /**
  70024. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70025. */
  70026. showBoundingBox: boolean;
  70027. }
  70028. }
  70029. /**
  70030. * Component responsible of rendering the bounding box of the meshes in a scene.
  70031. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70032. */
  70033. export class BoundingBoxRenderer implements ISceneComponent {
  70034. /**
  70035. * The component name helpfull to identify the component in the list of scene components.
  70036. */
  70037. readonly name: string;
  70038. /**
  70039. * The scene the component belongs to.
  70040. */
  70041. scene: Scene;
  70042. /**
  70043. * Color of the bounding box lines placed in front of an object
  70044. */
  70045. frontColor: Color3;
  70046. /**
  70047. * Color of the bounding box lines placed behind an object
  70048. */
  70049. backColor: Color3;
  70050. /**
  70051. * Defines if the renderer should show the back lines or not
  70052. */
  70053. showBackLines: boolean;
  70054. /**
  70055. * @hidden
  70056. */
  70057. renderList: SmartArray<BoundingBox>;
  70058. private _colorShader;
  70059. private _vertexBuffers;
  70060. private _indexBuffer;
  70061. private _fillIndexBuffer;
  70062. private _fillIndexData;
  70063. /**
  70064. * Instantiates a new bounding box renderer in a scene.
  70065. * @param scene the scene the renderer renders in
  70066. */
  70067. constructor(scene: Scene);
  70068. /**
  70069. * Registers the component in a given scene
  70070. */
  70071. register(): void;
  70072. private _evaluateSubMesh;
  70073. private _activeMesh;
  70074. private _prepareRessources;
  70075. private _createIndexBuffer;
  70076. /**
  70077. * Rebuilds the elements related to this component in case of
  70078. * context lost for instance.
  70079. */
  70080. rebuild(): void;
  70081. /**
  70082. * @hidden
  70083. */
  70084. reset(): void;
  70085. /**
  70086. * Render the bounding boxes of a specific rendering group
  70087. * @param renderingGroupId defines the rendering group to render
  70088. */
  70089. render(renderingGroupId: number): void;
  70090. /**
  70091. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70092. * @param mesh Define the mesh to render the occlusion bounding box for
  70093. */
  70094. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70095. /**
  70096. * Dispose and release the resources attached to this renderer.
  70097. */
  70098. dispose(): void;
  70099. }
  70100. }
  70101. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70102. import { Nullable } from "babylonjs/types";
  70103. import { Scene } from "babylonjs/scene";
  70104. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70105. import { Camera } from "babylonjs/Cameras/camera";
  70106. import { ISceneComponent } from "babylonjs/sceneComponent";
  70107. module "babylonjs/scene" {
  70108. interface Scene {
  70109. /** @hidden (Backing field) */
  70110. _depthRenderer: {
  70111. [id: string]: DepthRenderer;
  70112. };
  70113. /**
  70114. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70115. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70116. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70117. * @returns the created depth renderer
  70118. */
  70119. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70120. /**
  70121. * Disables a depth renderer for a given camera
  70122. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70123. */
  70124. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70125. }
  70126. }
  70127. /**
  70128. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70129. * in several rendering techniques.
  70130. */
  70131. export class DepthRendererSceneComponent implements ISceneComponent {
  70132. /**
  70133. * The component name helpfull to identify the component in the list of scene components.
  70134. */
  70135. readonly name: string;
  70136. /**
  70137. * The scene the component belongs to.
  70138. */
  70139. scene: Scene;
  70140. /**
  70141. * Creates a new instance of the component for the given scene
  70142. * @param scene Defines the scene to register the component in
  70143. */
  70144. constructor(scene: Scene);
  70145. /**
  70146. * Registers the component in a given scene
  70147. */
  70148. register(): void;
  70149. /**
  70150. * Rebuilds the elements related to this component in case of
  70151. * context lost for instance.
  70152. */
  70153. rebuild(): void;
  70154. /**
  70155. * Disposes the component and the associated ressources
  70156. */
  70157. dispose(): void;
  70158. private _gatherRenderTargets;
  70159. private _gatherActiveCameraRenderTargets;
  70160. }
  70161. }
  70162. declare module "babylonjs/Shaders/outline.fragment" {
  70163. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70164. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70165. /** @hidden */
  70166. export var outlinePixelShader: {
  70167. name: string;
  70168. shader: string;
  70169. };
  70170. }
  70171. declare module "babylonjs/Shaders/outline.vertex" {
  70172. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70173. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70174. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70175. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70176. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70177. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70178. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70179. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70180. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70181. /** @hidden */
  70182. export var outlineVertexShader: {
  70183. name: string;
  70184. shader: string;
  70185. };
  70186. }
  70187. declare module "babylonjs/Rendering/outlineRenderer" {
  70188. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70189. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70190. import { Scene } from "babylonjs/scene";
  70191. import { ISceneComponent } from "babylonjs/sceneComponent";
  70192. import "babylonjs/Shaders/outline.fragment";
  70193. import "babylonjs/Shaders/outline.vertex";
  70194. module "babylonjs/scene" {
  70195. interface Scene {
  70196. /** @hidden */
  70197. _outlineRenderer: OutlineRenderer;
  70198. /**
  70199. * Gets the outline renderer associated with the scene
  70200. * @returns a OutlineRenderer
  70201. */
  70202. getOutlineRenderer(): OutlineRenderer;
  70203. }
  70204. }
  70205. module "babylonjs/Meshes/abstractMesh" {
  70206. interface AbstractMesh {
  70207. /** @hidden (Backing field) */
  70208. _renderOutline: boolean;
  70209. /**
  70210. * Gets or sets a boolean indicating if the outline must be rendered as well
  70211. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70212. */
  70213. renderOutline: boolean;
  70214. /** @hidden (Backing field) */
  70215. _renderOverlay: boolean;
  70216. /**
  70217. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70218. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70219. */
  70220. renderOverlay: boolean;
  70221. }
  70222. }
  70223. /**
  70224. * This class is responsible to draw bothe outline/overlay of meshes.
  70225. * It should not be used directly but through the available method on mesh.
  70226. */
  70227. export class OutlineRenderer implements ISceneComponent {
  70228. /**
  70229. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70230. */
  70231. private static _StencilReference;
  70232. /**
  70233. * The name of the component. Each component must have a unique name.
  70234. */
  70235. name: string;
  70236. /**
  70237. * The scene the component belongs to.
  70238. */
  70239. scene: Scene;
  70240. /**
  70241. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70242. */
  70243. zOffset: number;
  70244. private _engine;
  70245. private _effect;
  70246. private _cachedDefines;
  70247. private _savedDepthWrite;
  70248. /**
  70249. * Instantiates a new outline renderer. (There could be only one per scene).
  70250. * @param scene Defines the scene it belongs to
  70251. */
  70252. constructor(scene: Scene);
  70253. /**
  70254. * Register the component to one instance of a scene.
  70255. */
  70256. register(): void;
  70257. /**
  70258. * Rebuilds the elements related to this component in case of
  70259. * context lost for instance.
  70260. */
  70261. rebuild(): void;
  70262. /**
  70263. * Disposes the component and the associated ressources.
  70264. */
  70265. dispose(): void;
  70266. /**
  70267. * Renders the outline in the canvas.
  70268. * @param subMesh Defines the sumesh to render
  70269. * @param batch Defines the batch of meshes in case of instances
  70270. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70271. */
  70272. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70273. /**
  70274. * Returns whether or not the outline renderer is ready for a given submesh.
  70275. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70276. * @param subMesh Defines the submesh to check readyness for
  70277. * @param useInstances Defines wheter wee are trying to render instances or not
  70278. * @returns true if ready otherwise false
  70279. */
  70280. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70281. private _beforeRenderingMesh;
  70282. private _afterRenderingMesh;
  70283. }
  70284. }
  70285. declare module "babylonjs/Rendering/index" {
  70286. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70287. export * from "babylonjs/Rendering/depthRenderer";
  70288. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70289. export * from "babylonjs/Rendering/edgesRenderer";
  70290. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70291. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70292. export * from "babylonjs/Rendering/outlineRenderer";
  70293. export * from "babylonjs/Rendering/renderingGroup";
  70294. export * from "babylonjs/Rendering/renderingManager";
  70295. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70296. }
  70297. declare module "babylonjs/Sprites/ISprites" {
  70298. /**
  70299. * Defines the basic options interface of a Sprite Frame Source Size.
  70300. */
  70301. export interface ISpriteJSONSpriteSourceSize {
  70302. /**
  70303. * number of the original width of the Frame
  70304. */
  70305. w: number;
  70306. /**
  70307. * number of the original height of the Frame
  70308. */
  70309. h: number;
  70310. }
  70311. /**
  70312. * Defines the basic options interface of a Sprite Frame Data.
  70313. */
  70314. export interface ISpriteJSONSpriteFrameData {
  70315. /**
  70316. * number of the x offset of the Frame
  70317. */
  70318. x: number;
  70319. /**
  70320. * number of the y offset of the Frame
  70321. */
  70322. y: number;
  70323. /**
  70324. * number of the width of the Frame
  70325. */
  70326. w: number;
  70327. /**
  70328. * number of the height of the Frame
  70329. */
  70330. h: number;
  70331. }
  70332. /**
  70333. * Defines the basic options interface of a JSON Sprite.
  70334. */
  70335. export interface ISpriteJSONSprite {
  70336. /**
  70337. * string name of the Frame
  70338. */
  70339. filename: string;
  70340. /**
  70341. * ISpriteJSONSpriteFrame basic object of the frame data
  70342. */
  70343. frame: ISpriteJSONSpriteFrameData;
  70344. /**
  70345. * boolean to flag is the frame was rotated.
  70346. */
  70347. rotated: boolean;
  70348. /**
  70349. * boolean to flag is the frame was trimmed.
  70350. */
  70351. trimmed: boolean;
  70352. /**
  70353. * ISpriteJSONSpriteFrame basic object of the source data
  70354. */
  70355. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70356. /**
  70357. * ISpriteJSONSpriteFrame basic object of the source data
  70358. */
  70359. sourceSize: ISpriteJSONSpriteSourceSize;
  70360. }
  70361. /**
  70362. * Defines the basic options interface of a JSON atlas.
  70363. */
  70364. export interface ISpriteJSONAtlas {
  70365. /**
  70366. * Array of objects that contain the frame data.
  70367. */
  70368. frames: Array<ISpriteJSONSprite>;
  70369. /**
  70370. * object basic object containing the sprite meta data.
  70371. */
  70372. meta?: object;
  70373. }
  70374. }
  70375. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70376. /** @hidden */
  70377. export var spriteMapPixelShader: {
  70378. name: string;
  70379. shader: string;
  70380. };
  70381. }
  70382. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70383. /** @hidden */
  70384. export var spriteMapVertexShader: {
  70385. name: string;
  70386. shader: string;
  70387. };
  70388. }
  70389. declare module "babylonjs/Sprites/spriteMap" {
  70390. import { IDisposable, Scene } from "babylonjs/scene";
  70391. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70392. import { Texture } from "babylonjs/Materials/Textures/texture";
  70393. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70394. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70395. import "babylonjs/Meshes/Builders/planeBuilder";
  70396. import "babylonjs/Shaders/spriteMap.fragment";
  70397. import "babylonjs/Shaders/spriteMap.vertex";
  70398. /**
  70399. * Defines the basic options interface of a SpriteMap
  70400. */
  70401. export interface ISpriteMapOptions {
  70402. /**
  70403. * Vector2 of the number of cells in the grid.
  70404. */
  70405. stageSize?: Vector2;
  70406. /**
  70407. * Vector2 of the size of the output plane in World Units.
  70408. */
  70409. outputSize?: Vector2;
  70410. /**
  70411. * Vector3 of the position of the output plane in World Units.
  70412. */
  70413. outputPosition?: Vector3;
  70414. /**
  70415. * Vector3 of the rotation of the output plane.
  70416. */
  70417. outputRotation?: Vector3;
  70418. /**
  70419. * number of layers that the system will reserve in resources.
  70420. */
  70421. layerCount?: number;
  70422. /**
  70423. * number of max animation frames a single cell will reserve in resources.
  70424. */
  70425. maxAnimationFrames?: number;
  70426. /**
  70427. * number cell index of the base tile when the system compiles.
  70428. */
  70429. baseTile?: number;
  70430. /**
  70431. * boolean flip the sprite after its been repositioned by the framing data.
  70432. */
  70433. flipU?: boolean;
  70434. /**
  70435. * Vector3 scalar of the global RGB values of the SpriteMap.
  70436. */
  70437. colorMultiply?: Vector3;
  70438. }
  70439. /**
  70440. * Defines the IDisposable interface in order to be cleanable from resources.
  70441. */
  70442. export interface ISpriteMap extends IDisposable {
  70443. /**
  70444. * String name of the SpriteMap.
  70445. */
  70446. name: string;
  70447. /**
  70448. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70449. */
  70450. atlasJSON: ISpriteJSONAtlas;
  70451. /**
  70452. * Texture of the SpriteMap.
  70453. */
  70454. spriteSheet: Texture;
  70455. /**
  70456. * The parameters to initialize the SpriteMap with.
  70457. */
  70458. options: ISpriteMapOptions;
  70459. }
  70460. /**
  70461. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70462. */
  70463. export class SpriteMap implements ISpriteMap {
  70464. /** The Name of the spriteMap */
  70465. name: string;
  70466. /** The JSON file with the frame and meta data */
  70467. atlasJSON: ISpriteJSONAtlas;
  70468. /** The systems Sprite Sheet Texture */
  70469. spriteSheet: Texture;
  70470. /** Arguments passed with the Constructor */
  70471. options: ISpriteMapOptions;
  70472. /** Public Sprite Storage array, parsed from atlasJSON */
  70473. sprites: Array<ISpriteJSONSprite>;
  70474. /** Returns the Number of Sprites in the System */
  70475. get spriteCount(): number;
  70476. /** Returns the Position of Output Plane*/
  70477. get position(): Vector3;
  70478. /** Returns the Position of Output Plane*/
  70479. set position(v: Vector3);
  70480. /** Returns the Rotation of Output Plane*/
  70481. get rotation(): Vector3;
  70482. /** Returns the Rotation of Output Plane*/
  70483. set rotation(v: Vector3);
  70484. /** Sets the AnimationMap*/
  70485. get animationMap(): RawTexture;
  70486. /** Sets the AnimationMap*/
  70487. set animationMap(v: RawTexture);
  70488. /** Scene that the SpriteMap was created in */
  70489. private _scene;
  70490. /** Texture Buffer of Float32 that holds tile frame data*/
  70491. private _frameMap;
  70492. /** Texture Buffers of Float32 that holds tileMap data*/
  70493. private _tileMaps;
  70494. /** Texture Buffer of Float32 that holds Animation Data*/
  70495. private _animationMap;
  70496. /** Custom ShaderMaterial Central to the System*/
  70497. private _material;
  70498. /** Custom ShaderMaterial Central to the System*/
  70499. private _output;
  70500. /** Systems Time Ticker*/
  70501. private _time;
  70502. /**
  70503. * Creates a new SpriteMap
  70504. * @param name defines the SpriteMaps Name
  70505. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70506. * @param spriteSheet is the Texture that the Sprites are on.
  70507. * @param options a basic deployment configuration
  70508. * @param scene The Scene that the map is deployed on
  70509. */
  70510. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70511. /**
  70512. * Returns tileID location
  70513. * @returns Vector2 the cell position ID
  70514. */
  70515. getTileID(): Vector2;
  70516. /**
  70517. * Gets the UV location of the mouse over the SpriteMap.
  70518. * @returns Vector2 the UV position of the mouse interaction
  70519. */
  70520. getMousePosition(): Vector2;
  70521. /**
  70522. * Creates the "frame" texture Buffer
  70523. * -------------------------------------
  70524. * Structure of frames
  70525. * "filename": "Falling-Water-2.png",
  70526. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70527. * "rotated": true,
  70528. * "trimmed": true,
  70529. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70530. * "sourceSize": {"w":32,"h":32}
  70531. * @returns RawTexture of the frameMap
  70532. */
  70533. private _createFrameBuffer;
  70534. /**
  70535. * Creates the tileMap texture Buffer
  70536. * @param buffer normally and array of numbers, or a false to generate from scratch
  70537. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70538. * @returns RawTexture of the tileMap
  70539. */
  70540. private _createTileBuffer;
  70541. /**
  70542. * Modifies the data of the tileMaps
  70543. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70544. * @param pos is the iVector2 Coordinates of the Tile
  70545. * @param tile The SpriteIndex of the new Tile
  70546. */
  70547. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70548. /**
  70549. * Creates the animationMap texture Buffer
  70550. * @param buffer normally and array of numbers, or a false to generate from scratch
  70551. * @returns RawTexture of the animationMap
  70552. */
  70553. private _createTileAnimationBuffer;
  70554. /**
  70555. * Modifies the data of the animationMap
  70556. * @param cellID is the Index of the Sprite
  70557. * @param _frame is the target Animation frame
  70558. * @param toCell is the Target Index of the next frame of the animation
  70559. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70560. * @param speed is a global scalar of the time variable on the map.
  70561. */
  70562. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70563. /**
  70564. * Exports the .tilemaps file
  70565. */
  70566. saveTileMaps(): void;
  70567. /**
  70568. * Imports the .tilemaps file
  70569. * @param url of the .tilemaps file
  70570. */
  70571. loadTileMaps(url: string): void;
  70572. /**
  70573. * Release associated resources
  70574. */
  70575. dispose(): void;
  70576. }
  70577. }
  70578. declare module "babylonjs/Sprites/spritePackedManager" {
  70579. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70580. import { Scene } from "babylonjs/scene";
  70581. /**
  70582. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70583. * @see http://doc.babylonjs.com/babylon101/sprites
  70584. */
  70585. export class SpritePackedManager extends SpriteManager {
  70586. /** defines the packed manager's name */
  70587. name: string;
  70588. /**
  70589. * Creates a new sprite manager from a packed sprite sheet
  70590. * @param name defines the manager's name
  70591. * @param imgUrl defines the sprite sheet url
  70592. * @param capacity defines the maximum allowed number of sprites
  70593. * @param scene defines the hosting scene
  70594. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70595. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70596. * @param samplingMode defines the smapling mode to use with spritesheet
  70597. * @param fromPacked set to true; do not alter
  70598. */
  70599. constructor(
  70600. /** defines the packed manager's name */
  70601. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70602. }
  70603. }
  70604. declare module "babylonjs/Sprites/index" {
  70605. export * from "babylonjs/Sprites/sprite";
  70606. export * from "babylonjs/Sprites/ISprites";
  70607. export * from "babylonjs/Sprites/spriteManager";
  70608. export * from "babylonjs/Sprites/spriteMap";
  70609. export * from "babylonjs/Sprites/spritePackedManager";
  70610. export * from "babylonjs/Sprites/spriteSceneComponent";
  70611. }
  70612. declare module "babylonjs/States/index" {
  70613. export * from "babylonjs/States/alphaCullingState";
  70614. export * from "babylonjs/States/depthCullingState";
  70615. export * from "babylonjs/States/stencilState";
  70616. }
  70617. declare module "babylonjs/Misc/assetsManager" {
  70618. import { Scene } from "babylonjs/scene";
  70619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70620. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70621. import { Skeleton } from "babylonjs/Bones/skeleton";
  70622. import { Observable } from "babylonjs/Misc/observable";
  70623. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70624. import { Texture } from "babylonjs/Materials/Textures/texture";
  70625. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70626. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70627. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70628. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70629. /**
  70630. * Defines the list of states available for a task inside a AssetsManager
  70631. */
  70632. export enum AssetTaskState {
  70633. /**
  70634. * Initialization
  70635. */
  70636. INIT = 0,
  70637. /**
  70638. * Running
  70639. */
  70640. RUNNING = 1,
  70641. /**
  70642. * Done
  70643. */
  70644. DONE = 2,
  70645. /**
  70646. * Error
  70647. */
  70648. ERROR = 3
  70649. }
  70650. /**
  70651. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70652. */
  70653. export abstract class AbstractAssetTask {
  70654. /**
  70655. * Task name
  70656. */ name: string;
  70657. /**
  70658. * Callback called when the task is successful
  70659. */
  70660. onSuccess: (task: any) => void;
  70661. /**
  70662. * Callback called when the task is not successful
  70663. */
  70664. onError: (task: any, message?: string, exception?: any) => void;
  70665. /**
  70666. * Creates a new AssetsManager
  70667. * @param name defines the name of the task
  70668. */
  70669. constructor(
  70670. /**
  70671. * Task name
  70672. */ name: string);
  70673. private _isCompleted;
  70674. private _taskState;
  70675. private _errorObject;
  70676. /**
  70677. * Get if the task is completed
  70678. */
  70679. get isCompleted(): boolean;
  70680. /**
  70681. * Gets the current state of the task
  70682. */
  70683. get taskState(): AssetTaskState;
  70684. /**
  70685. * Gets the current error object (if task is in error)
  70686. */
  70687. get errorObject(): {
  70688. message?: string;
  70689. exception?: any;
  70690. };
  70691. /**
  70692. * Internal only
  70693. * @hidden
  70694. */
  70695. _setErrorObject(message?: string, exception?: any): void;
  70696. /**
  70697. * Execute the current task
  70698. * @param scene defines the scene where you want your assets to be loaded
  70699. * @param onSuccess is a callback called when the task is successfully executed
  70700. * @param onError is a callback called if an error occurs
  70701. */
  70702. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70703. /**
  70704. * Execute the current task
  70705. * @param scene defines the scene where you want your assets to be loaded
  70706. * @param onSuccess is a callback called when the task is successfully executed
  70707. * @param onError is a callback called if an error occurs
  70708. */
  70709. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70710. /**
  70711. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70712. * This can be used with failed tasks that have the reason for failure fixed.
  70713. */
  70714. reset(): void;
  70715. private onErrorCallback;
  70716. private onDoneCallback;
  70717. }
  70718. /**
  70719. * Define the interface used by progress events raised during assets loading
  70720. */
  70721. export interface IAssetsProgressEvent {
  70722. /**
  70723. * Defines the number of remaining tasks to process
  70724. */
  70725. remainingCount: number;
  70726. /**
  70727. * Defines the total number of tasks
  70728. */
  70729. totalCount: number;
  70730. /**
  70731. * Defines the task that was just processed
  70732. */
  70733. task: AbstractAssetTask;
  70734. }
  70735. /**
  70736. * Class used to share progress information about assets loading
  70737. */
  70738. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70739. /**
  70740. * Defines the number of remaining tasks to process
  70741. */
  70742. remainingCount: number;
  70743. /**
  70744. * Defines the total number of tasks
  70745. */
  70746. totalCount: number;
  70747. /**
  70748. * Defines the task that was just processed
  70749. */
  70750. task: AbstractAssetTask;
  70751. /**
  70752. * Creates a AssetsProgressEvent
  70753. * @param remainingCount defines the number of remaining tasks to process
  70754. * @param totalCount defines the total number of tasks
  70755. * @param task defines the task that was just processed
  70756. */
  70757. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70758. }
  70759. /**
  70760. * Define a task used by AssetsManager to load meshes
  70761. */
  70762. export class MeshAssetTask extends AbstractAssetTask {
  70763. /**
  70764. * Defines the name of the task
  70765. */
  70766. name: string;
  70767. /**
  70768. * Defines the list of mesh's names you want to load
  70769. */
  70770. meshesNames: any;
  70771. /**
  70772. * Defines the root url to use as a base to load your meshes and associated resources
  70773. */
  70774. rootUrl: string;
  70775. /**
  70776. * Defines the filename of the scene to load from
  70777. */
  70778. sceneFilename: string;
  70779. /**
  70780. * Gets the list of loaded meshes
  70781. */
  70782. loadedMeshes: Array<AbstractMesh>;
  70783. /**
  70784. * Gets the list of loaded particle systems
  70785. */
  70786. loadedParticleSystems: Array<IParticleSystem>;
  70787. /**
  70788. * Gets the list of loaded skeletons
  70789. */
  70790. loadedSkeletons: Array<Skeleton>;
  70791. /**
  70792. * Gets the list of loaded animation groups
  70793. */
  70794. loadedAnimationGroups: Array<AnimationGroup>;
  70795. /**
  70796. * Callback called when the task is successful
  70797. */
  70798. onSuccess: (task: MeshAssetTask) => void;
  70799. /**
  70800. * Callback called when the task is successful
  70801. */
  70802. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70803. /**
  70804. * Creates a new MeshAssetTask
  70805. * @param name defines the name of the task
  70806. * @param meshesNames defines the list of mesh's names you want to load
  70807. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70808. * @param sceneFilename defines the filename of the scene to load from
  70809. */
  70810. constructor(
  70811. /**
  70812. * Defines the name of the task
  70813. */
  70814. name: string,
  70815. /**
  70816. * Defines the list of mesh's names you want to load
  70817. */
  70818. meshesNames: any,
  70819. /**
  70820. * Defines the root url to use as a base to load your meshes and associated resources
  70821. */
  70822. rootUrl: string,
  70823. /**
  70824. * Defines the filename of the scene to load from
  70825. */
  70826. sceneFilename: string);
  70827. /**
  70828. * Execute the current task
  70829. * @param scene defines the scene where you want your assets to be loaded
  70830. * @param onSuccess is a callback called when the task is successfully executed
  70831. * @param onError is a callback called if an error occurs
  70832. */
  70833. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70834. }
  70835. /**
  70836. * Define a task used by AssetsManager to load text content
  70837. */
  70838. export class TextFileAssetTask extends AbstractAssetTask {
  70839. /**
  70840. * Defines the name of the task
  70841. */
  70842. name: string;
  70843. /**
  70844. * Defines the location of the file to load
  70845. */
  70846. url: string;
  70847. /**
  70848. * Gets the loaded text string
  70849. */
  70850. text: string;
  70851. /**
  70852. * Callback called when the task is successful
  70853. */
  70854. onSuccess: (task: TextFileAssetTask) => void;
  70855. /**
  70856. * Callback called when the task is successful
  70857. */
  70858. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70859. /**
  70860. * Creates a new TextFileAssetTask object
  70861. * @param name defines the name of the task
  70862. * @param url defines the location of the file to load
  70863. */
  70864. constructor(
  70865. /**
  70866. * Defines the name of the task
  70867. */
  70868. name: string,
  70869. /**
  70870. * Defines the location of the file to load
  70871. */
  70872. url: string);
  70873. /**
  70874. * Execute the current task
  70875. * @param scene defines the scene where you want your assets to be loaded
  70876. * @param onSuccess is a callback called when the task is successfully executed
  70877. * @param onError is a callback called if an error occurs
  70878. */
  70879. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70880. }
  70881. /**
  70882. * Define a task used by AssetsManager to load binary data
  70883. */
  70884. export class BinaryFileAssetTask extends AbstractAssetTask {
  70885. /**
  70886. * Defines the name of the task
  70887. */
  70888. name: string;
  70889. /**
  70890. * Defines the location of the file to load
  70891. */
  70892. url: string;
  70893. /**
  70894. * Gets the lodaded data (as an array buffer)
  70895. */
  70896. data: ArrayBuffer;
  70897. /**
  70898. * Callback called when the task is successful
  70899. */
  70900. onSuccess: (task: BinaryFileAssetTask) => void;
  70901. /**
  70902. * Callback called when the task is successful
  70903. */
  70904. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70905. /**
  70906. * Creates a new BinaryFileAssetTask object
  70907. * @param name defines the name of the new task
  70908. * @param url defines the location of the file to load
  70909. */
  70910. constructor(
  70911. /**
  70912. * Defines the name of the task
  70913. */
  70914. name: string,
  70915. /**
  70916. * Defines the location of the file to load
  70917. */
  70918. url: string);
  70919. /**
  70920. * Execute the current task
  70921. * @param scene defines the scene where you want your assets to be loaded
  70922. * @param onSuccess is a callback called when the task is successfully executed
  70923. * @param onError is a callback called if an error occurs
  70924. */
  70925. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70926. }
  70927. /**
  70928. * Define a task used by AssetsManager to load images
  70929. */
  70930. export class ImageAssetTask extends AbstractAssetTask {
  70931. /**
  70932. * Defines the name of the task
  70933. */
  70934. name: string;
  70935. /**
  70936. * Defines the location of the image to load
  70937. */
  70938. url: string;
  70939. /**
  70940. * Gets the loaded images
  70941. */
  70942. image: HTMLImageElement;
  70943. /**
  70944. * Callback called when the task is successful
  70945. */
  70946. onSuccess: (task: ImageAssetTask) => void;
  70947. /**
  70948. * Callback called when the task is successful
  70949. */
  70950. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70951. /**
  70952. * Creates a new ImageAssetTask
  70953. * @param name defines the name of the task
  70954. * @param url defines the location of the image to load
  70955. */
  70956. constructor(
  70957. /**
  70958. * Defines the name of the task
  70959. */
  70960. name: string,
  70961. /**
  70962. * Defines the location of the image to load
  70963. */
  70964. url: string);
  70965. /**
  70966. * Execute the current task
  70967. * @param scene defines the scene where you want your assets to be loaded
  70968. * @param onSuccess is a callback called when the task is successfully executed
  70969. * @param onError is a callback called if an error occurs
  70970. */
  70971. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70972. }
  70973. /**
  70974. * Defines the interface used by texture loading tasks
  70975. */
  70976. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70977. /**
  70978. * Gets the loaded texture
  70979. */
  70980. texture: TEX;
  70981. }
  70982. /**
  70983. * Define a task used by AssetsManager to load 2D textures
  70984. */
  70985. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70986. /**
  70987. * Defines the name of the task
  70988. */
  70989. name: string;
  70990. /**
  70991. * Defines the location of the file to load
  70992. */
  70993. url: string;
  70994. /**
  70995. * Defines if mipmap should not be generated (default is false)
  70996. */
  70997. noMipmap?: boolean | undefined;
  70998. /**
  70999. * Defines if texture must be inverted on Y axis (default is false)
  71000. */
  71001. invertY?: boolean | undefined;
  71002. /**
  71003. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71004. */
  71005. samplingMode: number;
  71006. /**
  71007. * Gets the loaded texture
  71008. */
  71009. texture: Texture;
  71010. /**
  71011. * Callback called when the task is successful
  71012. */
  71013. onSuccess: (task: TextureAssetTask) => void;
  71014. /**
  71015. * Callback called when the task is successful
  71016. */
  71017. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71018. /**
  71019. * Creates a new TextureAssetTask object
  71020. * @param name defines the name of the task
  71021. * @param url defines the location of the file to load
  71022. * @param noMipmap defines if mipmap should not be generated (default is false)
  71023. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71024. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71025. */
  71026. constructor(
  71027. /**
  71028. * Defines the name of the task
  71029. */
  71030. name: string,
  71031. /**
  71032. * Defines the location of the file to load
  71033. */
  71034. url: string,
  71035. /**
  71036. * Defines if mipmap should not be generated (default is false)
  71037. */
  71038. noMipmap?: boolean | undefined,
  71039. /**
  71040. * Defines if texture must be inverted on Y axis (default is false)
  71041. */
  71042. invertY?: boolean | undefined,
  71043. /**
  71044. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71045. */
  71046. samplingMode?: number);
  71047. /**
  71048. * Execute the current task
  71049. * @param scene defines the scene where you want your assets to be loaded
  71050. * @param onSuccess is a callback called when the task is successfully executed
  71051. * @param onError is a callback called if an error occurs
  71052. */
  71053. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71054. }
  71055. /**
  71056. * Define a task used by AssetsManager to load cube textures
  71057. */
  71058. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71059. /**
  71060. * Defines the name of the task
  71061. */
  71062. name: string;
  71063. /**
  71064. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71065. */
  71066. url: string;
  71067. /**
  71068. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71069. */
  71070. extensions?: string[] | undefined;
  71071. /**
  71072. * Defines if mipmaps should not be generated (default is false)
  71073. */
  71074. noMipmap?: boolean | undefined;
  71075. /**
  71076. * Defines the explicit list of files (undefined by default)
  71077. */
  71078. files?: string[] | undefined;
  71079. /**
  71080. * Gets the loaded texture
  71081. */
  71082. texture: CubeTexture;
  71083. /**
  71084. * Callback called when the task is successful
  71085. */
  71086. onSuccess: (task: CubeTextureAssetTask) => void;
  71087. /**
  71088. * Callback called when the task is successful
  71089. */
  71090. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71091. /**
  71092. * Creates a new CubeTextureAssetTask
  71093. * @param name defines the name of the task
  71094. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71095. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71096. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71097. * @param files defines the explicit list of files (undefined by default)
  71098. */
  71099. constructor(
  71100. /**
  71101. * Defines the name of the task
  71102. */
  71103. name: string,
  71104. /**
  71105. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71106. */
  71107. url: string,
  71108. /**
  71109. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71110. */
  71111. extensions?: string[] | undefined,
  71112. /**
  71113. * Defines if mipmaps should not be generated (default is false)
  71114. */
  71115. noMipmap?: boolean | undefined,
  71116. /**
  71117. * Defines the explicit list of files (undefined by default)
  71118. */
  71119. files?: string[] | undefined);
  71120. /**
  71121. * Execute the current task
  71122. * @param scene defines the scene where you want your assets to be loaded
  71123. * @param onSuccess is a callback called when the task is successfully executed
  71124. * @param onError is a callback called if an error occurs
  71125. */
  71126. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71127. }
  71128. /**
  71129. * Define a task used by AssetsManager to load HDR cube textures
  71130. */
  71131. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71132. /**
  71133. * Defines the name of the task
  71134. */
  71135. name: string;
  71136. /**
  71137. * Defines the location of the file to load
  71138. */
  71139. url: string;
  71140. /**
  71141. * Defines the desired size (the more it increases the longer the generation will be)
  71142. */
  71143. size: number;
  71144. /**
  71145. * Defines if mipmaps should not be generated (default is false)
  71146. */
  71147. noMipmap: boolean;
  71148. /**
  71149. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71150. */
  71151. generateHarmonics: boolean;
  71152. /**
  71153. * 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)
  71154. */
  71155. gammaSpace: boolean;
  71156. /**
  71157. * Internal Use Only
  71158. */
  71159. reserved: boolean;
  71160. /**
  71161. * Gets the loaded texture
  71162. */
  71163. texture: HDRCubeTexture;
  71164. /**
  71165. * Callback called when the task is successful
  71166. */
  71167. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71168. /**
  71169. * Callback called when the task is successful
  71170. */
  71171. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71172. /**
  71173. * Creates a new HDRCubeTextureAssetTask object
  71174. * @param name defines the name of the task
  71175. * @param url defines the location of the file to load
  71176. * @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.
  71177. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71178. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71179. * @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)
  71180. * @param reserved Internal use only
  71181. */
  71182. constructor(
  71183. /**
  71184. * Defines the name of the task
  71185. */
  71186. name: string,
  71187. /**
  71188. * Defines the location of the file to load
  71189. */
  71190. url: string,
  71191. /**
  71192. * Defines the desired size (the more it increases the longer the generation will be)
  71193. */
  71194. size: number,
  71195. /**
  71196. * Defines if mipmaps should not be generated (default is false)
  71197. */
  71198. noMipmap?: boolean,
  71199. /**
  71200. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71201. */
  71202. generateHarmonics?: boolean,
  71203. /**
  71204. * 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)
  71205. */
  71206. gammaSpace?: boolean,
  71207. /**
  71208. * Internal Use Only
  71209. */
  71210. reserved?: boolean);
  71211. /**
  71212. * Execute the current task
  71213. * @param scene defines the scene where you want your assets to be loaded
  71214. * @param onSuccess is a callback called when the task is successfully executed
  71215. * @param onError is a callback called if an error occurs
  71216. */
  71217. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71218. }
  71219. /**
  71220. * Define a task used by AssetsManager to load Equirectangular cube textures
  71221. */
  71222. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71223. /**
  71224. * Defines the name of the task
  71225. */
  71226. name: string;
  71227. /**
  71228. * Defines the location of the file to load
  71229. */
  71230. url: string;
  71231. /**
  71232. * Defines the desired size (the more it increases the longer the generation will be)
  71233. */
  71234. size: number;
  71235. /**
  71236. * Defines if mipmaps should not be generated (default is false)
  71237. */
  71238. noMipmap: boolean;
  71239. /**
  71240. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71241. * but the standard material would require them in Gamma space) (default is true)
  71242. */
  71243. gammaSpace: boolean;
  71244. /**
  71245. * Gets the loaded texture
  71246. */
  71247. texture: EquiRectangularCubeTexture;
  71248. /**
  71249. * Callback called when the task is successful
  71250. */
  71251. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71252. /**
  71253. * Callback called when the task is successful
  71254. */
  71255. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71256. /**
  71257. * Creates a new EquiRectangularCubeTextureAssetTask object
  71258. * @param name defines the name of the task
  71259. * @param url defines the location of the file to load
  71260. * @param size defines the desired size (the more it increases the longer the generation will be)
  71261. * If the size is omitted this implies you are using a preprocessed cubemap.
  71262. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71263. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71264. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71265. * (default is true)
  71266. */
  71267. constructor(
  71268. /**
  71269. * Defines the name of the task
  71270. */
  71271. name: string,
  71272. /**
  71273. * Defines the location of the file to load
  71274. */
  71275. url: string,
  71276. /**
  71277. * Defines the desired size (the more it increases the longer the generation will be)
  71278. */
  71279. size: number,
  71280. /**
  71281. * Defines if mipmaps should not be generated (default is false)
  71282. */
  71283. noMipmap?: boolean,
  71284. /**
  71285. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71286. * but the standard material would require them in Gamma space) (default is true)
  71287. */
  71288. gammaSpace?: boolean);
  71289. /**
  71290. * Execute the current task
  71291. * @param scene defines the scene where you want your assets to be loaded
  71292. * @param onSuccess is a callback called when the task is successfully executed
  71293. * @param onError is a callback called if an error occurs
  71294. */
  71295. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71296. }
  71297. /**
  71298. * This class can be used to easily import assets into a scene
  71299. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71300. */
  71301. export class AssetsManager {
  71302. private _scene;
  71303. private _isLoading;
  71304. protected _tasks: AbstractAssetTask[];
  71305. protected _waitingTasksCount: number;
  71306. protected _totalTasksCount: number;
  71307. /**
  71308. * Callback called when all tasks are processed
  71309. */
  71310. onFinish: (tasks: AbstractAssetTask[]) => void;
  71311. /**
  71312. * Callback called when a task is successful
  71313. */
  71314. onTaskSuccess: (task: AbstractAssetTask) => void;
  71315. /**
  71316. * Callback called when a task had an error
  71317. */
  71318. onTaskError: (task: AbstractAssetTask) => void;
  71319. /**
  71320. * Callback called when a task is done (whatever the result is)
  71321. */
  71322. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71323. /**
  71324. * Observable called when all tasks are processed
  71325. */
  71326. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71327. /**
  71328. * Observable called when a task had an error
  71329. */
  71330. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71331. /**
  71332. * Observable called when all tasks were executed
  71333. */
  71334. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71335. /**
  71336. * Observable called when a task is done (whatever the result is)
  71337. */
  71338. onProgressObservable: Observable<IAssetsProgressEvent>;
  71339. /**
  71340. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71341. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71342. */
  71343. useDefaultLoadingScreen: boolean;
  71344. /**
  71345. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71346. * when all assets have been downloaded.
  71347. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71348. */
  71349. autoHideLoadingUI: boolean;
  71350. /**
  71351. * Creates a new AssetsManager
  71352. * @param scene defines the scene to work on
  71353. */
  71354. constructor(scene: Scene);
  71355. /**
  71356. * Add a MeshAssetTask to the list of active tasks
  71357. * @param taskName defines the name of the new task
  71358. * @param meshesNames defines the name of meshes to load
  71359. * @param rootUrl defines the root url to use to locate files
  71360. * @param sceneFilename defines the filename of the scene file
  71361. * @returns a new MeshAssetTask object
  71362. */
  71363. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71364. /**
  71365. * Add a TextFileAssetTask to the list of active tasks
  71366. * @param taskName defines the name of the new task
  71367. * @param url defines the url of the file to load
  71368. * @returns a new TextFileAssetTask object
  71369. */
  71370. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71371. /**
  71372. * Add a BinaryFileAssetTask to the list of active tasks
  71373. * @param taskName defines the name of the new task
  71374. * @param url defines the url of the file to load
  71375. * @returns a new BinaryFileAssetTask object
  71376. */
  71377. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71378. /**
  71379. * Add a ImageAssetTask to the list of active tasks
  71380. * @param taskName defines the name of the new task
  71381. * @param url defines the url of the file to load
  71382. * @returns a new ImageAssetTask object
  71383. */
  71384. addImageTask(taskName: string, url: string): ImageAssetTask;
  71385. /**
  71386. * Add a TextureAssetTask to the list of active tasks
  71387. * @param taskName defines the name of the new task
  71388. * @param url defines the url of the file to load
  71389. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71390. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71391. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71392. * @returns a new TextureAssetTask object
  71393. */
  71394. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71395. /**
  71396. * Add a CubeTextureAssetTask 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 extensions defines the extension to use to load the cube map (can be null)
  71400. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71401. * @param files defines the list of files to load (can be null)
  71402. * @returns a new CubeTextureAssetTask object
  71403. */
  71404. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71405. /**
  71406. *
  71407. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71408. * @param taskName defines the name of the new task
  71409. * @param url defines the url of the file to load
  71410. * @param size defines the size you want for the cubemap (can be null)
  71411. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71412. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71413. * @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)
  71414. * @param reserved Internal use only
  71415. * @returns a new HDRCubeTextureAssetTask object
  71416. */
  71417. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71418. /**
  71419. *
  71420. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71421. * @param taskName defines the name of the new task
  71422. * @param url defines the url of the file to load
  71423. * @param size defines the size you want for the cubemap (can be null)
  71424. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71425. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71426. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71427. * @returns a new EquiRectangularCubeTextureAssetTask object
  71428. */
  71429. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71430. /**
  71431. * Remove a task from the assets manager.
  71432. * @param task the task to remove
  71433. */
  71434. removeTask(task: AbstractAssetTask): void;
  71435. private _decreaseWaitingTasksCount;
  71436. private _runTask;
  71437. /**
  71438. * Reset the AssetsManager and remove all tasks
  71439. * @return the current instance of the AssetsManager
  71440. */
  71441. reset(): AssetsManager;
  71442. /**
  71443. * Start the loading process
  71444. * @return the current instance of the AssetsManager
  71445. */
  71446. load(): AssetsManager;
  71447. /**
  71448. * Start the loading process as an async operation
  71449. * @return a promise returning the list of failed tasks
  71450. */
  71451. loadAsync(): Promise<void>;
  71452. }
  71453. }
  71454. declare module "babylonjs/Misc/deferred" {
  71455. /**
  71456. * Wrapper class for promise with external resolve and reject.
  71457. */
  71458. export class Deferred<T> {
  71459. /**
  71460. * The promise associated with this deferred object.
  71461. */
  71462. readonly promise: Promise<T>;
  71463. private _resolve;
  71464. private _reject;
  71465. /**
  71466. * The resolve method of the promise associated with this deferred object.
  71467. */
  71468. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71469. /**
  71470. * The reject method of the promise associated with this deferred object.
  71471. */
  71472. get reject(): (reason?: any) => void;
  71473. /**
  71474. * Constructor for this deferred object.
  71475. */
  71476. constructor();
  71477. }
  71478. }
  71479. declare module "babylonjs/Misc/meshExploder" {
  71480. import { Mesh } from "babylonjs/Meshes/mesh";
  71481. /**
  71482. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71483. */
  71484. export class MeshExploder {
  71485. private _centerMesh;
  71486. private _meshes;
  71487. private _meshesOrigins;
  71488. private _toCenterVectors;
  71489. private _scaledDirection;
  71490. private _newPosition;
  71491. private _centerPosition;
  71492. /**
  71493. * Explodes meshes from a center mesh.
  71494. * @param meshes The meshes to explode.
  71495. * @param centerMesh The mesh to be center of explosion.
  71496. */
  71497. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71498. private _setCenterMesh;
  71499. /**
  71500. * Get class name
  71501. * @returns "MeshExploder"
  71502. */
  71503. getClassName(): string;
  71504. /**
  71505. * "Exploded meshes"
  71506. * @returns Array of meshes with the centerMesh at index 0.
  71507. */
  71508. getMeshes(): Array<Mesh>;
  71509. /**
  71510. * Explodes meshes giving a specific direction
  71511. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71512. */
  71513. explode(direction?: number): void;
  71514. }
  71515. }
  71516. declare module "babylonjs/Misc/filesInput" {
  71517. import { Engine } from "babylonjs/Engines/engine";
  71518. import { Scene } from "babylonjs/scene";
  71519. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71520. /**
  71521. * Class used to help managing file picking and drag'n'drop
  71522. */
  71523. export class FilesInput {
  71524. /**
  71525. * List of files ready to be loaded
  71526. */
  71527. static get FilesToLoad(): {
  71528. [key: string]: File;
  71529. };
  71530. /**
  71531. * Callback called when a file is processed
  71532. */
  71533. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71534. private _engine;
  71535. private _currentScene;
  71536. private _sceneLoadedCallback;
  71537. private _progressCallback;
  71538. private _additionalRenderLoopLogicCallback;
  71539. private _textureLoadingCallback;
  71540. private _startingProcessingFilesCallback;
  71541. private _onReloadCallback;
  71542. private _errorCallback;
  71543. private _elementToMonitor;
  71544. private _sceneFileToLoad;
  71545. private _filesToLoad;
  71546. /**
  71547. * Creates a new FilesInput
  71548. * @param engine defines the rendering engine
  71549. * @param scene defines the hosting scene
  71550. * @param sceneLoadedCallback callback called when scene is loaded
  71551. * @param progressCallback callback called to track progress
  71552. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71553. * @param textureLoadingCallback callback called when a texture is loading
  71554. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71555. * @param onReloadCallback callback called when a reload is requested
  71556. * @param errorCallback callback call if an error occurs
  71557. */
  71558. 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);
  71559. private _dragEnterHandler;
  71560. private _dragOverHandler;
  71561. private _dropHandler;
  71562. /**
  71563. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71564. * @param elementToMonitor defines the DOM element to track
  71565. */
  71566. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71567. /**
  71568. * Release all associated resources
  71569. */
  71570. dispose(): void;
  71571. private renderFunction;
  71572. private drag;
  71573. private drop;
  71574. private _traverseFolder;
  71575. private _processFiles;
  71576. /**
  71577. * Load files from a drop event
  71578. * @param event defines the drop event to use as source
  71579. */
  71580. loadFiles(event: any): void;
  71581. private _processReload;
  71582. /**
  71583. * Reload the current scene from the loaded files
  71584. */
  71585. reload(): void;
  71586. }
  71587. }
  71588. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71589. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71590. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71591. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71592. }
  71593. declare module "babylonjs/Misc/sceneOptimizer" {
  71594. import { Scene, IDisposable } from "babylonjs/scene";
  71595. import { Observable } from "babylonjs/Misc/observable";
  71596. /**
  71597. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71598. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71599. */
  71600. export class SceneOptimization {
  71601. /**
  71602. * Defines the priority of this optimization (0 by default which means first in the list)
  71603. */
  71604. priority: number;
  71605. /**
  71606. * Gets a string describing the action executed by the current optimization
  71607. * @returns description string
  71608. */
  71609. getDescription(): string;
  71610. /**
  71611. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71612. * @param scene defines the current scene where to apply this optimization
  71613. * @param optimizer defines the current optimizer
  71614. * @returns true if everything that can be done was applied
  71615. */
  71616. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71617. /**
  71618. * Creates the SceneOptimization object
  71619. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71620. * @param desc defines the description associated with the optimization
  71621. */
  71622. constructor(
  71623. /**
  71624. * Defines the priority of this optimization (0 by default which means first in the list)
  71625. */
  71626. priority?: number);
  71627. }
  71628. /**
  71629. * Defines an optimization used to reduce the size of render target textures
  71630. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71631. */
  71632. export class TextureOptimization extends SceneOptimization {
  71633. /**
  71634. * Defines the priority of this optimization (0 by default which means first in the list)
  71635. */
  71636. priority: number;
  71637. /**
  71638. * 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
  71639. */
  71640. maximumSize: number;
  71641. /**
  71642. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71643. */
  71644. step: number;
  71645. /**
  71646. * Gets a string describing the action executed by the current optimization
  71647. * @returns description string
  71648. */
  71649. getDescription(): string;
  71650. /**
  71651. * Creates the TextureOptimization object
  71652. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71653. * @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
  71654. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71655. */
  71656. constructor(
  71657. /**
  71658. * Defines the priority of this optimization (0 by default which means first in the list)
  71659. */
  71660. priority?: number,
  71661. /**
  71662. * 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
  71663. */
  71664. maximumSize?: number,
  71665. /**
  71666. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71667. */
  71668. step?: number);
  71669. /**
  71670. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71671. * @param scene defines the current scene where to apply this optimization
  71672. * @param optimizer defines the current optimizer
  71673. * @returns true if everything that can be done was applied
  71674. */
  71675. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71676. }
  71677. /**
  71678. * Defines an optimization used to increase or decrease the rendering resolution
  71679. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71680. */
  71681. export class HardwareScalingOptimization extends SceneOptimization {
  71682. /**
  71683. * Defines the priority of this optimization (0 by default which means first in the list)
  71684. */
  71685. priority: number;
  71686. /**
  71687. * Defines the maximum scale to use (2 by default)
  71688. */
  71689. maximumScale: number;
  71690. /**
  71691. * Defines the step to use between two passes (0.5 by default)
  71692. */
  71693. step: number;
  71694. private _currentScale;
  71695. private _directionOffset;
  71696. /**
  71697. * Gets a string describing the action executed by the current optimization
  71698. * @return description string
  71699. */
  71700. getDescription(): string;
  71701. /**
  71702. * Creates the HardwareScalingOptimization object
  71703. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71704. * @param maximumScale defines the maximum scale to use (2 by default)
  71705. * @param step defines the step to use between two passes (0.5 by default)
  71706. */
  71707. constructor(
  71708. /**
  71709. * Defines the priority of this optimization (0 by default which means first in the list)
  71710. */
  71711. priority?: number,
  71712. /**
  71713. * Defines the maximum scale to use (2 by default)
  71714. */
  71715. maximumScale?: number,
  71716. /**
  71717. * Defines the step to use between two passes (0.5 by default)
  71718. */
  71719. step?: number);
  71720. /**
  71721. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71722. * @param scene defines the current scene where to apply this optimization
  71723. * @param optimizer defines the current optimizer
  71724. * @returns true if everything that can be done was applied
  71725. */
  71726. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71727. }
  71728. /**
  71729. * Defines an optimization used to remove shadows
  71730. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71731. */
  71732. export class ShadowsOptimization extends SceneOptimization {
  71733. /**
  71734. * Gets a string describing the action executed by the current optimization
  71735. * @return description string
  71736. */
  71737. getDescription(): string;
  71738. /**
  71739. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71740. * @param scene defines the current scene where to apply this optimization
  71741. * @param optimizer defines the current optimizer
  71742. * @returns true if everything that can be done was applied
  71743. */
  71744. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71745. }
  71746. /**
  71747. * Defines an optimization used to turn post-processes off
  71748. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71749. */
  71750. export class PostProcessesOptimization extends SceneOptimization {
  71751. /**
  71752. * Gets a string describing the action executed by the current optimization
  71753. * @return description string
  71754. */
  71755. getDescription(): string;
  71756. /**
  71757. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71758. * @param scene defines the current scene where to apply this optimization
  71759. * @param optimizer defines the current optimizer
  71760. * @returns true if everything that can be done was applied
  71761. */
  71762. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71763. }
  71764. /**
  71765. * Defines an optimization used to turn lens flares off
  71766. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71767. */
  71768. export class LensFlaresOptimization extends SceneOptimization {
  71769. /**
  71770. * Gets a string describing the action executed by the current optimization
  71771. * @return description string
  71772. */
  71773. getDescription(): string;
  71774. /**
  71775. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71776. * @param scene defines the current scene where to apply this optimization
  71777. * @param optimizer defines the current optimizer
  71778. * @returns true if everything that can be done was applied
  71779. */
  71780. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71781. }
  71782. /**
  71783. * Defines an optimization based on user defined callback.
  71784. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71785. */
  71786. export class CustomOptimization extends SceneOptimization {
  71787. /**
  71788. * Callback called to apply the custom optimization.
  71789. */
  71790. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71791. /**
  71792. * Callback called to get custom description
  71793. */
  71794. onGetDescription: () => string;
  71795. /**
  71796. * Gets a string describing the action executed by the current optimization
  71797. * @returns description string
  71798. */
  71799. getDescription(): string;
  71800. /**
  71801. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71802. * @param scene defines the current scene where to apply this optimization
  71803. * @param optimizer defines the current optimizer
  71804. * @returns true if everything that can be done was applied
  71805. */
  71806. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71807. }
  71808. /**
  71809. * Defines an optimization used to turn particles off
  71810. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71811. */
  71812. export class ParticlesOptimization extends SceneOptimization {
  71813. /**
  71814. * Gets a string describing the action executed by the current optimization
  71815. * @return description string
  71816. */
  71817. getDescription(): string;
  71818. /**
  71819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71820. * @param scene defines the current scene where to apply this optimization
  71821. * @param optimizer defines the current optimizer
  71822. * @returns true if everything that can be done was applied
  71823. */
  71824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71825. }
  71826. /**
  71827. * Defines an optimization used to turn render targets off
  71828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71829. */
  71830. export class RenderTargetsOptimization extends SceneOptimization {
  71831. /**
  71832. * Gets a string describing the action executed by the current optimization
  71833. * @return description string
  71834. */
  71835. getDescription(): string;
  71836. /**
  71837. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71838. * @param scene defines the current scene where to apply this optimization
  71839. * @param optimizer defines the current optimizer
  71840. * @returns true if everything that can be done was applied
  71841. */
  71842. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71843. }
  71844. /**
  71845. * Defines an optimization used to merge meshes with compatible materials
  71846. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71847. */
  71848. export class MergeMeshesOptimization extends SceneOptimization {
  71849. private static _UpdateSelectionTree;
  71850. /**
  71851. * Gets or sets a boolean which defines if optimization octree has to be updated
  71852. */
  71853. static get UpdateSelectionTree(): boolean;
  71854. /**
  71855. * Gets or sets a boolean which defines if optimization octree has to be updated
  71856. */
  71857. static set UpdateSelectionTree(value: boolean);
  71858. /**
  71859. * Gets a string describing the action executed by the current optimization
  71860. * @return description string
  71861. */
  71862. getDescription(): string;
  71863. private _canBeMerged;
  71864. /**
  71865. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71866. * @param scene defines the current scene where to apply this optimization
  71867. * @param optimizer defines the current optimizer
  71868. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71869. * @returns true if everything that can be done was applied
  71870. */
  71871. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71872. }
  71873. /**
  71874. * Defines a list of options used by SceneOptimizer
  71875. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71876. */
  71877. export class SceneOptimizerOptions {
  71878. /**
  71879. * Defines the target frame rate to reach (60 by default)
  71880. */
  71881. targetFrameRate: number;
  71882. /**
  71883. * Defines the interval between two checkes (2000ms by default)
  71884. */
  71885. trackerDuration: number;
  71886. /**
  71887. * Gets the list of optimizations to apply
  71888. */
  71889. optimizations: SceneOptimization[];
  71890. /**
  71891. * Creates a new list of options used by SceneOptimizer
  71892. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71893. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71894. */
  71895. constructor(
  71896. /**
  71897. * Defines the target frame rate to reach (60 by default)
  71898. */
  71899. targetFrameRate?: number,
  71900. /**
  71901. * Defines the interval between two checkes (2000ms by default)
  71902. */
  71903. trackerDuration?: number);
  71904. /**
  71905. * Add a new optimization
  71906. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71907. * @returns the current SceneOptimizerOptions
  71908. */
  71909. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71910. /**
  71911. * Add a new custom optimization
  71912. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71913. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71914. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71915. * @returns the current SceneOptimizerOptions
  71916. */
  71917. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71918. /**
  71919. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71920. * @param targetFrameRate defines the target frame rate (60 by default)
  71921. * @returns a SceneOptimizerOptions object
  71922. */
  71923. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71924. /**
  71925. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71926. * @param targetFrameRate defines the target frame rate (60 by default)
  71927. * @returns a SceneOptimizerOptions object
  71928. */
  71929. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71930. /**
  71931. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71932. * @param targetFrameRate defines the target frame rate (60 by default)
  71933. * @returns a SceneOptimizerOptions object
  71934. */
  71935. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71936. }
  71937. /**
  71938. * Class used to run optimizations in order to reach a target frame rate
  71939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71940. */
  71941. export class SceneOptimizer implements IDisposable {
  71942. private _isRunning;
  71943. private _options;
  71944. private _scene;
  71945. private _currentPriorityLevel;
  71946. private _targetFrameRate;
  71947. private _trackerDuration;
  71948. private _currentFrameRate;
  71949. private _sceneDisposeObserver;
  71950. private _improvementMode;
  71951. /**
  71952. * Defines an observable called when the optimizer reaches the target frame rate
  71953. */
  71954. onSuccessObservable: Observable<SceneOptimizer>;
  71955. /**
  71956. * Defines an observable called when the optimizer enables an optimization
  71957. */
  71958. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71959. /**
  71960. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71961. */
  71962. onFailureObservable: Observable<SceneOptimizer>;
  71963. /**
  71964. * Gets a boolean indicating if the optimizer is in improvement mode
  71965. */
  71966. get isInImprovementMode(): boolean;
  71967. /**
  71968. * Gets the current priority level (0 at start)
  71969. */
  71970. get currentPriorityLevel(): number;
  71971. /**
  71972. * Gets the current frame rate checked by the SceneOptimizer
  71973. */
  71974. get currentFrameRate(): number;
  71975. /**
  71976. * Gets or sets the current target frame rate (60 by default)
  71977. */
  71978. get targetFrameRate(): number;
  71979. /**
  71980. * Gets or sets the current target frame rate (60 by default)
  71981. */
  71982. set targetFrameRate(value: number);
  71983. /**
  71984. * Gets or sets the current interval between two checks (every 2000ms by default)
  71985. */
  71986. get trackerDuration(): number;
  71987. /**
  71988. * Gets or sets the current interval between two checks (every 2000ms by default)
  71989. */
  71990. set trackerDuration(value: number);
  71991. /**
  71992. * Gets the list of active optimizations
  71993. */
  71994. get optimizations(): SceneOptimization[];
  71995. /**
  71996. * Creates a new SceneOptimizer
  71997. * @param scene defines the scene to work on
  71998. * @param options defines the options to use with the SceneOptimizer
  71999. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72000. * @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)
  72001. */
  72002. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72003. /**
  72004. * Stops the current optimizer
  72005. */
  72006. stop(): void;
  72007. /**
  72008. * Reset the optimizer to initial step (current priority level = 0)
  72009. */
  72010. reset(): void;
  72011. /**
  72012. * Start the optimizer. By default it will try to reach a specific framerate
  72013. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72014. */
  72015. start(): void;
  72016. private _checkCurrentState;
  72017. /**
  72018. * Release all resources
  72019. */
  72020. dispose(): void;
  72021. /**
  72022. * Helper function to create a SceneOptimizer with one single line of code
  72023. * @param scene defines the scene to work on
  72024. * @param options defines the options to use with the SceneOptimizer
  72025. * @param onSuccess defines a callback to call on success
  72026. * @param onFailure defines a callback to call on failure
  72027. * @returns the new SceneOptimizer object
  72028. */
  72029. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72030. }
  72031. }
  72032. declare module "babylonjs/Misc/sceneSerializer" {
  72033. import { Scene } from "babylonjs/scene";
  72034. /**
  72035. * Class used to serialize a scene into a string
  72036. */
  72037. export class SceneSerializer {
  72038. /**
  72039. * Clear cache used by a previous serialization
  72040. */
  72041. static ClearCache(): void;
  72042. /**
  72043. * Serialize a scene into a JSON compatible object
  72044. * @param scene defines the scene to serialize
  72045. * @returns a JSON compatible object
  72046. */
  72047. static Serialize(scene: Scene): any;
  72048. /**
  72049. * Serialize a mesh into a JSON compatible object
  72050. * @param toSerialize defines the mesh to serialize
  72051. * @param withParents defines if parents must be serialized as well
  72052. * @param withChildren defines if children must be serialized as well
  72053. * @returns a JSON compatible object
  72054. */
  72055. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72056. }
  72057. }
  72058. declare module "babylonjs/Misc/textureTools" {
  72059. import { Texture } from "babylonjs/Materials/Textures/texture";
  72060. /**
  72061. * Class used to host texture specific utilities
  72062. */
  72063. export class TextureTools {
  72064. /**
  72065. * Uses the GPU to create a copy texture rescaled at a given size
  72066. * @param texture Texture to copy from
  72067. * @param width defines the desired width
  72068. * @param height defines the desired height
  72069. * @param useBilinearMode defines if bilinear mode has to be used
  72070. * @return the generated texture
  72071. */
  72072. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72073. }
  72074. }
  72075. declare module "babylonjs/Misc/videoRecorder" {
  72076. import { Nullable } from "babylonjs/types";
  72077. import { Engine } from "babylonjs/Engines/engine";
  72078. /**
  72079. * This represents the different options available for the video capture.
  72080. */
  72081. export interface VideoRecorderOptions {
  72082. /** Defines the mime type of the video. */
  72083. mimeType: string;
  72084. /** Defines the FPS the video should be recorded at. */
  72085. fps: number;
  72086. /** Defines the chunk size for the recording data. */
  72087. recordChunckSize: number;
  72088. /** The audio tracks to attach to the recording. */
  72089. audioTracks?: MediaStreamTrack[];
  72090. }
  72091. /**
  72092. * This can help with recording videos from BabylonJS.
  72093. * This is based on the available WebRTC functionalities of the browser.
  72094. *
  72095. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72096. */
  72097. export class VideoRecorder {
  72098. private static readonly _defaultOptions;
  72099. /**
  72100. * Returns whether or not the VideoRecorder is available in your browser.
  72101. * @param engine Defines the Babylon Engine.
  72102. * @returns true if supported otherwise false.
  72103. */
  72104. static IsSupported(engine: Engine): boolean;
  72105. private readonly _options;
  72106. private _canvas;
  72107. private _mediaRecorder;
  72108. private _recordedChunks;
  72109. private _fileName;
  72110. private _resolve;
  72111. private _reject;
  72112. /**
  72113. * True when a recording is already in progress.
  72114. */
  72115. get isRecording(): boolean;
  72116. /**
  72117. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72118. * @param engine Defines the BabylonJS Engine you wish to record.
  72119. * @param options Defines options that can be used to customize the capture.
  72120. */
  72121. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72122. /**
  72123. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72124. */
  72125. stopRecording(): void;
  72126. /**
  72127. * Starts recording the canvas for a max duration specified in parameters.
  72128. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72129. * If null no automatic download will start and you can rely on the promise to get the data back.
  72130. * @param maxDuration Defines the maximum recording time in seconds.
  72131. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72132. * @return A promise callback at the end of the recording with the video data in Blob.
  72133. */
  72134. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72135. /**
  72136. * Releases internal resources used during the recording.
  72137. */
  72138. dispose(): void;
  72139. private _handleDataAvailable;
  72140. private _handleError;
  72141. private _handleStop;
  72142. }
  72143. }
  72144. declare module "babylonjs/Misc/screenshotTools" {
  72145. import { Camera } from "babylonjs/Cameras/camera";
  72146. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72147. import { Engine } from "babylonjs/Engines/engine";
  72148. /**
  72149. * Class containing a set of static utilities functions for screenshots
  72150. */
  72151. export class ScreenshotTools {
  72152. /**
  72153. * Captures a screenshot of the current rendering
  72154. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72155. * @param engine defines the rendering engine
  72156. * @param camera defines the source camera
  72157. * @param size This parameter can be set to a single number or to an object with the
  72158. * following (optional) properties: precision, width, height. If a single number is passed,
  72159. * it will be used for both width and height. If an object is passed, the screenshot size
  72160. * will be derived from the parameters. The precision property is a multiplier allowing
  72161. * rendering at a higher or lower resolution
  72162. * @param successCallback defines the callback receives a single parameter which contains the
  72163. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72164. * src parameter of an <img> to display it
  72165. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72166. * Check your browser for supported MIME types
  72167. */
  72168. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72169. /**
  72170. * Captures a screenshot of the current rendering
  72171. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72172. * @param engine defines the rendering engine
  72173. * @param camera defines the source camera
  72174. * @param size This parameter can be set to a single number or to an object with the
  72175. * following (optional) properties: precision, width, height. If a single number is passed,
  72176. * it will be used for both width and height. If an object is passed, the screenshot size
  72177. * will be derived from the parameters. The precision property is a multiplier allowing
  72178. * rendering at a higher or lower resolution
  72179. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72180. * Check your browser for supported MIME types
  72181. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72182. * to the src parameter of an <img> to display it
  72183. */
  72184. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72185. /**
  72186. * Generates an image screenshot from the specified camera.
  72187. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72188. * @param engine The engine to use for rendering
  72189. * @param camera The camera to use for rendering
  72190. * @param size This parameter can be set to a single number or to an object with the
  72191. * following (optional) properties: precision, width, height. If a single number is passed,
  72192. * it will be used for both width and height. If an object is passed, the screenshot size
  72193. * will be derived from the parameters. The precision property is a multiplier allowing
  72194. * rendering at a higher or lower resolution
  72195. * @param successCallback The callback receives a single parameter which contains the
  72196. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72197. * src parameter of an <img> to display it
  72198. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72199. * Check your browser for supported MIME types
  72200. * @param samples Texture samples (default: 1)
  72201. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72202. * @param fileName A name for for the downloaded file.
  72203. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72204. */
  72205. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72206. /**
  72207. * Generates an image screenshot from the specified camera.
  72208. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72209. * @param engine The engine to use for rendering
  72210. * @param camera The camera to use for rendering
  72211. * @param size This parameter can be set to a single number or to an object with the
  72212. * following (optional) properties: precision, width, height. If a single number is passed,
  72213. * it will be used for both width and height. If an object is passed, the screenshot size
  72214. * will be derived from the parameters. The precision property is a multiplier allowing
  72215. * rendering at a higher or lower resolution
  72216. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72217. * Check your browser for supported MIME types
  72218. * @param samples Texture samples (default: 1)
  72219. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72220. * @param fileName A name for for the downloaded file.
  72221. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72222. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72223. * to the src parameter of an <img> to display it
  72224. */
  72225. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72226. /**
  72227. * Gets height and width for screenshot size
  72228. * @private
  72229. */
  72230. private static _getScreenshotSize;
  72231. }
  72232. }
  72233. declare module "babylonjs/Misc/dataReader" {
  72234. /**
  72235. * Interface for a data buffer
  72236. */
  72237. export interface IDataBuffer {
  72238. /**
  72239. * Reads bytes from the data buffer.
  72240. * @param byteOffset The byte offset to read
  72241. * @param byteLength The byte length to read
  72242. * @returns A promise that resolves when the bytes are read
  72243. */
  72244. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72245. /**
  72246. * The byte length of the buffer.
  72247. */
  72248. readonly byteLength: number;
  72249. }
  72250. /**
  72251. * Utility class for reading from a data buffer
  72252. */
  72253. export class DataReader {
  72254. /**
  72255. * The data buffer associated with this data reader.
  72256. */
  72257. readonly buffer: IDataBuffer;
  72258. /**
  72259. * The current byte offset from the beginning of the data buffer.
  72260. */
  72261. byteOffset: number;
  72262. private _dataView;
  72263. private _dataByteOffset;
  72264. /**
  72265. * Constructor
  72266. * @param buffer The buffer to read
  72267. */
  72268. constructor(buffer: IDataBuffer);
  72269. /**
  72270. * Loads the given byte length.
  72271. * @param byteLength The byte length to load
  72272. * @returns A promise that resolves when the load is complete
  72273. */
  72274. loadAsync(byteLength: number): Promise<void>;
  72275. /**
  72276. * Read a unsigned 32-bit integer from the currently loaded data range.
  72277. * @returns The 32-bit integer read
  72278. */
  72279. readUint32(): number;
  72280. /**
  72281. * Read a byte array from the currently loaded data range.
  72282. * @param byteLength The byte length to read
  72283. * @returns The byte array read
  72284. */
  72285. readUint8Array(byteLength: number): Uint8Array;
  72286. /**
  72287. * Read a string from the currently loaded data range.
  72288. * @param byteLength The byte length to read
  72289. * @returns The string read
  72290. */
  72291. readString(byteLength: number): string;
  72292. /**
  72293. * Skips the given byte length the currently loaded data range.
  72294. * @param byteLength The byte length to skip
  72295. */
  72296. skipBytes(byteLength: number): void;
  72297. }
  72298. }
  72299. declare module "babylonjs/Misc/index" {
  72300. export * from "babylonjs/Misc/andOrNotEvaluator";
  72301. export * from "babylonjs/Misc/assetsManager";
  72302. export * from "babylonjs/Misc/basis";
  72303. export * from "babylonjs/Misc/dds";
  72304. export * from "babylonjs/Misc/decorators";
  72305. export * from "babylonjs/Misc/deferred";
  72306. export * from "babylonjs/Misc/environmentTextureTools";
  72307. export * from "babylonjs/Misc/meshExploder";
  72308. export * from "babylonjs/Misc/filesInput";
  72309. export * from "babylonjs/Misc/HighDynamicRange/index";
  72310. export * from "babylonjs/Misc/khronosTextureContainer";
  72311. export * from "babylonjs/Misc/observable";
  72312. export * from "babylonjs/Misc/performanceMonitor";
  72313. export * from "babylonjs/Misc/promise";
  72314. export * from "babylonjs/Misc/sceneOptimizer";
  72315. export * from "babylonjs/Misc/sceneSerializer";
  72316. export * from "babylonjs/Misc/smartArray";
  72317. export * from "babylonjs/Misc/stringDictionary";
  72318. export * from "babylonjs/Misc/tags";
  72319. export * from "babylonjs/Misc/textureTools";
  72320. export * from "babylonjs/Misc/tga";
  72321. export * from "babylonjs/Misc/tools";
  72322. export * from "babylonjs/Misc/videoRecorder";
  72323. export * from "babylonjs/Misc/virtualJoystick";
  72324. export * from "babylonjs/Misc/workerPool";
  72325. export * from "babylonjs/Misc/logger";
  72326. export * from "babylonjs/Misc/typeStore";
  72327. export * from "babylonjs/Misc/filesInputStore";
  72328. export * from "babylonjs/Misc/deepCopier";
  72329. export * from "babylonjs/Misc/pivotTools";
  72330. export * from "babylonjs/Misc/precisionDate";
  72331. export * from "babylonjs/Misc/screenshotTools";
  72332. export * from "babylonjs/Misc/typeStore";
  72333. export * from "babylonjs/Misc/webRequest";
  72334. export * from "babylonjs/Misc/iInspectable";
  72335. export * from "babylonjs/Misc/brdfTextureTools";
  72336. export * from "babylonjs/Misc/rgbdTextureTools";
  72337. export * from "babylonjs/Misc/gradients";
  72338. export * from "babylonjs/Misc/perfCounter";
  72339. export * from "babylonjs/Misc/fileRequest";
  72340. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72341. export * from "babylonjs/Misc/retryStrategy";
  72342. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72343. export * from "babylonjs/Misc/canvasGenerator";
  72344. export * from "babylonjs/Misc/fileTools";
  72345. export * from "babylonjs/Misc/stringTools";
  72346. export * from "babylonjs/Misc/dataReader";
  72347. export * from "babylonjs/Misc/minMaxReducer";
  72348. export * from "babylonjs/Misc/depthReducer";
  72349. }
  72350. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72351. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72352. import { Observable } from "babylonjs/Misc/observable";
  72353. import { Matrix } from "babylonjs/Maths/math.vector";
  72354. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72355. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72356. /**
  72357. * Options used for hit testing
  72358. */
  72359. export interface IWebXRHitTestOptions {
  72360. /**
  72361. * Only test when user interacted with the scene. Default - hit test every frame
  72362. */
  72363. testOnPointerDownOnly?: boolean;
  72364. /**
  72365. * The node to use to transform the local results to world coordinates
  72366. */
  72367. worldParentNode?: TransformNode;
  72368. }
  72369. /**
  72370. * Interface defining the babylon result of raycasting/hit-test
  72371. */
  72372. export interface IWebXRHitResult {
  72373. /**
  72374. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72375. */
  72376. transformationMatrix: Matrix;
  72377. /**
  72378. * The native hit test result
  72379. */
  72380. xrHitResult: XRHitResult;
  72381. }
  72382. /**
  72383. * The currently-working hit-test module.
  72384. * Hit test (or Ray-casting) is used to interact with the real world.
  72385. * For further information read here - https://github.com/immersive-web/hit-test
  72386. */
  72387. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72388. /**
  72389. * options to use when constructing this feature
  72390. */
  72391. readonly options: IWebXRHitTestOptions;
  72392. private _direction;
  72393. private _mat;
  72394. private _onSelectEnabled;
  72395. private _origin;
  72396. /**
  72397. * The module's name
  72398. */
  72399. static readonly Name: string;
  72400. /**
  72401. * The (Babylon) version of this module.
  72402. * This is an integer representing the implementation version.
  72403. * This number does not correspond to the WebXR specs version
  72404. */
  72405. static readonly Version: number;
  72406. /**
  72407. * Populated with the last native XR Hit Results
  72408. */
  72409. lastNativeXRHitResults: XRHitResult[];
  72410. /**
  72411. * Triggered when new babylon (transformed) hit test results are available
  72412. */
  72413. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72414. /**
  72415. * Creates a new instance of the (legacy version) hit test feature
  72416. * @param _xrSessionManager an instance of WebXRSessionManager
  72417. * @param options options to use when constructing this feature
  72418. */
  72419. constructor(_xrSessionManager: WebXRSessionManager,
  72420. /**
  72421. * options to use when constructing this feature
  72422. */
  72423. options?: IWebXRHitTestOptions);
  72424. /**
  72425. * execute a hit test with an XR Ray
  72426. *
  72427. * @param xrSession a native xrSession that will execute this hit test
  72428. * @param xrRay the ray (position and direction) to use for ray-casting
  72429. * @param referenceSpace native XR reference space to use for the hit-test
  72430. * @param filter filter function that will filter the results
  72431. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72432. */
  72433. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72434. /**
  72435. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72436. * @param event the (select) event to use to select with
  72437. * @param referenceSpace the reference space to use for this hit test
  72438. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72439. */
  72440. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72441. /**
  72442. * attach this feature
  72443. * Will usually be called by the features manager
  72444. *
  72445. * @returns true if successful.
  72446. */
  72447. attach(): boolean;
  72448. /**
  72449. * detach this feature.
  72450. * Will usually be called by the features manager
  72451. *
  72452. * @returns true if successful.
  72453. */
  72454. detach(): boolean;
  72455. /**
  72456. * Dispose this feature and all of the resources attached
  72457. */
  72458. dispose(): void;
  72459. protected _onXRFrame(frame: XRFrame): void;
  72460. private _onHitTestResults;
  72461. private _onSelect;
  72462. }
  72463. }
  72464. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72465. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72466. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72467. import { Observable } from "babylonjs/Misc/observable";
  72468. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72469. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72470. /**
  72471. * Options used in the plane detector module
  72472. */
  72473. export interface IWebXRPlaneDetectorOptions {
  72474. /**
  72475. * The node to use to transform the local results to world coordinates
  72476. */
  72477. worldParentNode?: TransformNode;
  72478. }
  72479. /**
  72480. * A babylon interface for a WebXR plane.
  72481. * A Plane is actually a polygon, built from N points in space
  72482. *
  72483. * Supported in chrome 79, not supported in canary 81 ATM
  72484. */
  72485. export interface IWebXRPlane {
  72486. /**
  72487. * a babylon-assigned ID for this polygon
  72488. */
  72489. id: number;
  72490. /**
  72491. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72492. */
  72493. polygonDefinition: Array<Vector3>;
  72494. /**
  72495. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72496. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72497. */
  72498. transformationMatrix: Matrix;
  72499. /**
  72500. * the native xr-plane object
  72501. */
  72502. xrPlane: XRPlane;
  72503. }
  72504. /**
  72505. * The plane detector is used to detect planes in the real world when in AR
  72506. * For more information see https://github.com/immersive-web/real-world-geometry/
  72507. */
  72508. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72509. private _options;
  72510. private _detectedPlanes;
  72511. private _enabled;
  72512. private _lastFrameDetected;
  72513. /**
  72514. * The module's name
  72515. */
  72516. static readonly Name: string;
  72517. /**
  72518. * The (Babylon) version of this module.
  72519. * This is an integer representing the implementation version.
  72520. * This number does not correspond to the WebXR specs version
  72521. */
  72522. static readonly Version: number;
  72523. /**
  72524. * Observers registered here will be executed when a new plane was added to the session
  72525. */
  72526. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72527. /**
  72528. * Observers registered here will be executed when a plane is no longer detected in the session
  72529. */
  72530. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72531. /**
  72532. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72533. * This can execute N times every frame
  72534. */
  72535. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72536. /**
  72537. * construct a new Plane Detector
  72538. * @param _xrSessionManager an instance of xr Session manager
  72539. * @param _options configuration to use when constructing this feature
  72540. */
  72541. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72542. /**
  72543. * Dispose this feature and all of the resources attached
  72544. */
  72545. dispose(): void;
  72546. protected _onXRFrame(frame: XRFrame): void;
  72547. private _init;
  72548. private _updatePlaneWithXRPlane;
  72549. /**
  72550. * avoiding using Array.find for global support.
  72551. * @param xrPlane the plane to find in the array
  72552. */
  72553. private findIndexInPlaneArray;
  72554. }
  72555. }
  72556. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72557. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72558. import { Observable } from "babylonjs/Misc/observable";
  72559. import { Matrix } from "babylonjs/Maths/math.vector";
  72560. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72561. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72562. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72563. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72564. /**
  72565. * Configuration options of the anchor system
  72566. */
  72567. export interface IWebXRAnchorSystemOptions {
  72568. /**
  72569. * Should a new anchor be added every time a select event is triggered
  72570. */
  72571. addAnchorOnSelect?: boolean;
  72572. /**
  72573. * should the anchor system use plane detection.
  72574. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72575. */
  72576. usePlaneDetection?: boolean;
  72577. /**
  72578. * a node that will be used to convert local to world coordinates
  72579. */
  72580. worldParentNode?: TransformNode;
  72581. }
  72582. /**
  72583. * A babylon container for an XR Anchor
  72584. */
  72585. export interface IWebXRAnchor {
  72586. /**
  72587. * A babylon-assigned ID for this anchor
  72588. */
  72589. id: number;
  72590. /**
  72591. * Transformation matrix to apply to an object attached to this anchor
  72592. */
  72593. transformationMatrix: Matrix;
  72594. /**
  72595. * The native anchor object
  72596. */
  72597. xrAnchor: XRAnchor;
  72598. }
  72599. /**
  72600. * An implementation of the anchor system of WebXR.
  72601. * Note that the current documented implementation is not available in any browser. Future implementations
  72602. * will use the frame to create an anchor and not the session or a detected plane
  72603. * For further information see https://github.com/immersive-web/anchors/
  72604. */
  72605. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72606. private _options;
  72607. private _enabled;
  72608. private _hitTestModule;
  72609. private _lastFrameDetected;
  72610. private _onSelect;
  72611. private _planeDetector;
  72612. private _trackedAnchors;
  72613. /**
  72614. * The module's name
  72615. */
  72616. static readonly Name: string;
  72617. /**
  72618. * The (Babylon) version of this module.
  72619. * This is an integer representing the implementation version.
  72620. * This number does not correspond to the WebXR specs version
  72621. */
  72622. static readonly Version: number;
  72623. /**
  72624. * Observers registered here will be executed when a new anchor was added to the session
  72625. */
  72626. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72627. /**
  72628. * Observers registered here will be executed when an anchor was removed from the session
  72629. */
  72630. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72631. /**
  72632. * Observers registered here will be executed when an existing anchor updates
  72633. * This can execute N times every frame
  72634. */
  72635. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72636. /**
  72637. * constructs a new anchor system
  72638. * @param _xrSessionManager an instance of WebXRSessionManager
  72639. * @param _options configuration object for this feature
  72640. */
  72641. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72642. /**
  72643. * Add anchor at a specific XR point.
  72644. *
  72645. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72646. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72647. * @returns a promise the fulfills when the anchor was created
  72648. */
  72649. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72650. /**
  72651. * attach this feature
  72652. * Will usually be called by the features manager
  72653. *
  72654. * @returns true if successful.
  72655. */
  72656. attach(): boolean;
  72657. /**
  72658. * detach this feature.
  72659. * Will usually be called by the features manager
  72660. *
  72661. * @returns true if successful.
  72662. */
  72663. detach(): boolean;
  72664. /**
  72665. * Dispose this feature and all of the resources attached
  72666. */
  72667. dispose(): void;
  72668. /**
  72669. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72670. * @param hitTestModule the hit-test module to use.
  72671. */
  72672. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72673. /**
  72674. * set the plane detector to use in order to create anchors from frames
  72675. * @param planeDetector the plane-detector module to use
  72676. * @param enable enable plane-anchors. default is true
  72677. */
  72678. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72679. protected _onXRFrame(frame: XRFrame): void;
  72680. /**
  72681. * avoiding using Array.find for global support.
  72682. * @param xrAnchor the plane to find in the array
  72683. */
  72684. private _findIndexInAnchorArray;
  72685. private _updateAnchorWithXRFrame;
  72686. }
  72687. }
  72688. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72689. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72691. import { Observable } from "babylonjs/Misc/observable";
  72692. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72693. /**
  72694. * Options interface for the background remover plugin
  72695. */
  72696. export interface IWebXRBackgroundRemoverOptions {
  72697. /**
  72698. * Further background meshes to disable when entering AR
  72699. */
  72700. backgroundMeshes?: AbstractMesh[];
  72701. /**
  72702. * flags to configure the removal of the environment helper.
  72703. * If not set, the entire background will be removed. If set, flags should be set as well.
  72704. */
  72705. environmentHelperRemovalFlags?: {
  72706. /**
  72707. * Should the skybox be removed (default false)
  72708. */
  72709. skyBox?: boolean;
  72710. /**
  72711. * Should the ground be removed (default false)
  72712. */
  72713. ground?: boolean;
  72714. };
  72715. /**
  72716. * don't disable the environment helper
  72717. */
  72718. ignoreEnvironmentHelper?: boolean;
  72719. }
  72720. /**
  72721. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72722. */
  72723. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72724. /**
  72725. * read-only options to be used in this module
  72726. */
  72727. readonly options: IWebXRBackgroundRemoverOptions;
  72728. /**
  72729. * The module's name
  72730. */
  72731. static readonly Name: string;
  72732. /**
  72733. * The (Babylon) version of this module.
  72734. * This is an integer representing the implementation version.
  72735. * This number does not correspond to the WebXR specs version
  72736. */
  72737. static readonly Version: number;
  72738. /**
  72739. * registered observers will be triggered when the background state changes
  72740. */
  72741. onBackgroundStateChangedObservable: Observable<boolean>;
  72742. /**
  72743. * constructs a new background remover module
  72744. * @param _xrSessionManager the session manager for this module
  72745. * @param options read-only options to be used in this module
  72746. */
  72747. constructor(_xrSessionManager: WebXRSessionManager,
  72748. /**
  72749. * read-only options to be used in this module
  72750. */
  72751. options?: IWebXRBackgroundRemoverOptions);
  72752. /**
  72753. * attach this feature
  72754. * Will usually be called by the features manager
  72755. *
  72756. * @returns true if successful.
  72757. */
  72758. attach(): boolean;
  72759. /**
  72760. * detach this feature.
  72761. * Will usually be called by the features manager
  72762. *
  72763. * @returns true if successful.
  72764. */
  72765. detach(): boolean;
  72766. /**
  72767. * Dispose this feature and all of the resources attached
  72768. */
  72769. dispose(): void;
  72770. protected _onXRFrame(_xrFrame: XRFrame): void;
  72771. private _setBackgroundState;
  72772. }
  72773. }
  72774. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72775. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72776. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72777. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72778. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72779. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72780. import { Nullable } from "babylonjs/types";
  72781. /**
  72782. * Options for the controller physics feature
  72783. */
  72784. export class IWebXRControllerPhysicsOptions {
  72785. /**
  72786. * Should the headset get its own impostor
  72787. */
  72788. enableHeadsetImpostor?: boolean;
  72789. /**
  72790. * Optional parameters for the headset impostor
  72791. */
  72792. headsetImpostorParams?: {
  72793. /**
  72794. * The type of impostor to create. Default is sphere
  72795. */
  72796. impostorType: number;
  72797. /**
  72798. * the size of the impostor. Defaults to 10cm
  72799. */
  72800. impostorSize?: number | {
  72801. width: number;
  72802. height: number;
  72803. depth: number;
  72804. };
  72805. /**
  72806. * Friction definitions
  72807. */
  72808. friction?: number;
  72809. /**
  72810. * Restitution
  72811. */
  72812. restitution?: number;
  72813. };
  72814. /**
  72815. * The physics properties of the future impostors
  72816. */
  72817. physicsProperties?: {
  72818. /**
  72819. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72820. * Note that this requires a physics engine that supports mesh impostors!
  72821. */
  72822. useControllerMesh?: boolean;
  72823. /**
  72824. * The type of impostor to create. Default is sphere
  72825. */
  72826. impostorType?: number;
  72827. /**
  72828. * the size of the impostor. Defaults to 10cm
  72829. */
  72830. impostorSize?: number | {
  72831. width: number;
  72832. height: number;
  72833. depth: number;
  72834. };
  72835. /**
  72836. * Friction definitions
  72837. */
  72838. friction?: number;
  72839. /**
  72840. * Restitution
  72841. */
  72842. restitution?: number;
  72843. };
  72844. /**
  72845. * the xr input to use with this pointer selection
  72846. */
  72847. xrInput: WebXRInput;
  72848. }
  72849. /**
  72850. * Add physics impostor to your webxr controllers,
  72851. * including naive calculation of their linear and angular velocity
  72852. */
  72853. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72854. private readonly _options;
  72855. private _attachController;
  72856. private _controllers;
  72857. private _debugMode;
  72858. private _delta;
  72859. private _headsetImpostor?;
  72860. private _headsetMesh?;
  72861. private _lastTimestamp;
  72862. private _tmpQuaternion;
  72863. private _tmpVector;
  72864. /**
  72865. * The module's name
  72866. */
  72867. static readonly Name: string;
  72868. /**
  72869. * The (Babylon) version of this module.
  72870. * This is an integer representing the implementation version.
  72871. * This number does not correspond to the webxr specs version
  72872. */
  72873. static readonly Version: number;
  72874. /**
  72875. * Construct a new Controller Physics Feature
  72876. * @param _xrSessionManager the corresponding xr session manager
  72877. * @param _options options to create this feature with
  72878. */
  72879. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72880. /**
  72881. * @hidden
  72882. * enable debugging - will show console outputs and the impostor mesh
  72883. */
  72884. _enablePhysicsDebug(): void;
  72885. /**
  72886. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72887. * @param xrController the controller to add
  72888. */
  72889. addController(xrController: WebXRInputSource): void;
  72890. /**
  72891. * attach this feature
  72892. * Will usually be called by the features manager
  72893. *
  72894. * @returns true if successful.
  72895. */
  72896. attach(): boolean;
  72897. /**
  72898. * detach this feature.
  72899. * Will usually be called by the features manager
  72900. *
  72901. * @returns true if successful.
  72902. */
  72903. detach(): boolean;
  72904. /**
  72905. * Get the headset impostor, if enabled
  72906. * @returns the impostor
  72907. */
  72908. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72909. /**
  72910. * Get the physics impostor of a specific controller.
  72911. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72912. * @param controller the controller or the controller id of which to get the impostor
  72913. * @returns the impostor or null
  72914. */
  72915. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72916. /**
  72917. * Update the physics properties provided in the constructor
  72918. * @param newProperties the new properties object
  72919. */
  72920. setPhysicsProperties(newProperties: {
  72921. impostorType?: number;
  72922. impostorSize?: number | {
  72923. width: number;
  72924. height: number;
  72925. depth: number;
  72926. };
  72927. friction?: number;
  72928. restitution?: number;
  72929. }): void;
  72930. protected _onXRFrame(_xrFrame: any): void;
  72931. private _detachController;
  72932. }
  72933. }
  72934. declare module "babylonjs/XR/features/index" {
  72935. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72936. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72937. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72938. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72939. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72940. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72941. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72942. }
  72943. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72944. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72946. import { Scene } from "babylonjs/scene";
  72947. /**
  72948. * The motion controller class for all microsoft mixed reality controllers
  72949. */
  72950. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72951. protected readonly _mapping: {
  72952. defaultButton: {
  72953. "valueNodeName": string;
  72954. "unpressedNodeName": string;
  72955. "pressedNodeName": string;
  72956. };
  72957. defaultAxis: {
  72958. "valueNodeName": string;
  72959. "minNodeName": string;
  72960. "maxNodeName": string;
  72961. };
  72962. buttons: {
  72963. "xr-standard-trigger": {
  72964. "rootNodeName": string;
  72965. "componentProperty": string;
  72966. "states": string[];
  72967. };
  72968. "xr-standard-squeeze": {
  72969. "rootNodeName": string;
  72970. "componentProperty": string;
  72971. "states": string[];
  72972. };
  72973. "xr-standard-touchpad": {
  72974. "rootNodeName": string;
  72975. "labelAnchorNodeName": string;
  72976. "touchPointNodeName": string;
  72977. };
  72978. "xr-standard-thumbstick": {
  72979. "rootNodeName": string;
  72980. "componentProperty": string;
  72981. "states": string[];
  72982. };
  72983. };
  72984. axes: {
  72985. "xr-standard-touchpad": {
  72986. "x-axis": {
  72987. "rootNodeName": string;
  72988. };
  72989. "y-axis": {
  72990. "rootNodeName": string;
  72991. };
  72992. };
  72993. "xr-standard-thumbstick": {
  72994. "x-axis": {
  72995. "rootNodeName": string;
  72996. };
  72997. "y-axis": {
  72998. "rootNodeName": string;
  72999. };
  73000. };
  73001. };
  73002. };
  73003. /**
  73004. * The base url used to load the left and right controller models
  73005. */
  73006. static MODEL_BASE_URL: string;
  73007. /**
  73008. * The name of the left controller model file
  73009. */
  73010. static MODEL_LEFT_FILENAME: string;
  73011. /**
  73012. * The name of the right controller model file
  73013. */
  73014. static MODEL_RIGHT_FILENAME: string;
  73015. profileId: string;
  73016. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73017. protected _getFilenameAndPath(): {
  73018. filename: string;
  73019. path: string;
  73020. };
  73021. protected _getModelLoadingConstraints(): boolean;
  73022. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73023. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73024. protected _updateModel(): void;
  73025. }
  73026. }
  73027. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73028. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73030. import { Scene } from "babylonjs/scene";
  73031. /**
  73032. * The motion controller class for oculus touch (quest, rift).
  73033. * This class supports legacy mapping as well the standard xr mapping
  73034. */
  73035. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73036. private _forceLegacyControllers;
  73037. private _modelRootNode;
  73038. /**
  73039. * The base url used to load the left and right controller models
  73040. */
  73041. static MODEL_BASE_URL: string;
  73042. /**
  73043. * The name of the left controller model file
  73044. */
  73045. static MODEL_LEFT_FILENAME: string;
  73046. /**
  73047. * The name of the right controller model file
  73048. */
  73049. static MODEL_RIGHT_FILENAME: string;
  73050. /**
  73051. * Base Url for the Quest controller model.
  73052. */
  73053. static QUEST_MODEL_BASE_URL: string;
  73054. profileId: string;
  73055. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73056. protected _getFilenameAndPath(): {
  73057. filename: string;
  73058. path: string;
  73059. };
  73060. protected _getModelLoadingConstraints(): boolean;
  73061. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73062. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73063. protected _updateModel(): void;
  73064. /**
  73065. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73066. * between the touch and touch 2.
  73067. */
  73068. private _isQuest;
  73069. }
  73070. }
  73071. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73072. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73073. import { Scene } from "babylonjs/scene";
  73074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73075. /**
  73076. * The motion controller class for the standard HTC-Vive controllers
  73077. */
  73078. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73079. private _modelRootNode;
  73080. /**
  73081. * The base url used to load the left and right controller models
  73082. */
  73083. static MODEL_BASE_URL: string;
  73084. /**
  73085. * File name for the controller model.
  73086. */
  73087. static MODEL_FILENAME: string;
  73088. profileId: string;
  73089. /**
  73090. * Create a new Vive motion controller object
  73091. * @param scene the scene to use to create this controller
  73092. * @param gamepadObject the corresponding gamepad object
  73093. * @param handness the handness of the controller
  73094. */
  73095. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73096. protected _getFilenameAndPath(): {
  73097. filename: string;
  73098. path: string;
  73099. };
  73100. protected _getModelLoadingConstraints(): boolean;
  73101. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73102. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73103. protected _updateModel(): void;
  73104. }
  73105. }
  73106. declare module "babylonjs/XR/motionController/index" {
  73107. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73108. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73109. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73110. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73111. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73112. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73113. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73114. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73115. }
  73116. declare module "babylonjs/XR/index" {
  73117. export * from "babylonjs/XR/webXRCamera";
  73118. export * from "babylonjs/XR/webXREnterExitUI";
  73119. export * from "babylonjs/XR/webXRExperienceHelper";
  73120. export * from "babylonjs/XR/webXRInput";
  73121. export * from "babylonjs/XR/webXRInputSource";
  73122. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73123. export * from "babylonjs/XR/webXRTypes";
  73124. export * from "babylonjs/XR/webXRSessionManager";
  73125. export * from "babylonjs/XR/webXRDefaultExperience";
  73126. export * from "babylonjs/XR/webXRFeaturesManager";
  73127. export * from "babylonjs/XR/features/index";
  73128. export * from "babylonjs/XR/motionController/index";
  73129. }
  73130. declare module "babylonjs/index" {
  73131. export * from "babylonjs/abstractScene";
  73132. export * from "babylonjs/Actions/index";
  73133. export * from "babylonjs/Animations/index";
  73134. export * from "babylonjs/assetContainer";
  73135. export * from "babylonjs/Audio/index";
  73136. export * from "babylonjs/Behaviors/index";
  73137. export * from "babylonjs/Bones/index";
  73138. export * from "babylonjs/Cameras/index";
  73139. export * from "babylonjs/Collisions/index";
  73140. export * from "babylonjs/Culling/index";
  73141. export * from "babylonjs/Debug/index";
  73142. export * from "babylonjs/Engines/index";
  73143. export * from "babylonjs/Events/index";
  73144. export * from "babylonjs/Gamepads/index";
  73145. export * from "babylonjs/Gizmos/index";
  73146. export * from "babylonjs/Helpers/index";
  73147. export * from "babylonjs/Instrumentation/index";
  73148. export * from "babylonjs/Layers/index";
  73149. export * from "babylonjs/LensFlares/index";
  73150. export * from "babylonjs/Lights/index";
  73151. export * from "babylonjs/Loading/index";
  73152. export * from "babylonjs/Materials/index";
  73153. export * from "babylonjs/Maths/index";
  73154. export * from "babylonjs/Meshes/index";
  73155. export * from "babylonjs/Morph/index";
  73156. export * from "babylonjs/Navigation/index";
  73157. export * from "babylonjs/node";
  73158. export * from "babylonjs/Offline/index";
  73159. export * from "babylonjs/Particles/index";
  73160. export * from "babylonjs/Physics/index";
  73161. export * from "babylonjs/PostProcesses/index";
  73162. export * from "babylonjs/Probes/index";
  73163. export * from "babylonjs/Rendering/index";
  73164. export * from "babylonjs/scene";
  73165. export * from "babylonjs/sceneComponent";
  73166. export * from "babylonjs/Sprites/index";
  73167. export * from "babylonjs/States/index";
  73168. export * from "babylonjs/Misc/index";
  73169. export * from "babylonjs/XR/index";
  73170. export * from "babylonjs/types";
  73171. }
  73172. declare module "babylonjs/Animations/pathCursor" {
  73173. import { Vector3 } from "babylonjs/Maths/math.vector";
  73174. import { Path2 } from "babylonjs/Maths/math.path";
  73175. /**
  73176. * A cursor which tracks a point on a path
  73177. */
  73178. export class PathCursor {
  73179. private path;
  73180. /**
  73181. * Stores path cursor callbacks for when an onchange event is triggered
  73182. */
  73183. private _onchange;
  73184. /**
  73185. * The value of the path cursor
  73186. */
  73187. value: number;
  73188. /**
  73189. * The animation array of the path cursor
  73190. */
  73191. animations: Animation[];
  73192. /**
  73193. * Initializes the path cursor
  73194. * @param path The path to track
  73195. */
  73196. constructor(path: Path2);
  73197. /**
  73198. * Gets the cursor point on the path
  73199. * @returns A point on the path cursor at the cursor location
  73200. */
  73201. getPoint(): Vector3;
  73202. /**
  73203. * Moves the cursor ahead by the step amount
  73204. * @param step The amount to move the cursor forward
  73205. * @returns This path cursor
  73206. */
  73207. moveAhead(step?: number): PathCursor;
  73208. /**
  73209. * Moves the cursor behind by the step amount
  73210. * @param step The amount to move the cursor back
  73211. * @returns This path cursor
  73212. */
  73213. moveBack(step?: number): PathCursor;
  73214. /**
  73215. * Moves the cursor by the step amount
  73216. * If the step amount is greater than one, an exception is thrown
  73217. * @param step The amount to move the cursor
  73218. * @returns This path cursor
  73219. */
  73220. move(step: number): PathCursor;
  73221. /**
  73222. * Ensures that the value is limited between zero and one
  73223. * @returns This path cursor
  73224. */
  73225. private ensureLimits;
  73226. /**
  73227. * Runs onchange callbacks on change (used by the animation engine)
  73228. * @returns This path cursor
  73229. */
  73230. private raiseOnChange;
  73231. /**
  73232. * Executes a function on change
  73233. * @param f A path cursor onchange callback
  73234. * @returns This path cursor
  73235. */
  73236. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73237. }
  73238. }
  73239. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73240. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73241. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73242. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73243. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73244. }
  73245. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73246. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73247. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73248. }
  73249. declare module "babylonjs/Engines/Processors/index" {
  73250. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73251. export * from "babylonjs/Engines/Processors/Expressions/index";
  73252. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73253. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73254. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73255. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73256. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73257. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73258. }
  73259. declare module "babylonjs/Legacy/legacy" {
  73260. import * as Babylon from "babylonjs/index";
  73261. export * from "babylonjs/index";
  73262. }
  73263. declare module "babylonjs/Shaders/blur.fragment" {
  73264. /** @hidden */
  73265. export var blurPixelShader: {
  73266. name: string;
  73267. shader: string;
  73268. };
  73269. }
  73270. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73271. /** @hidden */
  73272. export var pointCloudVertexDeclaration: {
  73273. name: string;
  73274. shader: string;
  73275. };
  73276. }
  73277. declare module "babylonjs" {
  73278. export * from "babylonjs/Legacy/legacy";
  73279. }
  73280. declare module BABYLON {
  73281. /** Alias type for value that can be null */
  73282. export type Nullable<T> = T | null;
  73283. /**
  73284. * Alias type for number that are floats
  73285. * @ignorenaming
  73286. */
  73287. export type float = number;
  73288. /**
  73289. * Alias type for number that are doubles.
  73290. * @ignorenaming
  73291. */
  73292. export type double = number;
  73293. /**
  73294. * Alias type for number that are integer
  73295. * @ignorenaming
  73296. */
  73297. export type int = number;
  73298. /** Alias type for number array or Float32Array */
  73299. export type FloatArray = number[] | Float32Array;
  73300. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73301. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73302. /**
  73303. * Alias for types that can be used by a Buffer or VertexBuffer.
  73304. */
  73305. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73306. /**
  73307. * Alias type for primitive types
  73308. * @ignorenaming
  73309. */
  73310. type Primitive = undefined | null | boolean | string | number | Function;
  73311. /**
  73312. * Type modifier to make all the properties of an object Readonly
  73313. */
  73314. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73315. /**
  73316. * Type modifier to make all the properties of an object Readonly recursively
  73317. */
  73318. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73319. /**
  73320. * Type modifier to make object properties readonly.
  73321. */
  73322. export type DeepImmutableObject<T> = {
  73323. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73324. };
  73325. /** @hidden */
  73326. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73327. }
  73328. }
  73329. declare module BABYLON {
  73330. /**
  73331. * A class serves as a medium between the observable and its observers
  73332. */
  73333. export class EventState {
  73334. /**
  73335. * Create a new EventState
  73336. * @param mask defines the mask associated with this state
  73337. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73338. * @param target defines the original target of the state
  73339. * @param currentTarget defines the current target of the state
  73340. */
  73341. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73342. /**
  73343. * Initialize the current event state
  73344. * @param mask defines the mask associated with this state
  73345. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73346. * @param target defines the original target of the state
  73347. * @param currentTarget defines the current target of the state
  73348. * @returns the current event state
  73349. */
  73350. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73351. /**
  73352. * An Observer can set this property to true to prevent subsequent observers of being notified
  73353. */
  73354. skipNextObservers: boolean;
  73355. /**
  73356. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73357. */
  73358. mask: number;
  73359. /**
  73360. * The object that originally notified the event
  73361. */
  73362. target?: any;
  73363. /**
  73364. * The current object in the bubbling phase
  73365. */
  73366. currentTarget?: any;
  73367. /**
  73368. * This will be populated with the return value of the last function that was executed.
  73369. * If it is the first function in the callback chain it will be the event data.
  73370. */
  73371. lastReturnValue?: any;
  73372. }
  73373. /**
  73374. * Represent an Observer registered to a given Observable object.
  73375. */
  73376. export class Observer<T> {
  73377. /**
  73378. * Defines the callback to call when the observer is notified
  73379. */
  73380. callback: (eventData: T, eventState: EventState) => void;
  73381. /**
  73382. * Defines the mask of the observer (used to filter notifications)
  73383. */
  73384. mask: number;
  73385. /**
  73386. * Defines the current scope used to restore the JS context
  73387. */
  73388. scope: any;
  73389. /** @hidden */
  73390. _willBeUnregistered: boolean;
  73391. /**
  73392. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73393. */
  73394. unregisterOnNextCall: boolean;
  73395. /**
  73396. * Creates a new observer
  73397. * @param callback defines the callback to call when the observer is notified
  73398. * @param mask defines the mask of the observer (used to filter notifications)
  73399. * @param scope defines the current scope used to restore the JS context
  73400. */
  73401. constructor(
  73402. /**
  73403. * Defines the callback to call when the observer is notified
  73404. */
  73405. callback: (eventData: T, eventState: EventState) => void,
  73406. /**
  73407. * Defines the mask of the observer (used to filter notifications)
  73408. */
  73409. mask: number,
  73410. /**
  73411. * Defines the current scope used to restore the JS context
  73412. */
  73413. scope?: any);
  73414. }
  73415. /**
  73416. * Represent a list of observers registered to multiple Observables object.
  73417. */
  73418. export class MultiObserver<T> {
  73419. private _observers;
  73420. private _observables;
  73421. /**
  73422. * Release associated resources
  73423. */
  73424. dispose(): void;
  73425. /**
  73426. * Raise a callback when one of the observable will notify
  73427. * @param observables defines a list of observables to watch
  73428. * @param callback defines the callback to call on notification
  73429. * @param mask defines the mask used to filter notifications
  73430. * @param scope defines the current scope used to restore the JS context
  73431. * @returns the new MultiObserver
  73432. */
  73433. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73434. }
  73435. /**
  73436. * The Observable class is a simple implementation of the Observable pattern.
  73437. *
  73438. * 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.
  73439. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73440. * 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).
  73441. * 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.
  73442. */
  73443. export class Observable<T> {
  73444. private _observers;
  73445. private _eventState;
  73446. private _onObserverAdded;
  73447. /**
  73448. * Gets the list of observers
  73449. */
  73450. get observers(): Array<Observer<T>>;
  73451. /**
  73452. * Creates a new observable
  73453. * @param onObserverAdded defines a callback to call when a new observer is added
  73454. */
  73455. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73456. /**
  73457. * Create a new Observer with the specified callback
  73458. * @param callback the callback that will be executed for that Observer
  73459. * @param mask the mask used to filter observers
  73460. * @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.
  73461. * @param scope optional scope for the callback to be called from
  73462. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73463. * @returns the new observer created for the callback
  73464. */
  73465. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73466. /**
  73467. * Create a new Observer with the specified callback and unregisters after the next notification
  73468. * @param callback the callback that will be executed for that Observer
  73469. * @returns the new observer created for the callback
  73470. */
  73471. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73472. /**
  73473. * Remove an Observer from the Observable object
  73474. * @param observer the instance of the Observer to remove
  73475. * @returns false if it doesn't belong to this Observable
  73476. */
  73477. remove(observer: Nullable<Observer<T>>): boolean;
  73478. /**
  73479. * Remove a callback from the Observable object
  73480. * @param callback the callback to remove
  73481. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73482. * @returns false if it doesn't belong to this Observable
  73483. */
  73484. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73485. private _deferUnregister;
  73486. private _remove;
  73487. /**
  73488. * Moves the observable to the top of the observer list making it get called first when notified
  73489. * @param observer the observer to move
  73490. */
  73491. makeObserverTopPriority(observer: Observer<T>): void;
  73492. /**
  73493. * Moves the observable to the bottom of the observer list making it get called last when notified
  73494. * @param observer the observer to move
  73495. */
  73496. makeObserverBottomPriority(observer: Observer<T>): void;
  73497. /**
  73498. * Notify all Observers by calling their respective callback with the given data
  73499. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73500. * @param eventData defines the data to send to all observers
  73501. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73502. * @param target defines the original target of the state
  73503. * @param currentTarget defines the current target of the state
  73504. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73505. */
  73506. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73507. /**
  73508. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73509. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73510. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73511. * and it is crucial that all callbacks will be executed.
  73512. * The order of the callbacks is kept, callbacks are not executed parallel.
  73513. *
  73514. * @param eventData The data to be sent to each callback
  73515. * @param mask is used to filter observers defaults to -1
  73516. * @param target defines the callback target (see EventState)
  73517. * @param currentTarget defines he current object in the bubbling phase
  73518. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73519. */
  73520. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73521. /**
  73522. * Notify a specific observer
  73523. * @param observer defines the observer to notify
  73524. * @param eventData defines the data to be sent to each callback
  73525. * @param mask is used to filter observers defaults to -1
  73526. */
  73527. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73528. /**
  73529. * Gets a boolean indicating if the observable has at least one observer
  73530. * @returns true is the Observable has at least one Observer registered
  73531. */
  73532. hasObservers(): boolean;
  73533. /**
  73534. * Clear the list of observers
  73535. */
  73536. clear(): void;
  73537. /**
  73538. * Clone the current observable
  73539. * @returns a new observable
  73540. */
  73541. clone(): Observable<T>;
  73542. /**
  73543. * Does this observable handles observer registered with a given mask
  73544. * @param mask defines the mask to be tested
  73545. * @return whether or not one observer registered with the given mask is handeled
  73546. **/
  73547. hasSpecificMask(mask?: number): boolean;
  73548. }
  73549. }
  73550. declare module BABYLON {
  73551. /**
  73552. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73553. * Babylon.js
  73554. */
  73555. export class DomManagement {
  73556. /**
  73557. * Checks if the window object exists
  73558. * @returns true if the window object exists
  73559. */
  73560. static IsWindowObjectExist(): boolean;
  73561. /**
  73562. * Checks if the navigator object exists
  73563. * @returns true if the navigator object exists
  73564. */
  73565. static IsNavigatorAvailable(): boolean;
  73566. /**
  73567. * Extracts text content from a DOM element hierarchy
  73568. * @param element defines the root element
  73569. * @returns a string
  73570. */
  73571. static GetDOMTextContent(element: HTMLElement): string;
  73572. }
  73573. }
  73574. declare module BABYLON {
  73575. /**
  73576. * Logger used througouht the application to allow configuration of
  73577. * the log level required for the messages.
  73578. */
  73579. export class Logger {
  73580. /**
  73581. * No log
  73582. */
  73583. static readonly NoneLogLevel: number;
  73584. /**
  73585. * Only message logs
  73586. */
  73587. static readonly MessageLogLevel: number;
  73588. /**
  73589. * Only warning logs
  73590. */
  73591. static readonly WarningLogLevel: number;
  73592. /**
  73593. * Only error logs
  73594. */
  73595. static readonly ErrorLogLevel: number;
  73596. /**
  73597. * All logs
  73598. */
  73599. static readonly AllLogLevel: number;
  73600. private static _LogCache;
  73601. /**
  73602. * Gets a value indicating the number of loading errors
  73603. * @ignorenaming
  73604. */
  73605. static errorsCount: number;
  73606. /**
  73607. * Callback called when a new log is added
  73608. */
  73609. static OnNewCacheEntry: (entry: string) => void;
  73610. private static _AddLogEntry;
  73611. private static _FormatMessage;
  73612. private static _LogDisabled;
  73613. private static _LogEnabled;
  73614. private static _WarnDisabled;
  73615. private static _WarnEnabled;
  73616. private static _ErrorDisabled;
  73617. private static _ErrorEnabled;
  73618. /**
  73619. * Log a message to the console
  73620. */
  73621. static Log: (message: string) => void;
  73622. /**
  73623. * Write a warning message to the console
  73624. */
  73625. static Warn: (message: string) => void;
  73626. /**
  73627. * Write an error message to the console
  73628. */
  73629. static Error: (message: string) => void;
  73630. /**
  73631. * Gets current log cache (list of logs)
  73632. */
  73633. static get LogCache(): string;
  73634. /**
  73635. * Clears the log cache
  73636. */
  73637. static ClearLogCache(): void;
  73638. /**
  73639. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73640. */
  73641. static set LogLevels(level: number);
  73642. }
  73643. }
  73644. declare module BABYLON {
  73645. /** @hidden */
  73646. export class _TypeStore {
  73647. /** @hidden */
  73648. static RegisteredTypes: {
  73649. [key: string]: Object;
  73650. };
  73651. /** @hidden */
  73652. static GetClass(fqdn: string): any;
  73653. }
  73654. }
  73655. declare module BABYLON {
  73656. /**
  73657. * Helper to manipulate strings
  73658. */
  73659. export class StringTools {
  73660. /**
  73661. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73662. * @param str Source string
  73663. * @param suffix Suffix to search for in the source string
  73664. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73665. */
  73666. static EndsWith(str: string, suffix: string): boolean;
  73667. /**
  73668. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73669. * @param str Source string
  73670. * @param suffix Suffix to search for in the source string
  73671. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73672. */
  73673. static StartsWith(str: string, suffix: string): boolean;
  73674. /**
  73675. * Decodes a buffer into a string
  73676. * @param buffer The buffer to decode
  73677. * @returns The decoded string
  73678. */
  73679. static Decode(buffer: Uint8Array | Uint16Array): string;
  73680. /**
  73681. * Encode a buffer to a base64 string
  73682. * @param buffer defines the buffer to encode
  73683. * @returns the encoded string
  73684. */
  73685. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73686. }
  73687. }
  73688. declare module BABYLON {
  73689. /**
  73690. * Class containing a set of static utilities functions for deep copy.
  73691. */
  73692. export class DeepCopier {
  73693. /**
  73694. * Tries to copy an object by duplicating every property
  73695. * @param source defines the source object
  73696. * @param destination defines the target object
  73697. * @param doNotCopyList defines a list of properties to avoid
  73698. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73699. */
  73700. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73701. }
  73702. }
  73703. declare module BABYLON {
  73704. /**
  73705. * Class containing a set of static utilities functions for precision date
  73706. */
  73707. export class PrecisionDate {
  73708. /**
  73709. * Gets either window.performance.now() if supported or Date.now() else
  73710. */
  73711. static get Now(): number;
  73712. }
  73713. }
  73714. declare module BABYLON {
  73715. /** @hidden */
  73716. export class _DevTools {
  73717. static WarnImport(name: string): string;
  73718. }
  73719. }
  73720. declare module BABYLON {
  73721. /**
  73722. * Interface used to define the mechanism to get data from the network
  73723. */
  73724. export interface IWebRequest {
  73725. /**
  73726. * Returns client's response url
  73727. */
  73728. responseURL: string;
  73729. /**
  73730. * Returns client's status
  73731. */
  73732. status: number;
  73733. /**
  73734. * Returns client's status as a text
  73735. */
  73736. statusText: string;
  73737. }
  73738. }
  73739. declare module BABYLON {
  73740. /**
  73741. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73742. */
  73743. export class WebRequest implements IWebRequest {
  73744. private _xhr;
  73745. /**
  73746. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73747. * i.e. when loading files, where the server/service expects an Authorization header
  73748. */
  73749. static CustomRequestHeaders: {
  73750. [key: string]: string;
  73751. };
  73752. /**
  73753. * Add callback functions in this array to update all the requests before they get sent to the network
  73754. */
  73755. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73756. private _injectCustomRequestHeaders;
  73757. /**
  73758. * Gets or sets a function to be called when loading progress changes
  73759. */
  73760. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73761. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73762. /**
  73763. * Returns client's state
  73764. */
  73765. get readyState(): number;
  73766. /**
  73767. * Returns client's status
  73768. */
  73769. get status(): number;
  73770. /**
  73771. * Returns client's status as a text
  73772. */
  73773. get statusText(): string;
  73774. /**
  73775. * Returns client's response
  73776. */
  73777. get response(): any;
  73778. /**
  73779. * Returns client's response url
  73780. */
  73781. get responseURL(): string;
  73782. /**
  73783. * Returns client's response as text
  73784. */
  73785. get responseText(): string;
  73786. /**
  73787. * Gets or sets the expected response type
  73788. */
  73789. get responseType(): XMLHttpRequestResponseType;
  73790. set responseType(value: XMLHttpRequestResponseType);
  73791. /** @hidden */
  73792. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73793. /** @hidden */
  73794. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73795. /**
  73796. * Cancels any network activity
  73797. */
  73798. abort(): void;
  73799. /**
  73800. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73801. * @param body defines an optional request body
  73802. */
  73803. send(body?: Document | BodyInit | null): void;
  73804. /**
  73805. * Sets the request method, request URL
  73806. * @param method defines the method to use (GET, POST, etc..)
  73807. * @param url defines the url to connect with
  73808. */
  73809. open(method: string, url: string): void;
  73810. /**
  73811. * Sets the value of a request header.
  73812. * @param name The name of the header whose value is to be set
  73813. * @param value The value to set as the body of the header
  73814. */
  73815. setRequestHeader(name: string, value: string): void;
  73816. /**
  73817. * Get the string containing the text of a particular header's value.
  73818. * @param name The name of the header
  73819. * @returns The string containing the text of the given header name
  73820. */
  73821. getResponseHeader(name: string): Nullable<string>;
  73822. }
  73823. }
  73824. declare module BABYLON {
  73825. /**
  73826. * File request interface
  73827. */
  73828. export interface IFileRequest {
  73829. /**
  73830. * Raised when the request is complete (success or error).
  73831. */
  73832. onCompleteObservable: Observable<IFileRequest>;
  73833. /**
  73834. * Aborts the request for a file.
  73835. */
  73836. abort: () => void;
  73837. }
  73838. }
  73839. declare module BABYLON {
  73840. /**
  73841. * Define options used to create a render target texture
  73842. */
  73843. export class RenderTargetCreationOptions {
  73844. /**
  73845. * Specifies is mipmaps must be generated
  73846. */
  73847. generateMipMaps?: boolean;
  73848. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73849. generateDepthBuffer?: boolean;
  73850. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73851. generateStencilBuffer?: boolean;
  73852. /** Defines texture type (int by default) */
  73853. type?: number;
  73854. /** Defines sampling mode (trilinear by default) */
  73855. samplingMode?: number;
  73856. /** Defines format (RGBA by default) */
  73857. format?: number;
  73858. }
  73859. }
  73860. declare module BABYLON {
  73861. /** Defines the cross module used constants to avoid circular dependncies */
  73862. export class Constants {
  73863. /** Defines that alpha blending is disabled */
  73864. static readonly ALPHA_DISABLE: number;
  73865. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73866. static readonly ALPHA_ADD: number;
  73867. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73868. static readonly ALPHA_COMBINE: number;
  73869. /** Defines that alpha blending is DEST - SRC * DEST */
  73870. static readonly ALPHA_SUBTRACT: number;
  73871. /** Defines that alpha blending is SRC * DEST */
  73872. static readonly ALPHA_MULTIPLY: number;
  73873. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73874. static readonly ALPHA_MAXIMIZED: number;
  73875. /** Defines that alpha blending is SRC + DEST */
  73876. static readonly ALPHA_ONEONE: number;
  73877. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73878. static readonly ALPHA_PREMULTIPLIED: number;
  73879. /**
  73880. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73881. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73882. */
  73883. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73884. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73885. static readonly ALPHA_INTERPOLATE: number;
  73886. /**
  73887. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73888. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73889. */
  73890. static readonly ALPHA_SCREENMODE: number;
  73891. /**
  73892. * Defines that alpha blending is SRC + DST
  73893. * Alpha will be set to SRC ALPHA + DST ALPHA
  73894. */
  73895. static readonly ALPHA_ONEONE_ONEONE: number;
  73896. /**
  73897. * Defines that alpha blending is SRC * DST ALPHA + DST
  73898. * Alpha will be set to 0
  73899. */
  73900. static readonly ALPHA_ALPHATOCOLOR: number;
  73901. /**
  73902. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73903. */
  73904. static readonly ALPHA_REVERSEONEMINUS: number;
  73905. /**
  73906. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73907. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73908. */
  73909. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73910. /**
  73911. * Defines that alpha blending is SRC + DST
  73912. * Alpha will be set to SRC ALPHA
  73913. */
  73914. static readonly ALPHA_ONEONE_ONEZERO: number;
  73915. /**
  73916. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73917. * Alpha will be set to DST ALPHA
  73918. */
  73919. static readonly ALPHA_EXCLUSION: number;
  73920. /** Defines that alpha blending equation a SUM */
  73921. static readonly ALPHA_EQUATION_ADD: number;
  73922. /** Defines that alpha blending equation a SUBSTRACTION */
  73923. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73924. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73925. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73926. /** Defines that alpha blending equation a MAX operation */
  73927. static readonly ALPHA_EQUATION_MAX: number;
  73928. /** Defines that alpha blending equation a MIN operation */
  73929. static readonly ALPHA_EQUATION_MIN: number;
  73930. /**
  73931. * Defines that alpha blending equation a DARKEN operation:
  73932. * It takes the min of the src and sums the alpha channels.
  73933. */
  73934. static readonly ALPHA_EQUATION_DARKEN: number;
  73935. /** Defines that the ressource is not delayed*/
  73936. static readonly DELAYLOADSTATE_NONE: number;
  73937. /** Defines that the ressource was successfully delay loaded */
  73938. static readonly DELAYLOADSTATE_LOADED: number;
  73939. /** Defines that the ressource is currently delay loading */
  73940. static readonly DELAYLOADSTATE_LOADING: number;
  73941. /** Defines that the ressource is delayed and has not started loading */
  73942. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73943. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73944. static readonly NEVER: number;
  73945. /** 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 */
  73946. static readonly ALWAYS: number;
  73947. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73948. static readonly LESS: number;
  73949. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73950. static readonly EQUAL: number;
  73951. /** 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 */
  73952. static readonly LEQUAL: number;
  73953. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73954. static readonly GREATER: number;
  73955. /** 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 */
  73956. static readonly GEQUAL: number;
  73957. /** 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 */
  73958. static readonly NOTEQUAL: number;
  73959. /** Passed to stencilOperation to specify that stencil value must be kept */
  73960. static readonly KEEP: number;
  73961. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73962. static readonly REPLACE: number;
  73963. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73964. static readonly INCR: number;
  73965. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73966. static readonly DECR: number;
  73967. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73968. static readonly INVERT: number;
  73969. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73970. static readonly INCR_WRAP: number;
  73971. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73972. static readonly DECR_WRAP: number;
  73973. /** Texture is not repeating outside of 0..1 UVs */
  73974. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73975. /** Texture is repeating outside of 0..1 UVs */
  73976. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73977. /** Texture is repeating and mirrored */
  73978. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73979. /** ALPHA */
  73980. static readonly TEXTUREFORMAT_ALPHA: number;
  73981. /** LUMINANCE */
  73982. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73983. /** LUMINANCE_ALPHA */
  73984. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73985. /** RGB */
  73986. static readonly TEXTUREFORMAT_RGB: number;
  73987. /** RGBA */
  73988. static readonly TEXTUREFORMAT_RGBA: number;
  73989. /** RED */
  73990. static readonly TEXTUREFORMAT_RED: number;
  73991. /** RED (2nd reference) */
  73992. static readonly TEXTUREFORMAT_R: number;
  73993. /** RG */
  73994. static readonly TEXTUREFORMAT_RG: number;
  73995. /** RED_INTEGER */
  73996. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73997. /** RED_INTEGER (2nd reference) */
  73998. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73999. /** RG_INTEGER */
  74000. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  74001. /** RGB_INTEGER */
  74002. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74003. /** RGBA_INTEGER */
  74004. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74005. /** UNSIGNED_BYTE */
  74006. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74007. /** UNSIGNED_BYTE (2nd reference) */
  74008. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74009. /** FLOAT */
  74010. static readonly TEXTURETYPE_FLOAT: number;
  74011. /** HALF_FLOAT */
  74012. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74013. /** BYTE */
  74014. static readonly TEXTURETYPE_BYTE: number;
  74015. /** SHORT */
  74016. static readonly TEXTURETYPE_SHORT: number;
  74017. /** UNSIGNED_SHORT */
  74018. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74019. /** INT */
  74020. static readonly TEXTURETYPE_INT: number;
  74021. /** UNSIGNED_INT */
  74022. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74023. /** UNSIGNED_SHORT_4_4_4_4 */
  74024. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74025. /** UNSIGNED_SHORT_5_5_5_1 */
  74026. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74027. /** UNSIGNED_SHORT_5_6_5 */
  74028. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74029. /** UNSIGNED_INT_2_10_10_10_REV */
  74030. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74031. /** UNSIGNED_INT_24_8 */
  74032. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74033. /** UNSIGNED_INT_10F_11F_11F_REV */
  74034. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74035. /** UNSIGNED_INT_5_9_9_9_REV */
  74036. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74037. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74038. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74039. /** nearest is mag = nearest and min = nearest and no mip */
  74040. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74041. /** mag = nearest and min = nearest and mip = none */
  74042. static readonly TEXTURE_NEAREST_NEAREST: number;
  74043. /** Bilinear is mag = linear and min = linear and no mip */
  74044. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74045. /** mag = linear and min = linear and mip = none */
  74046. static readonly TEXTURE_LINEAR_LINEAR: number;
  74047. /** Trilinear is mag = linear and min = linear and mip = linear */
  74048. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74049. /** Trilinear is mag = linear and min = linear and mip = linear */
  74050. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74051. /** mag = nearest and min = nearest and mip = nearest */
  74052. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74053. /** mag = nearest and min = linear and mip = nearest */
  74054. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74055. /** mag = nearest and min = linear and mip = linear */
  74056. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74057. /** mag = nearest and min = linear and mip = none */
  74058. static readonly TEXTURE_NEAREST_LINEAR: number;
  74059. /** nearest is mag = nearest and min = nearest and mip = linear */
  74060. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74061. /** mag = linear and min = nearest and mip = nearest */
  74062. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74063. /** mag = linear and min = nearest and mip = linear */
  74064. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74065. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74066. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74067. /** mag = linear and min = nearest and mip = none */
  74068. static readonly TEXTURE_LINEAR_NEAREST: number;
  74069. /** Explicit coordinates mode */
  74070. static readonly TEXTURE_EXPLICIT_MODE: number;
  74071. /** Spherical coordinates mode */
  74072. static readonly TEXTURE_SPHERICAL_MODE: number;
  74073. /** Planar coordinates mode */
  74074. static readonly TEXTURE_PLANAR_MODE: number;
  74075. /** Cubic coordinates mode */
  74076. static readonly TEXTURE_CUBIC_MODE: number;
  74077. /** Projection coordinates mode */
  74078. static readonly TEXTURE_PROJECTION_MODE: number;
  74079. /** Skybox coordinates mode */
  74080. static readonly TEXTURE_SKYBOX_MODE: number;
  74081. /** Inverse Cubic coordinates mode */
  74082. static readonly TEXTURE_INVCUBIC_MODE: number;
  74083. /** Equirectangular coordinates mode */
  74084. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74085. /** Equirectangular Fixed coordinates mode */
  74086. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74087. /** Equirectangular Fixed Mirrored coordinates mode */
  74088. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74089. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74090. static readonly SCALEMODE_FLOOR: number;
  74091. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74092. static readonly SCALEMODE_NEAREST: number;
  74093. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74094. static readonly SCALEMODE_CEILING: number;
  74095. /**
  74096. * The dirty texture flag value
  74097. */
  74098. static readonly MATERIAL_TextureDirtyFlag: number;
  74099. /**
  74100. * The dirty light flag value
  74101. */
  74102. static readonly MATERIAL_LightDirtyFlag: number;
  74103. /**
  74104. * The dirty fresnel flag value
  74105. */
  74106. static readonly MATERIAL_FresnelDirtyFlag: number;
  74107. /**
  74108. * The dirty attribute flag value
  74109. */
  74110. static readonly MATERIAL_AttributesDirtyFlag: number;
  74111. /**
  74112. * The dirty misc flag value
  74113. */
  74114. static readonly MATERIAL_MiscDirtyFlag: number;
  74115. /**
  74116. * The all dirty flag value
  74117. */
  74118. static readonly MATERIAL_AllDirtyFlag: number;
  74119. /**
  74120. * Returns the triangle fill mode
  74121. */
  74122. static readonly MATERIAL_TriangleFillMode: number;
  74123. /**
  74124. * Returns the wireframe mode
  74125. */
  74126. static readonly MATERIAL_WireFrameFillMode: number;
  74127. /**
  74128. * Returns the point fill mode
  74129. */
  74130. static readonly MATERIAL_PointFillMode: number;
  74131. /**
  74132. * Returns the point list draw mode
  74133. */
  74134. static readonly MATERIAL_PointListDrawMode: number;
  74135. /**
  74136. * Returns the line list draw mode
  74137. */
  74138. static readonly MATERIAL_LineListDrawMode: number;
  74139. /**
  74140. * Returns the line loop draw mode
  74141. */
  74142. static readonly MATERIAL_LineLoopDrawMode: number;
  74143. /**
  74144. * Returns the line strip draw mode
  74145. */
  74146. static readonly MATERIAL_LineStripDrawMode: number;
  74147. /**
  74148. * Returns the triangle strip draw mode
  74149. */
  74150. static readonly MATERIAL_TriangleStripDrawMode: number;
  74151. /**
  74152. * Returns the triangle fan draw mode
  74153. */
  74154. static readonly MATERIAL_TriangleFanDrawMode: number;
  74155. /**
  74156. * Stores the clock-wise side orientation
  74157. */
  74158. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74159. /**
  74160. * Stores the counter clock-wise side orientation
  74161. */
  74162. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74163. /**
  74164. * Nothing
  74165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74166. */
  74167. static readonly ACTION_NothingTrigger: number;
  74168. /**
  74169. * On pick
  74170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74171. */
  74172. static readonly ACTION_OnPickTrigger: number;
  74173. /**
  74174. * On left pick
  74175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74176. */
  74177. static readonly ACTION_OnLeftPickTrigger: number;
  74178. /**
  74179. * On right pick
  74180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74181. */
  74182. static readonly ACTION_OnRightPickTrigger: number;
  74183. /**
  74184. * On center pick
  74185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74186. */
  74187. static readonly ACTION_OnCenterPickTrigger: number;
  74188. /**
  74189. * On pick down
  74190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74191. */
  74192. static readonly ACTION_OnPickDownTrigger: number;
  74193. /**
  74194. * On double pick
  74195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74196. */
  74197. static readonly ACTION_OnDoublePickTrigger: number;
  74198. /**
  74199. * On pick up
  74200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74201. */
  74202. static readonly ACTION_OnPickUpTrigger: number;
  74203. /**
  74204. * On pick out.
  74205. * This trigger will only be raised if you also declared a OnPickDown
  74206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74207. */
  74208. static readonly ACTION_OnPickOutTrigger: number;
  74209. /**
  74210. * On long press
  74211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74212. */
  74213. static readonly ACTION_OnLongPressTrigger: number;
  74214. /**
  74215. * On pointer over
  74216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74217. */
  74218. static readonly ACTION_OnPointerOverTrigger: number;
  74219. /**
  74220. * On pointer out
  74221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74222. */
  74223. static readonly ACTION_OnPointerOutTrigger: number;
  74224. /**
  74225. * On every frame
  74226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74227. */
  74228. static readonly ACTION_OnEveryFrameTrigger: number;
  74229. /**
  74230. * On intersection enter
  74231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74232. */
  74233. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74234. /**
  74235. * On intersection exit
  74236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74237. */
  74238. static readonly ACTION_OnIntersectionExitTrigger: number;
  74239. /**
  74240. * On key down
  74241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74242. */
  74243. static readonly ACTION_OnKeyDownTrigger: number;
  74244. /**
  74245. * On key up
  74246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74247. */
  74248. static readonly ACTION_OnKeyUpTrigger: number;
  74249. /**
  74250. * Billboard mode will only apply to Y axis
  74251. */
  74252. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74253. /**
  74254. * Billboard mode will apply to all axes
  74255. */
  74256. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74257. /**
  74258. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74259. */
  74260. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74261. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74262. * Test order :
  74263. * Is the bounding sphere outside the frustum ?
  74264. * If not, are the bounding box vertices outside the frustum ?
  74265. * It not, then the cullable object is in the frustum.
  74266. */
  74267. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74268. /** Culling strategy : Bounding Sphere Only.
  74269. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74270. * It's also less accurate than the standard because some not visible objects can still be selected.
  74271. * Test : is the bounding sphere outside the frustum ?
  74272. * If not, then the cullable object is in the frustum.
  74273. */
  74274. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74275. /** Culling strategy : Optimistic Inclusion.
  74276. * This in an inclusion test first, then the standard exclusion test.
  74277. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74278. * 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.
  74279. * Anyway, it's as accurate as the standard strategy.
  74280. * Test :
  74281. * Is the cullable object bounding sphere center in the frustum ?
  74282. * If not, apply the default culling strategy.
  74283. */
  74284. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74285. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74286. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74287. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74288. * 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.
  74289. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74290. * Test :
  74291. * Is the cullable object bounding sphere center in the frustum ?
  74292. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74293. */
  74294. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74295. /**
  74296. * No logging while loading
  74297. */
  74298. static readonly SCENELOADER_NO_LOGGING: number;
  74299. /**
  74300. * Minimal logging while loading
  74301. */
  74302. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74303. /**
  74304. * Summary logging while loading
  74305. */
  74306. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74307. /**
  74308. * Detailled logging while loading
  74309. */
  74310. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74311. }
  74312. }
  74313. declare module BABYLON {
  74314. /**
  74315. * This represents the required contract to create a new type of texture loader.
  74316. */
  74317. export interface IInternalTextureLoader {
  74318. /**
  74319. * Defines wether the loader supports cascade loading the different faces.
  74320. */
  74321. supportCascades: boolean;
  74322. /**
  74323. * This returns if the loader support the current file information.
  74324. * @param extension defines the file extension of the file being loaded
  74325. * @returns true if the loader can load the specified file
  74326. */
  74327. canLoad(extension: string): boolean;
  74328. /**
  74329. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74330. * @param data contains the texture data
  74331. * @param texture defines the BabylonJS internal texture
  74332. * @param createPolynomials will be true if polynomials have been requested
  74333. * @param onLoad defines the callback to trigger once the texture is ready
  74334. * @param onError defines the callback to trigger in case of error
  74335. */
  74336. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74337. /**
  74338. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74339. * @param data contains the texture data
  74340. * @param texture defines the BabylonJS internal texture
  74341. * @param callback defines the method to call once ready to upload
  74342. */
  74343. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74344. }
  74345. }
  74346. declare module BABYLON {
  74347. /**
  74348. * Class used to store and describe the pipeline context associated with an effect
  74349. */
  74350. export interface IPipelineContext {
  74351. /**
  74352. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74353. */
  74354. isAsync: boolean;
  74355. /**
  74356. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74357. */
  74358. isReady: boolean;
  74359. /** @hidden */
  74360. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74361. }
  74362. }
  74363. declare module BABYLON {
  74364. /**
  74365. * Class used to store gfx data (like WebGLBuffer)
  74366. */
  74367. export class DataBuffer {
  74368. /**
  74369. * Gets or sets the number of objects referencing this buffer
  74370. */
  74371. references: number;
  74372. /** Gets or sets the size of the underlying buffer */
  74373. capacity: number;
  74374. /**
  74375. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74376. */
  74377. is32Bits: boolean;
  74378. /**
  74379. * Gets the underlying buffer
  74380. */
  74381. get underlyingResource(): any;
  74382. }
  74383. }
  74384. declare module BABYLON {
  74385. /** @hidden */
  74386. export interface IShaderProcessor {
  74387. attributeProcessor?: (attribute: string) => string;
  74388. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74389. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74390. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74391. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74392. lineProcessor?: (line: string, isFragment: boolean) => string;
  74393. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74394. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74395. }
  74396. }
  74397. declare module BABYLON {
  74398. /** @hidden */
  74399. export interface ProcessingOptions {
  74400. defines: string[];
  74401. indexParameters: any;
  74402. isFragment: boolean;
  74403. shouldUseHighPrecisionShader: boolean;
  74404. supportsUniformBuffers: boolean;
  74405. shadersRepository: string;
  74406. includesShadersStore: {
  74407. [key: string]: string;
  74408. };
  74409. processor?: IShaderProcessor;
  74410. version: string;
  74411. platformName: string;
  74412. lookForClosingBracketForUniformBuffer?: boolean;
  74413. }
  74414. }
  74415. declare module BABYLON {
  74416. /** @hidden */
  74417. export class ShaderCodeNode {
  74418. line: string;
  74419. children: ShaderCodeNode[];
  74420. additionalDefineKey?: string;
  74421. additionalDefineValue?: string;
  74422. isValid(preprocessors: {
  74423. [key: string]: string;
  74424. }): boolean;
  74425. process(preprocessors: {
  74426. [key: string]: string;
  74427. }, options: ProcessingOptions): string;
  74428. }
  74429. }
  74430. declare module BABYLON {
  74431. /** @hidden */
  74432. export class ShaderCodeCursor {
  74433. private _lines;
  74434. lineIndex: number;
  74435. get currentLine(): string;
  74436. get canRead(): boolean;
  74437. set lines(value: string[]);
  74438. }
  74439. }
  74440. declare module BABYLON {
  74441. /** @hidden */
  74442. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74443. process(preprocessors: {
  74444. [key: string]: string;
  74445. }, options: ProcessingOptions): string;
  74446. }
  74447. }
  74448. declare module BABYLON {
  74449. /** @hidden */
  74450. export class ShaderDefineExpression {
  74451. isTrue(preprocessors: {
  74452. [key: string]: string;
  74453. }): boolean;
  74454. }
  74455. }
  74456. declare module BABYLON {
  74457. /** @hidden */
  74458. export class ShaderCodeTestNode extends ShaderCodeNode {
  74459. testExpression: ShaderDefineExpression;
  74460. isValid(preprocessors: {
  74461. [key: string]: string;
  74462. }): boolean;
  74463. }
  74464. }
  74465. declare module BABYLON {
  74466. /** @hidden */
  74467. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74468. define: string;
  74469. not: boolean;
  74470. constructor(define: string, not?: boolean);
  74471. isTrue(preprocessors: {
  74472. [key: string]: string;
  74473. }): boolean;
  74474. }
  74475. }
  74476. declare module BABYLON {
  74477. /** @hidden */
  74478. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74479. leftOperand: ShaderDefineExpression;
  74480. rightOperand: ShaderDefineExpression;
  74481. isTrue(preprocessors: {
  74482. [key: string]: string;
  74483. }): boolean;
  74484. }
  74485. }
  74486. declare module BABYLON {
  74487. /** @hidden */
  74488. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74489. leftOperand: ShaderDefineExpression;
  74490. rightOperand: ShaderDefineExpression;
  74491. isTrue(preprocessors: {
  74492. [key: string]: string;
  74493. }): boolean;
  74494. }
  74495. }
  74496. declare module BABYLON {
  74497. /** @hidden */
  74498. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74499. define: string;
  74500. operand: string;
  74501. testValue: string;
  74502. constructor(define: string, operand: string, testValue: string);
  74503. isTrue(preprocessors: {
  74504. [key: string]: string;
  74505. }): boolean;
  74506. }
  74507. }
  74508. declare module BABYLON {
  74509. /**
  74510. * Class used to enable access to offline support
  74511. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74512. */
  74513. export interface IOfflineProvider {
  74514. /**
  74515. * Gets a boolean indicating if scene must be saved in the database
  74516. */
  74517. enableSceneOffline: boolean;
  74518. /**
  74519. * Gets a boolean indicating if textures must be saved in the database
  74520. */
  74521. enableTexturesOffline: boolean;
  74522. /**
  74523. * Open the offline support and make it available
  74524. * @param successCallback defines the callback to call on success
  74525. * @param errorCallback defines the callback to call on error
  74526. */
  74527. open(successCallback: () => void, errorCallback: () => void): void;
  74528. /**
  74529. * Loads an image from the offline support
  74530. * @param url defines the url to load from
  74531. * @param image defines the target DOM image
  74532. */
  74533. loadImage(url: string, image: HTMLImageElement): void;
  74534. /**
  74535. * Loads a file from offline support
  74536. * @param url defines the URL to load from
  74537. * @param sceneLoaded defines a callback to call on success
  74538. * @param progressCallBack defines a callback to call when progress changed
  74539. * @param errorCallback defines a callback to call on error
  74540. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74541. */
  74542. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74543. }
  74544. }
  74545. declare module BABYLON {
  74546. /**
  74547. * Class used to help managing file picking and drag'n'drop
  74548. * File Storage
  74549. */
  74550. export class FilesInputStore {
  74551. /**
  74552. * List of files ready to be loaded
  74553. */
  74554. static FilesToLoad: {
  74555. [key: string]: File;
  74556. };
  74557. }
  74558. }
  74559. declare module BABYLON {
  74560. /**
  74561. * Class used to define a retry strategy when error happens while loading assets
  74562. */
  74563. export class RetryStrategy {
  74564. /**
  74565. * Function used to defines an exponential back off strategy
  74566. * @param maxRetries defines the maximum number of retries (3 by default)
  74567. * @param baseInterval defines the interval between retries
  74568. * @returns the strategy function to use
  74569. */
  74570. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74571. }
  74572. }
  74573. declare module BABYLON {
  74574. /**
  74575. * @ignore
  74576. * Application error to support additional information when loading a file
  74577. */
  74578. export abstract class BaseError extends Error {
  74579. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74580. }
  74581. }
  74582. declare module BABYLON {
  74583. /** @ignore */
  74584. export class LoadFileError extends BaseError {
  74585. request?: WebRequest;
  74586. file?: File;
  74587. /**
  74588. * Creates a new LoadFileError
  74589. * @param message defines the message of the error
  74590. * @param request defines the optional web request
  74591. * @param file defines the optional file
  74592. */
  74593. constructor(message: string, object?: WebRequest | File);
  74594. }
  74595. /** @ignore */
  74596. export class RequestFileError extends BaseError {
  74597. request: WebRequest;
  74598. /**
  74599. * Creates a new LoadFileError
  74600. * @param message defines the message of the error
  74601. * @param request defines the optional web request
  74602. */
  74603. constructor(message: string, request: WebRequest);
  74604. }
  74605. /** @ignore */
  74606. export class ReadFileError extends BaseError {
  74607. file: File;
  74608. /**
  74609. * Creates a new ReadFileError
  74610. * @param message defines the message of the error
  74611. * @param file defines the optional file
  74612. */
  74613. constructor(message: string, file: File);
  74614. }
  74615. /**
  74616. * @hidden
  74617. */
  74618. export class FileTools {
  74619. /**
  74620. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74621. */
  74622. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74623. /**
  74624. * Gets or sets the base URL to use to load assets
  74625. */
  74626. static BaseUrl: string;
  74627. /**
  74628. * Default behaviour for cors in the application.
  74629. * It can be a string if the expected behavior is identical in the entire app.
  74630. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74631. */
  74632. static CorsBehavior: string | ((url: string | string[]) => string);
  74633. /**
  74634. * Gets or sets a function used to pre-process url before using them to load assets
  74635. */
  74636. static PreprocessUrl: (url: string) => string;
  74637. /**
  74638. * Removes unwanted characters from an url
  74639. * @param url defines the url to clean
  74640. * @returns the cleaned url
  74641. */
  74642. private static _CleanUrl;
  74643. /**
  74644. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74645. * @param url define the url we are trying
  74646. * @param element define the dom element where to configure the cors policy
  74647. */
  74648. static SetCorsBehavior(url: string | string[], element: {
  74649. crossOrigin: string | null;
  74650. }): void;
  74651. /**
  74652. * Loads an image as an HTMLImageElement.
  74653. * @param input url string, ArrayBuffer, or Blob to load
  74654. * @param onLoad callback called when the image successfully loads
  74655. * @param onError callback called when the image fails to load
  74656. * @param offlineProvider offline provider for caching
  74657. * @param mimeType optional mime type
  74658. * @returns the HTMLImageElement of the loaded image
  74659. */
  74660. 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>;
  74661. /**
  74662. * Reads a file from a File object
  74663. * @param file defines the file to load
  74664. * @param onSuccess defines the callback to call when data is loaded
  74665. * @param onProgress defines the callback to call during loading process
  74666. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74667. * @param onError defines the callback to call when an error occurs
  74668. * @returns a file request object
  74669. */
  74670. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74671. /**
  74672. * Loads a file from a url
  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 offlineProvider defines the offline provider for caching
  74677. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74678. * @param onError callback called when the file fails to load
  74679. * @returns a file request object
  74680. */
  74681. 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;
  74682. /**
  74683. * Loads a file
  74684. * @param url url to load
  74685. * @param onSuccess callback called when the file successfully loads
  74686. * @param onProgress callback called while file is loading (if the server supports this mode)
  74687. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74688. * @param onError callback called when the file fails to load
  74689. * @param onOpened callback called when the web request is opened
  74690. * @returns a file request object
  74691. */
  74692. 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;
  74693. /**
  74694. * Checks if the loaded document was accessed via `file:`-Protocol.
  74695. * @returns boolean
  74696. */
  74697. static IsFileURL(): boolean;
  74698. }
  74699. }
  74700. declare module BABYLON {
  74701. /** @hidden */
  74702. export class ShaderProcessor {
  74703. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74704. private static _ProcessPrecision;
  74705. private static _ExtractOperation;
  74706. private static _BuildSubExpression;
  74707. private static _BuildExpression;
  74708. private static _MoveCursorWithinIf;
  74709. private static _MoveCursor;
  74710. private static _EvaluatePreProcessors;
  74711. private static _PreparePreProcessors;
  74712. private static _ProcessShaderConversion;
  74713. private static _ProcessIncludes;
  74714. /**
  74715. * Loads a file from a url
  74716. * @param url url to load
  74717. * @param onSuccess callback called when the file successfully loads
  74718. * @param onProgress callback called while file is loading (if the server supports this mode)
  74719. * @param offlineProvider defines the offline provider for caching
  74720. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74721. * @param onError callback called when the file fails to load
  74722. * @returns a file request object
  74723. * @hidden
  74724. */
  74725. 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;
  74726. }
  74727. }
  74728. declare module BABYLON {
  74729. /**
  74730. * @hidden
  74731. */
  74732. export interface IColor4Like {
  74733. r: float;
  74734. g: float;
  74735. b: float;
  74736. a: float;
  74737. }
  74738. /**
  74739. * @hidden
  74740. */
  74741. export interface IColor3Like {
  74742. r: float;
  74743. g: float;
  74744. b: float;
  74745. }
  74746. /**
  74747. * @hidden
  74748. */
  74749. export interface IVector4Like {
  74750. x: float;
  74751. y: float;
  74752. z: float;
  74753. w: float;
  74754. }
  74755. /**
  74756. * @hidden
  74757. */
  74758. export interface IVector3Like {
  74759. x: float;
  74760. y: float;
  74761. z: float;
  74762. }
  74763. /**
  74764. * @hidden
  74765. */
  74766. export interface IVector2Like {
  74767. x: float;
  74768. y: float;
  74769. }
  74770. /**
  74771. * @hidden
  74772. */
  74773. export interface IMatrixLike {
  74774. toArray(): DeepImmutable<Float32Array>;
  74775. updateFlag: int;
  74776. }
  74777. /**
  74778. * @hidden
  74779. */
  74780. export interface IViewportLike {
  74781. x: float;
  74782. y: float;
  74783. width: float;
  74784. height: float;
  74785. }
  74786. /**
  74787. * @hidden
  74788. */
  74789. export interface IPlaneLike {
  74790. normal: IVector3Like;
  74791. d: float;
  74792. normalize(): void;
  74793. }
  74794. }
  74795. declare module BABYLON {
  74796. /**
  74797. * Interface used to define common properties for effect fallbacks
  74798. */
  74799. export interface IEffectFallbacks {
  74800. /**
  74801. * Removes the defines that should be removed when falling back.
  74802. * @param currentDefines defines the current define statements for the shader.
  74803. * @param effect defines the current effect we try to compile
  74804. * @returns The resulting defines with defines of the current rank removed.
  74805. */
  74806. reduce(currentDefines: string, effect: Effect): string;
  74807. /**
  74808. * Removes the fallback from the bound mesh.
  74809. */
  74810. unBindMesh(): void;
  74811. /**
  74812. * Checks to see if more fallbacks are still availible.
  74813. */
  74814. hasMoreFallbacks: boolean;
  74815. }
  74816. }
  74817. declare module BABYLON {
  74818. /**
  74819. * Class used to evalaute queries containing `and` and `or` operators
  74820. */
  74821. export class AndOrNotEvaluator {
  74822. /**
  74823. * Evaluate a query
  74824. * @param query defines the query to evaluate
  74825. * @param evaluateCallback defines the callback used to filter result
  74826. * @returns true if the query matches
  74827. */
  74828. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74829. private static _HandleParenthesisContent;
  74830. private static _SimplifyNegation;
  74831. }
  74832. }
  74833. declare module BABYLON {
  74834. /**
  74835. * Class used to store custom tags
  74836. */
  74837. export class Tags {
  74838. /**
  74839. * Adds support for tags on the given object
  74840. * @param obj defines the object to use
  74841. */
  74842. static EnableFor(obj: any): void;
  74843. /**
  74844. * Removes tags support
  74845. * @param obj defines the object to use
  74846. */
  74847. static DisableFor(obj: any): void;
  74848. /**
  74849. * Gets a boolean indicating if the given object has tags
  74850. * @param obj defines the object to use
  74851. * @returns a boolean
  74852. */
  74853. static HasTags(obj: any): boolean;
  74854. /**
  74855. * Gets the tags available on a given object
  74856. * @param obj defines the object to use
  74857. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74858. * @returns the tags
  74859. */
  74860. static GetTags(obj: any, asString?: boolean): any;
  74861. /**
  74862. * Adds tags to an object
  74863. * @param obj defines the object to use
  74864. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74865. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74866. */
  74867. static AddTagsTo(obj: any, tagsString: string): void;
  74868. /**
  74869. * @hidden
  74870. */
  74871. static _AddTagTo(obj: any, tag: string): void;
  74872. /**
  74873. * Removes specific tags from a specific object
  74874. * @param obj defines the object to use
  74875. * @param tagsString defines the tags to remove
  74876. */
  74877. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74878. /**
  74879. * @hidden
  74880. */
  74881. static _RemoveTagFrom(obj: any, tag: string): void;
  74882. /**
  74883. * Defines if tags hosted on an object match a given query
  74884. * @param obj defines the object to use
  74885. * @param tagsQuery defines the tag query
  74886. * @returns a boolean
  74887. */
  74888. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74889. }
  74890. }
  74891. declare module BABYLON {
  74892. /**
  74893. * Scalar computation library
  74894. */
  74895. export class Scalar {
  74896. /**
  74897. * Two pi constants convenient for computation.
  74898. */
  74899. static TwoPi: number;
  74900. /**
  74901. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74902. * @param a number
  74903. * @param b number
  74904. * @param epsilon (default = 1.401298E-45)
  74905. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74906. */
  74907. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74908. /**
  74909. * Returns a string : the upper case translation of the number i to hexadecimal.
  74910. * @param i number
  74911. * @returns the upper case translation of the number i to hexadecimal.
  74912. */
  74913. static ToHex(i: number): string;
  74914. /**
  74915. * Returns -1 if value is negative and +1 is value is positive.
  74916. * @param value the value
  74917. * @returns the value itself if it's equal to zero.
  74918. */
  74919. static Sign(value: number): number;
  74920. /**
  74921. * Returns the value itself if it's between min and max.
  74922. * Returns min if the value is lower than min.
  74923. * Returns max if the value is greater than max.
  74924. * @param value the value to clmap
  74925. * @param min the min value to clamp to (default: 0)
  74926. * @param max the max value to clamp to (default: 1)
  74927. * @returns the clamped value
  74928. */
  74929. static Clamp(value: number, min?: number, max?: number): number;
  74930. /**
  74931. * the log2 of value.
  74932. * @param value the value to compute log2 of
  74933. * @returns the log2 of value.
  74934. */
  74935. static Log2(value: number): number;
  74936. /**
  74937. * Loops the value, so that it is never larger than length and never smaller than 0.
  74938. *
  74939. * This is similar to the modulo operator but it works with floating point numbers.
  74940. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74941. * With t = 5 and length = 2.5, the result would be 0.0.
  74942. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74943. * @param value the value
  74944. * @param length the length
  74945. * @returns the looped value
  74946. */
  74947. static Repeat(value: number, length: number): number;
  74948. /**
  74949. * Normalize the value between 0.0 and 1.0 using min and max values
  74950. * @param value value to normalize
  74951. * @param min max to normalize between
  74952. * @param max min to normalize between
  74953. * @returns the normalized value
  74954. */
  74955. static Normalize(value: number, min: number, max: number): number;
  74956. /**
  74957. * Denormalize the value from 0.0 and 1.0 using min and max values
  74958. * @param normalized value to denormalize
  74959. * @param min max to denormalize between
  74960. * @param max min to denormalize between
  74961. * @returns the denormalized value
  74962. */
  74963. static Denormalize(normalized: number, min: number, max: number): number;
  74964. /**
  74965. * Calculates the shortest difference between two given angles given in degrees.
  74966. * @param current current angle in degrees
  74967. * @param target target angle in degrees
  74968. * @returns the delta
  74969. */
  74970. static DeltaAngle(current: number, target: number): number;
  74971. /**
  74972. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74973. * @param tx value
  74974. * @param length length
  74975. * @returns The returned value will move back and forth between 0 and length
  74976. */
  74977. static PingPong(tx: number, length: number): number;
  74978. /**
  74979. * Interpolates between min and max with smoothing at the limits.
  74980. *
  74981. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74982. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74983. * @param from from
  74984. * @param to to
  74985. * @param tx value
  74986. * @returns the smooth stepped value
  74987. */
  74988. static SmoothStep(from: number, to: number, tx: number): number;
  74989. /**
  74990. * Moves a value current towards target.
  74991. *
  74992. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74993. * Negative values of maxDelta pushes the value away from target.
  74994. * @param current current value
  74995. * @param target target value
  74996. * @param maxDelta max distance to move
  74997. * @returns resulting value
  74998. */
  74999. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75000. /**
  75001. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75002. *
  75003. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75004. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75005. * @param current current value
  75006. * @param target target value
  75007. * @param maxDelta max distance to move
  75008. * @returns resulting angle
  75009. */
  75010. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75011. /**
  75012. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75013. * @param start start value
  75014. * @param end target value
  75015. * @param amount amount to lerp between
  75016. * @returns the lerped value
  75017. */
  75018. static Lerp(start: number, end: number, amount: number): number;
  75019. /**
  75020. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75021. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75022. * @param start start value
  75023. * @param end target value
  75024. * @param amount amount to lerp between
  75025. * @returns the lerped value
  75026. */
  75027. static LerpAngle(start: number, end: number, amount: number): number;
  75028. /**
  75029. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75030. * @param a start value
  75031. * @param b target value
  75032. * @param value value between a and b
  75033. * @returns the inverseLerp value
  75034. */
  75035. static InverseLerp(a: number, b: number, value: number): number;
  75036. /**
  75037. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75038. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75039. * @param value1 spline value
  75040. * @param tangent1 spline value
  75041. * @param value2 spline value
  75042. * @param tangent2 spline value
  75043. * @param amount input value
  75044. * @returns hermite result
  75045. */
  75046. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75047. /**
  75048. * Returns a random float number between and min and max values
  75049. * @param min min value of random
  75050. * @param max max value of random
  75051. * @returns random value
  75052. */
  75053. static RandomRange(min: number, max: number): number;
  75054. /**
  75055. * This function returns percentage of a number in a given range.
  75056. *
  75057. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75058. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75059. * @param number to convert to percentage
  75060. * @param min min range
  75061. * @param max max range
  75062. * @returns the percentage
  75063. */
  75064. static RangeToPercent(number: number, min: number, max: number): number;
  75065. /**
  75066. * This function returns number that corresponds to the percentage in a given range.
  75067. *
  75068. * PercentToRange(0.34,0,100) will return 34.
  75069. * @param percent to convert to number
  75070. * @param min min range
  75071. * @param max max range
  75072. * @returns the number
  75073. */
  75074. static PercentToRange(percent: number, min: number, max: number): number;
  75075. /**
  75076. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75077. * @param angle The angle to normalize in radian.
  75078. * @return The converted angle.
  75079. */
  75080. static NormalizeRadians(angle: number): number;
  75081. }
  75082. }
  75083. declare module BABYLON {
  75084. /**
  75085. * Constant used to convert a value to gamma space
  75086. * @ignorenaming
  75087. */
  75088. export const ToGammaSpace: number;
  75089. /**
  75090. * Constant used to convert a value to linear space
  75091. * @ignorenaming
  75092. */
  75093. export const ToLinearSpace = 2.2;
  75094. /**
  75095. * Constant used to define the minimal number value in Babylon.js
  75096. * @ignorenaming
  75097. */
  75098. let Epsilon: number;
  75099. }
  75100. declare module BABYLON {
  75101. /**
  75102. * Class used to represent a viewport on screen
  75103. */
  75104. export class Viewport {
  75105. /** viewport left coordinate */
  75106. x: number;
  75107. /** viewport top coordinate */
  75108. y: number;
  75109. /**viewport width */
  75110. width: number;
  75111. /** viewport height */
  75112. height: number;
  75113. /**
  75114. * Creates a Viewport object located at (x, y) and sized (width, height)
  75115. * @param x defines viewport left coordinate
  75116. * @param y defines viewport top coordinate
  75117. * @param width defines the viewport width
  75118. * @param height defines the viewport height
  75119. */
  75120. constructor(
  75121. /** viewport left coordinate */
  75122. x: number,
  75123. /** viewport top coordinate */
  75124. y: number,
  75125. /**viewport width */
  75126. width: number,
  75127. /** viewport height */
  75128. height: number);
  75129. /**
  75130. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75131. * @param renderWidth defines the rendering width
  75132. * @param renderHeight defines the rendering height
  75133. * @returns a new Viewport
  75134. */
  75135. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75136. /**
  75137. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75138. * @param renderWidth defines the rendering width
  75139. * @param renderHeight defines the rendering height
  75140. * @param ref defines the target viewport
  75141. * @returns the current viewport
  75142. */
  75143. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75144. /**
  75145. * Returns a new Viewport copied from the current one
  75146. * @returns a new Viewport
  75147. */
  75148. clone(): Viewport;
  75149. }
  75150. }
  75151. declare module BABYLON {
  75152. /**
  75153. * Class containing a set of static utilities functions for arrays.
  75154. */
  75155. export class ArrayTools {
  75156. /**
  75157. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75158. * @param size the number of element to construct and put in the array
  75159. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75160. * @returns a new array filled with new objects
  75161. */
  75162. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75163. }
  75164. }
  75165. declare module BABYLON {
  75166. /**
  75167. * Class representing a vector containing 2 coordinates
  75168. */
  75169. export class Vector2 {
  75170. /** defines the first coordinate */
  75171. x: number;
  75172. /** defines the second coordinate */
  75173. y: number;
  75174. /**
  75175. * Creates a new Vector2 from the given x and y coordinates
  75176. * @param x defines the first coordinate
  75177. * @param y defines the second coordinate
  75178. */
  75179. constructor(
  75180. /** defines the first coordinate */
  75181. x?: number,
  75182. /** defines the second coordinate */
  75183. y?: number);
  75184. /**
  75185. * Gets a string with the Vector2 coordinates
  75186. * @returns a string with the Vector2 coordinates
  75187. */
  75188. toString(): string;
  75189. /**
  75190. * Gets class name
  75191. * @returns the string "Vector2"
  75192. */
  75193. getClassName(): string;
  75194. /**
  75195. * Gets current vector hash code
  75196. * @returns the Vector2 hash code as a number
  75197. */
  75198. getHashCode(): number;
  75199. /**
  75200. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75201. * @param array defines the source array
  75202. * @param index defines the offset in source array
  75203. * @returns the current Vector2
  75204. */
  75205. toArray(array: FloatArray, index?: number): Vector2;
  75206. /**
  75207. * Copy the current vector to an array
  75208. * @returns a new array with 2 elements: the Vector2 coordinates.
  75209. */
  75210. asArray(): number[];
  75211. /**
  75212. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75213. * @param source defines the source Vector2
  75214. * @returns the current updated Vector2
  75215. */
  75216. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75217. /**
  75218. * Sets the Vector2 coordinates with the given floats
  75219. * @param x defines the first coordinate
  75220. * @param y defines the second coordinate
  75221. * @returns the current updated Vector2
  75222. */
  75223. copyFromFloats(x: number, y: number): Vector2;
  75224. /**
  75225. * Sets the Vector2 coordinates with the given floats
  75226. * @param x defines the first coordinate
  75227. * @param y defines the second coordinate
  75228. * @returns the current updated Vector2
  75229. */
  75230. set(x: number, y: number): Vector2;
  75231. /**
  75232. * Add another vector with the current one
  75233. * @param otherVector defines the other vector
  75234. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75235. */
  75236. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75237. /**
  75238. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75239. * @param otherVector defines the other vector
  75240. * @param result defines the target vector
  75241. * @returns the unmodified current Vector2
  75242. */
  75243. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75244. /**
  75245. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75246. * @param otherVector defines the other vector
  75247. * @returns the current updated Vector2
  75248. */
  75249. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75250. /**
  75251. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75252. * @param otherVector defines the other vector
  75253. * @returns a new Vector2
  75254. */
  75255. addVector3(otherVector: Vector3): Vector2;
  75256. /**
  75257. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75258. * @param otherVector defines the other vector
  75259. * @returns a new Vector2
  75260. */
  75261. subtract(otherVector: Vector2): Vector2;
  75262. /**
  75263. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75264. * @param otherVector defines the other vector
  75265. * @param result defines the target vector
  75266. * @returns the unmodified current Vector2
  75267. */
  75268. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75269. /**
  75270. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75271. * @param otherVector defines the other vector
  75272. * @returns the current updated Vector2
  75273. */
  75274. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75275. /**
  75276. * Multiplies in place the current Vector2 coordinates by the given ones
  75277. * @param otherVector defines the other vector
  75278. * @returns the current updated Vector2
  75279. */
  75280. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75281. /**
  75282. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75283. * @param otherVector defines the other vector
  75284. * @returns a new Vector2
  75285. */
  75286. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75287. /**
  75288. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75289. * @param otherVector defines the other vector
  75290. * @param result defines the target vector
  75291. * @returns the unmodified current Vector2
  75292. */
  75293. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75294. /**
  75295. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75296. * @param x defines the first coordinate
  75297. * @param y defines the second coordinate
  75298. * @returns a new Vector2
  75299. */
  75300. multiplyByFloats(x: number, y: number): Vector2;
  75301. /**
  75302. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75303. * @param otherVector defines the other vector
  75304. * @returns a new Vector2
  75305. */
  75306. divide(otherVector: Vector2): Vector2;
  75307. /**
  75308. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75309. * @param otherVector defines the other vector
  75310. * @param result defines the target vector
  75311. * @returns the unmodified current Vector2
  75312. */
  75313. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75314. /**
  75315. * Divides the current Vector2 coordinates by the given ones
  75316. * @param otherVector defines the other vector
  75317. * @returns the current updated Vector2
  75318. */
  75319. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75320. /**
  75321. * Gets a new Vector2 with current Vector2 negated coordinates
  75322. * @returns a new Vector2
  75323. */
  75324. negate(): Vector2;
  75325. /**
  75326. * Negate this vector in place
  75327. * @returns this
  75328. */
  75329. negateInPlace(): Vector2;
  75330. /**
  75331. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75332. * @param result defines the Vector3 object where to store the result
  75333. * @returns the current Vector2
  75334. */
  75335. negateToRef(result: Vector2): Vector2;
  75336. /**
  75337. * Multiply the Vector2 coordinates by scale
  75338. * @param scale defines the scaling factor
  75339. * @returns the current updated Vector2
  75340. */
  75341. scaleInPlace(scale: number): Vector2;
  75342. /**
  75343. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75344. * @param scale defines the scaling factor
  75345. * @returns a new Vector2
  75346. */
  75347. scale(scale: number): Vector2;
  75348. /**
  75349. * Scale the current Vector2 values by a factor to a given Vector2
  75350. * @param scale defines the scale factor
  75351. * @param result defines the Vector2 object where to store the result
  75352. * @returns the unmodified current Vector2
  75353. */
  75354. scaleToRef(scale: number, result: Vector2): Vector2;
  75355. /**
  75356. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75357. * @param scale defines the scale factor
  75358. * @param result defines the Vector2 object where to store the result
  75359. * @returns the unmodified current Vector2
  75360. */
  75361. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75362. /**
  75363. * Gets a boolean if two vectors are equals
  75364. * @param otherVector defines the other vector
  75365. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75366. */
  75367. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75368. /**
  75369. * Gets a boolean if two vectors are equals (using an epsilon value)
  75370. * @param otherVector defines the other vector
  75371. * @param epsilon defines the minimal distance to consider equality
  75372. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75373. */
  75374. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75375. /**
  75376. * Gets a new Vector2 from current Vector2 floored values
  75377. * @returns a new Vector2
  75378. */
  75379. floor(): Vector2;
  75380. /**
  75381. * Gets a new Vector2 from current Vector2 floored values
  75382. * @returns a new Vector2
  75383. */
  75384. fract(): Vector2;
  75385. /**
  75386. * Gets the length of the vector
  75387. * @returns the vector length (float)
  75388. */
  75389. length(): number;
  75390. /**
  75391. * Gets the vector squared length
  75392. * @returns the vector squared length (float)
  75393. */
  75394. lengthSquared(): number;
  75395. /**
  75396. * Normalize the vector
  75397. * @returns the current updated Vector2
  75398. */
  75399. normalize(): Vector2;
  75400. /**
  75401. * Gets a new Vector2 copied from the Vector2
  75402. * @returns a new Vector2
  75403. */
  75404. clone(): Vector2;
  75405. /**
  75406. * Gets a new Vector2(0, 0)
  75407. * @returns a new Vector2
  75408. */
  75409. static Zero(): Vector2;
  75410. /**
  75411. * Gets a new Vector2(1, 1)
  75412. * @returns a new Vector2
  75413. */
  75414. static One(): Vector2;
  75415. /**
  75416. * Gets a new Vector2 set from the given index element of the given array
  75417. * @param array defines the data source
  75418. * @param offset defines the offset in the data source
  75419. * @returns a new Vector2
  75420. */
  75421. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75422. /**
  75423. * Sets "result" from the given index element of the given array
  75424. * @param array defines the data source
  75425. * @param offset defines the offset in the data source
  75426. * @param result defines the target vector
  75427. */
  75428. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75429. /**
  75430. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75431. * @param value1 defines 1st point of control
  75432. * @param value2 defines 2nd point of control
  75433. * @param value3 defines 3rd point of control
  75434. * @param value4 defines 4th point of control
  75435. * @param amount defines the interpolation factor
  75436. * @returns a new Vector2
  75437. */
  75438. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75439. /**
  75440. * 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".
  75441. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75442. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75443. * @param value defines the value to clamp
  75444. * @param min defines the lower limit
  75445. * @param max defines the upper limit
  75446. * @returns a new Vector2
  75447. */
  75448. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75449. /**
  75450. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75451. * @param value1 defines the 1st control point
  75452. * @param tangent1 defines the outgoing tangent
  75453. * @param value2 defines the 2nd control point
  75454. * @param tangent2 defines the incoming tangent
  75455. * @param amount defines the interpolation factor
  75456. * @returns a new Vector2
  75457. */
  75458. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75459. /**
  75460. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75461. * @param start defines the start vector
  75462. * @param end defines the end vector
  75463. * @param amount defines the interpolation factor
  75464. * @returns a new Vector2
  75465. */
  75466. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75467. /**
  75468. * Gets the dot product of the vector "left" and the vector "right"
  75469. * @param left defines first vector
  75470. * @param right defines second vector
  75471. * @returns the dot product (float)
  75472. */
  75473. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75474. /**
  75475. * Returns a new Vector2 equal to the normalized given vector
  75476. * @param vector defines the vector to normalize
  75477. * @returns a new Vector2
  75478. */
  75479. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75480. /**
  75481. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75482. * @param left defines 1st vector
  75483. * @param right defines 2nd vector
  75484. * @returns a new Vector2
  75485. */
  75486. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75487. /**
  75488. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75489. * @param left defines 1st vector
  75490. * @param right defines 2nd vector
  75491. * @returns a new Vector2
  75492. */
  75493. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75494. /**
  75495. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75496. * @param vector defines the vector to transform
  75497. * @param transformation defines the matrix to apply
  75498. * @returns a new Vector2
  75499. */
  75500. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75501. /**
  75502. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75503. * @param vector defines the vector to transform
  75504. * @param transformation defines the matrix to apply
  75505. * @param result defines the target vector
  75506. */
  75507. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75508. /**
  75509. * Determines if a given vector is included in a triangle
  75510. * @param p defines the vector to test
  75511. * @param p0 defines 1st triangle point
  75512. * @param p1 defines 2nd triangle point
  75513. * @param p2 defines 3rd triangle point
  75514. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75515. */
  75516. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75517. /**
  75518. * Gets the distance between the vectors "value1" and "value2"
  75519. * @param value1 defines first vector
  75520. * @param value2 defines second vector
  75521. * @returns the distance between vectors
  75522. */
  75523. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75524. /**
  75525. * Returns the squared distance between the vectors "value1" and "value2"
  75526. * @param value1 defines first vector
  75527. * @param value2 defines second vector
  75528. * @returns the squared distance between vectors
  75529. */
  75530. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75531. /**
  75532. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75533. * @param value1 defines first vector
  75534. * @param value2 defines second vector
  75535. * @returns a new Vector2
  75536. */
  75537. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75538. /**
  75539. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75540. * @param p defines the middle point
  75541. * @param segA defines one point of the segment
  75542. * @param segB defines the other point of the segment
  75543. * @returns the shortest distance
  75544. */
  75545. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75546. }
  75547. /**
  75548. * Class used to store (x,y,z) vector representation
  75549. * A Vector3 is the main object used in 3D geometry
  75550. * It can represent etiher the coordinates of a point the space, either a direction
  75551. * Reminder: js uses a left handed forward facing system
  75552. */
  75553. export class Vector3 {
  75554. /**
  75555. * Defines the first coordinates (on X axis)
  75556. */
  75557. x: number;
  75558. /**
  75559. * Defines the second coordinates (on Y axis)
  75560. */
  75561. y: number;
  75562. /**
  75563. * Defines the third coordinates (on Z axis)
  75564. */
  75565. z: number;
  75566. private static _UpReadOnly;
  75567. private static _ZeroReadOnly;
  75568. /**
  75569. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75570. * @param x defines the first coordinates (on X axis)
  75571. * @param y defines the second coordinates (on Y axis)
  75572. * @param z defines the third coordinates (on Z axis)
  75573. */
  75574. constructor(
  75575. /**
  75576. * Defines the first coordinates (on X axis)
  75577. */
  75578. x?: number,
  75579. /**
  75580. * Defines the second coordinates (on Y axis)
  75581. */
  75582. y?: number,
  75583. /**
  75584. * Defines the third coordinates (on Z axis)
  75585. */
  75586. z?: number);
  75587. /**
  75588. * Creates a string representation of the Vector3
  75589. * @returns a string with the Vector3 coordinates.
  75590. */
  75591. toString(): string;
  75592. /**
  75593. * Gets the class name
  75594. * @returns the string "Vector3"
  75595. */
  75596. getClassName(): string;
  75597. /**
  75598. * Creates the Vector3 hash code
  75599. * @returns a number which tends to be unique between Vector3 instances
  75600. */
  75601. getHashCode(): number;
  75602. /**
  75603. * Creates an array containing three elements : the coordinates of the Vector3
  75604. * @returns a new array of numbers
  75605. */
  75606. asArray(): number[];
  75607. /**
  75608. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75609. * @param array defines the destination array
  75610. * @param index defines the offset in the destination array
  75611. * @returns the current Vector3
  75612. */
  75613. toArray(array: FloatArray, index?: number): Vector3;
  75614. /**
  75615. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75616. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75617. */
  75618. toQuaternion(): Quaternion;
  75619. /**
  75620. * Adds the given vector to the current Vector3
  75621. * @param otherVector defines the second operand
  75622. * @returns the current updated Vector3
  75623. */
  75624. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75625. /**
  75626. * Adds the given coordinates to the current Vector3
  75627. * @param x defines the x coordinate of the operand
  75628. * @param y defines the y coordinate of the operand
  75629. * @param z defines the z coordinate of the operand
  75630. * @returns the current updated Vector3
  75631. */
  75632. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75633. /**
  75634. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75635. * @param otherVector defines the second operand
  75636. * @returns the resulting Vector3
  75637. */
  75638. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75639. /**
  75640. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75641. * @param otherVector defines the second operand
  75642. * @param result defines the Vector3 object where to store the result
  75643. * @returns the current Vector3
  75644. */
  75645. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75646. /**
  75647. * Subtract the given vector from the current Vector3
  75648. * @param otherVector defines the second operand
  75649. * @returns the current updated Vector3
  75650. */
  75651. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75652. /**
  75653. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75654. * @param otherVector defines the second operand
  75655. * @returns the resulting Vector3
  75656. */
  75657. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75658. /**
  75659. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75660. * @param otherVector defines the second operand
  75661. * @param result defines the Vector3 object where to store the result
  75662. * @returns the current Vector3
  75663. */
  75664. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75665. /**
  75666. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75667. * @param x defines the x coordinate of the operand
  75668. * @param y defines the y coordinate of the operand
  75669. * @param z defines the z coordinate of the operand
  75670. * @returns the resulting Vector3
  75671. */
  75672. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75673. /**
  75674. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75675. * @param x defines the x coordinate of the operand
  75676. * @param y defines the y coordinate of the operand
  75677. * @param z defines the z coordinate of the operand
  75678. * @param result defines the Vector3 object where to store the result
  75679. * @returns the current Vector3
  75680. */
  75681. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75682. /**
  75683. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75684. * @returns a new Vector3
  75685. */
  75686. negate(): Vector3;
  75687. /**
  75688. * Negate this vector in place
  75689. * @returns this
  75690. */
  75691. negateInPlace(): Vector3;
  75692. /**
  75693. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75694. * @param result defines the Vector3 object where to store the result
  75695. * @returns the current Vector3
  75696. */
  75697. negateToRef(result: Vector3): Vector3;
  75698. /**
  75699. * Multiplies the Vector3 coordinates by the float "scale"
  75700. * @param scale defines the multiplier factor
  75701. * @returns the current updated Vector3
  75702. */
  75703. scaleInPlace(scale: number): Vector3;
  75704. /**
  75705. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75706. * @param scale defines the multiplier factor
  75707. * @returns a new Vector3
  75708. */
  75709. scale(scale: number): Vector3;
  75710. /**
  75711. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75712. * @param scale defines the multiplier factor
  75713. * @param result defines the Vector3 object where to store the result
  75714. * @returns the current Vector3
  75715. */
  75716. scaleToRef(scale: number, result: Vector3): Vector3;
  75717. /**
  75718. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75719. * @param scale defines the scale factor
  75720. * @param result defines the Vector3 object where to store the result
  75721. * @returns the unmodified current Vector3
  75722. */
  75723. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75724. /**
  75725. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75726. * @param otherVector defines the second operand
  75727. * @returns true if both vectors are equals
  75728. */
  75729. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75730. /**
  75731. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75732. * @param otherVector defines the second operand
  75733. * @param epsilon defines the minimal distance to define values as equals
  75734. * @returns true if both vectors are distant less than epsilon
  75735. */
  75736. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75737. /**
  75738. * Returns true if the current Vector3 coordinates equals the given floats
  75739. * @param x defines the x coordinate of the operand
  75740. * @param y defines the y coordinate of the operand
  75741. * @param z defines the z coordinate of the operand
  75742. * @returns true if both vectors are equals
  75743. */
  75744. equalsToFloats(x: number, y: number, z: number): boolean;
  75745. /**
  75746. * Multiplies the current Vector3 coordinates by the given ones
  75747. * @param otherVector defines the second operand
  75748. * @returns the current updated Vector3
  75749. */
  75750. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75751. /**
  75752. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75753. * @param otherVector defines the second operand
  75754. * @returns the new Vector3
  75755. */
  75756. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75757. /**
  75758. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75759. * @param otherVector defines the second operand
  75760. * @param result defines the Vector3 object where to store the result
  75761. * @returns the current Vector3
  75762. */
  75763. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75764. /**
  75765. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75766. * @param x defines the x coordinate of the operand
  75767. * @param y defines the y coordinate of the operand
  75768. * @param z defines the z coordinate of the operand
  75769. * @returns the new Vector3
  75770. */
  75771. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75772. /**
  75773. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75774. * @param otherVector defines the second operand
  75775. * @returns the new Vector3
  75776. */
  75777. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75778. /**
  75779. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75780. * @param otherVector defines the second operand
  75781. * @param result defines the Vector3 object where to store the result
  75782. * @returns the current Vector3
  75783. */
  75784. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75785. /**
  75786. * Divides the current Vector3 coordinates by the given ones.
  75787. * @param otherVector defines the second operand
  75788. * @returns the current updated Vector3
  75789. */
  75790. divideInPlace(otherVector: Vector3): Vector3;
  75791. /**
  75792. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75793. * @param other defines the second operand
  75794. * @returns the current updated Vector3
  75795. */
  75796. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75797. /**
  75798. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75799. * @param other defines the second operand
  75800. * @returns the current updated Vector3
  75801. */
  75802. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75803. /**
  75804. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75805. * @param x defines the x coordinate of the operand
  75806. * @param y defines the y coordinate of the operand
  75807. * @param z defines the z coordinate of the operand
  75808. * @returns the current updated Vector3
  75809. */
  75810. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75811. /**
  75812. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75813. * @param x defines the x coordinate of the operand
  75814. * @param y defines the y coordinate of the operand
  75815. * @param z defines the z coordinate of the operand
  75816. * @returns the current updated Vector3
  75817. */
  75818. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75819. /**
  75820. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75821. * Check if is non uniform within a certain amount of decimal places to account for this
  75822. * @param epsilon the amount the values can differ
  75823. * @returns if the the vector is non uniform to a certain number of decimal places
  75824. */
  75825. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75826. /**
  75827. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75828. */
  75829. get isNonUniform(): boolean;
  75830. /**
  75831. * Gets a new Vector3 from current Vector3 floored values
  75832. * @returns a new Vector3
  75833. */
  75834. floor(): Vector3;
  75835. /**
  75836. * Gets a new Vector3 from current Vector3 floored values
  75837. * @returns a new Vector3
  75838. */
  75839. fract(): Vector3;
  75840. /**
  75841. * Gets the length of the Vector3
  75842. * @returns the length of the Vector3
  75843. */
  75844. length(): number;
  75845. /**
  75846. * Gets the squared length of the Vector3
  75847. * @returns squared length of the Vector3
  75848. */
  75849. lengthSquared(): number;
  75850. /**
  75851. * Normalize the current Vector3.
  75852. * Please note that this is an in place operation.
  75853. * @returns the current updated Vector3
  75854. */
  75855. normalize(): Vector3;
  75856. /**
  75857. * Reorders the x y z properties of the vector in place
  75858. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75859. * @returns the current updated vector
  75860. */
  75861. reorderInPlace(order: string): this;
  75862. /**
  75863. * Rotates the vector around 0,0,0 by a quaternion
  75864. * @param quaternion the rotation quaternion
  75865. * @param result vector to store the result
  75866. * @returns the resulting vector
  75867. */
  75868. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75869. /**
  75870. * Rotates a vector around a given point
  75871. * @param quaternion the rotation quaternion
  75872. * @param point the point to rotate around
  75873. * @param result vector to store the result
  75874. * @returns the resulting vector
  75875. */
  75876. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75877. /**
  75878. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75879. * The cross product is then orthogonal to both current and "other"
  75880. * @param other defines the right operand
  75881. * @returns the cross product
  75882. */
  75883. cross(other: Vector3): Vector3;
  75884. /**
  75885. * Normalize the current Vector3 with the given input length.
  75886. * Please note that this is an in place operation.
  75887. * @param len the length of the vector
  75888. * @returns the current updated Vector3
  75889. */
  75890. normalizeFromLength(len: number): Vector3;
  75891. /**
  75892. * Normalize the current Vector3 to a new vector
  75893. * @returns the new Vector3
  75894. */
  75895. normalizeToNew(): Vector3;
  75896. /**
  75897. * Normalize the current Vector3 to the reference
  75898. * @param reference define the Vector3 to update
  75899. * @returns the updated Vector3
  75900. */
  75901. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75902. /**
  75903. * Creates a new Vector3 copied from the current Vector3
  75904. * @returns the new Vector3
  75905. */
  75906. clone(): Vector3;
  75907. /**
  75908. * Copies the given vector coordinates to the current Vector3 ones
  75909. * @param source defines the source Vector3
  75910. * @returns the current updated Vector3
  75911. */
  75912. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75913. /**
  75914. * Copies the given floats to the current Vector3 coordinates
  75915. * @param x defines the x coordinate of the operand
  75916. * @param y defines the y coordinate of the operand
  75917. * @param z defines the z coordinate of the operand
  75918. * @returns the current updated Vector3
  75919. */
  75920. copyFromFloats(x: number, y: number, z: number): Vector3;
  75921. /**
  75922. * Copies the given floats to the current Vector3 coordinates
  75923. * @param x defines the x coordinate of the operand
  75924. * @param y defines the y coordinate of the operand
  75925. * @param z defines the z coordinate of the operand
  75926. * @returns the current updated Vector3
  75927. */
  75928. set(x: number, y: number, z: number): Vector3;
  75929. /**
  75930. * Copies the given float to the current Vector3 coordinates
  75931. * @param v defines the x, y and z coordinates of the operand
  75932. * @returns the current updated Vector3
  75933. */
  75934. setAll(v: number): Vector3;
  75935. /**
  75936. * Get the clip factor between two vectors
  75937. * @param vector0 defines the first operand
  75938. * @param vector1 defines the second operand
  75939. * @param axis defines the axis to use
  75940. * @param size defines the size along the axis
  75941. * @returns the clip factor
  75942. */
  75943. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75944. /**
  75945. * Get angle between two vectors
  75946. * @param vector0 angle between vector0 and vector1
  75947. * @param vector1 angle between vector0 and vector1
  75948. * @param normal direction of the normal
  75949. * @return the angle between vector0 and vector1
  75950. */
  75951. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75952. /**
  75953. * Returns a new Vector3 set from the index "offset" of the given array
  75954. * @param array defines the source array
  75955. * @param offset defines the offset in the source array
  75956. * @returns the new Vector3
  75957. */
  75958. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75959. /**
  75960. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75961. * @param array defines the source array
  75962. * @param offset defines the offset in the source array
  75963. * @returns the new Vector3
  75964. * @deprecated Please use FromArray instead.
  75965. */
  75966. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75967. /**
  75968. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75969. * @param array defines the source array
  75970. * @param offset defines the offset in the source array
  75971. * @param result defines the Vector3 where to store the result
  75972. */
  75973. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75974. /**
  75975. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75976. * @param array defines the source array
  75977. * @param offset defines the offset in the source array
  75978. * @param result defines the Vector3 where to store the result
  75979. * @deprecated Please use FromArrayToRef instead.
  75980. */
  75981. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75982. /**
  75983. * Sets the given vector "result" with the given floats.
  75984. * @param x defines the x coordinate of the source
  75985. * @param y defines the y coordinate of the source
  75986. * @param z defines the z coordinate of the source
  75987. * @param result defines the Vector3 where to store the result
  75988. */
  75989. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75990. /**
  75991. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75992. * @returns a new empty Vector3
  75993. */
  75994. static Zero(): Vector3;
  75995. /**
  75996. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75997. * @returns a new unit Vector3
  75998. */
  75999. static One(): Vector3;
  76000. /**
  76001. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76002. * @returns a new up Vector3
  76003. */
  76004. static Up(): Vector3;
  76005. /**
  76006. * Gets a up Vector3 that must not be updated
  76007. */
  76008. static get UpReadOnly(): DeepImmutable<Vector3>;
  76009. /**
  76010. * Gets a zero Vector3 that must not be updated
  76011. */
  76012. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76013. /**
  76014. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76015. * @returns a new down Vector3
  76016. */
  76017. static Down(): Vector3;
  76018. /**
  76019. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76020. * @returns a new forward Vector3
  76021. */
  76022. static Forward(): Vector3;
  76023. /**
  76024. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76025. * @returns a new forward Vector3
  76026. */
  76027. static Backward(): Vector3;
  76028. /**
  76029. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76030. * @returns a new right Vector3
  76031. */
  76032. static Right(): Vector3;
  76033. /**
  76034. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76035. * @returns a new left Vector3
  76036. */
  76037. static Left(): Vector3;
  76038. /**
  76039. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76040. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76041. * @param vector defines the Vector3 to transform
  76042. * @param transformation defines the transformation matrix
  76043. * @returns the transformed Vector3
  76044. */
  76045. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76046. /**
  76047. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76048. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76049. * @param vector defines the Vector3 to transform
  76050. * @param transformation defines the transformation matrix
  76051. * @param result defines the Vector3 where to store the result
  76052. */
  76053. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76054. /**
  76055. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76056. * This method computes tranformed coordinates only, not transformed direction vectors
  76057. * @param x define the x coordinate of the source vector
  76058. * @param y define the y coordinate of the source vector
  76059. * @param z define the z coordinate of the source vector
  76060. * @param transformation defines the transformation matrix
  76061. * @param result defines the Vector3 where to store the result
  76062. */
  76063. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76064. /**
  76065. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76066. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76067. * @param vector defines the Vector3 to transform
  76068. * @param transformation defines the transformation matrix
  76069. * @returns the new Vector3
  76070. */
  76071. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76072. /**
  76073. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76074. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76075. * @param vector defines the Vector3 to transform
  76076. * @param transformation defines the transformation matrix
  76077. * @param result defines the Vector3 where to store the result
  76078. */
  76079. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76080. /**
  76081. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76082. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76083. * @param x define the x coordinate of the source vector
  76084. * @param y define the y coordinate of the source vector
  76085. * @param z define the z coordinate of the source vector
  76086. * @param transformation defines the transformation matrix
  76087. * @param result defines the Vector3 where to store the result
  76088. */
  76089. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76090. /**
  76091. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76092. * @param value1 defines the first control point
  76093. * @param value2 defines the second control point
  76094. * @param value3 defines the third control point
  76095. * @param value4 defines the fourth control point
  76096. * @param amount defines the amount on the spline to use
  76097. * @returns the new Vector3
  76098. */
  76099. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76100. /**
  76101. * 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"
  76102. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76103. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76104. * @param value defines the current value
  76105. * @param min defines the lower range value
  76106. * @param max defines the upper range value
  76107. * @returns the new Vector3
  76108. */
  76109. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76110. /**
  76111. * 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"
  76112. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76113. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76114. * @param value defines the current value
  76115. * @param min defines the lower range value
  76116. * @param max defines the upper range value
  76117. * @param result defines the Vector3 where to store the result
  76118. */
  76119. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76120. /**
  76121. * Checks if a given vector is inside a specific range
  76122. * @param v defines the vector to test
  76123. * @param min defines the minimum range
  76124. * @param max defines the maximum range
  76125. */
  76126. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76127. /**
  76128. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76129. * @param value1 defines the first control point
  76130. * @param tangent1 defines the first tangent vector
  76131. * @param value2 defines the second control point
  76132. * @param tangent2 defines the second tangent vector
  76133. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76134. * @returns the new Vector3
  76135. */
  76136. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76137. /**
  76138. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76139. * @param start defines the start value
  76140. * @param end defines the end value
  76141. * @param amount max defines amount between both (between 0 and 1)
  76142. * @returns the new Vector3
  76143. */
  76144. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76145. /**
  76146. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76147. * @param start defines the start value
  76148. * @param end defines the end value
  76149. * @param amount max defines amount between both (between 0 and 1)
  76150. * @param result defines the Vector3 where to store the result
  76151. */
  76152. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76153. /**
  76154. * Returns the dot product (float) between the vectors "left" and "right"
  76155. * @param left defines the left operand
  76156. * @param right defines the right operand
  76157. * @returns the dot product
  76158. */
  76159. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76160. /**
  76161. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76162. * The cross product is then orthogonal to both "left" and "right"
  76163. * @param left defines the left operand
  76164. * @param right defines the right operand
  76165. * @returns the cross product
  76166. */
  76167. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76168. /**
  76169. * Sets the given vector "result" with the cross product of "left" and "right"
  76170. * The cross product is then orthogonal to both "left" and "right"
  76171. * @param left defines the left operand
  76172. * @param right defines the right operand
  76173. * @param result defines the Vector3 where to store the result
  76174. */
  76175. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76176. /**
  76177. * Returns a new Vector3 as the normalization of the given vector
  76178. * @param vector defines the Vector3 to normalize
  76179. * @returns the new Vector3
  76180. */
  76181. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76182. /**
  76183. * Sets the given vector "result" with the normalization of the given first vector
  76184. * @param vector defines the Vector3 to normalize
  76185. * @param result defines the Vector3 where to store the result
  76186. */
  76187. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76188. /**
  76189. * Project a Vector3 onto screen space
  76190. * @param vector defines the Vector3 to project
  76191. * @param world defines the world matrix to use
  76192. * @param transform defines the transform (view x projection) matrix to use
  76193. * @param viewport defines the screen viewport to use
  76194. * @returns the new Vector3
  76195. */
  76196. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76197. /** @hidden */
  76198. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76199. /**
  76200. * Unproject from screen space to object space
  76201. * @param source defines the screen space Vector3 to use
  76202. * @param viewportWidth defines the current width of the viewport
  76203. * @param viewportHeight defines the current height of the viewport
  76204. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76205. * @param transform defines the transform (view x projection) matrix to use
  76206. * @returns the new Vector3
  76207. */
  76208. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: 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. * @returns the new Vector3
  76218. */
  76219. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76220. /**
  76221. * Unproject from screen space to object space
  76222. * @param source defines the screen space Vector3 to use
  76223. * @param viewportWidth defines the current width of the viewport
  76224. * @param viewportHeight defines the current height of the viewport
  76225. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76226. * @param view defines the view matrix to use
  76227. * @param projection defines the projection matrix to use
  76228. * @param result defines the Vector3 where to store the result
  76229. */
  76230. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76231. /**
  76232. * Unproject from screen space to object space
  76233. * @param sourceX defines the screen space x coordinate to use
  76234. * @param sourceY defines the screen space y coordinate to use
  76235. * @param sourceZ defines the screen space z coordinate to use
  76236. * @param viewportWidth defines the current width of the viewport
  76237. * @param viewportHeight defines the current height of the viewport
  76238. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76239. * @param view defines the view matrix to use
  76240. * @param projection defines the projection matrix to use
  76241. * @param result defines the Vector3 where to store the result
  76242. */
  76243. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76244. /**
  76245. * Gets the minimal coordinate values between two Vector3
  76246. * @param left defines the first operand
  76247. * @param right defines the second operand
  76248. * @returns the new Vector3
  76249. */
  76250. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76251. /**
  76252. * Gets the maximal coordinate values between two Vector3
  76253. * @param left defines the first operand
  76254. * @param right defines the second operand
  76255. * @returns the new Vector3
  76256. */
  76257. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76258. /**
  76259. * Returns the distance between the vectors "value1" and "value2"
  76260. * @param value1 defines the first operand
  76261. * @param value2 defines the second operand
  76262. * @returns the distance
  76263. */
  76264. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76265. /**
  76266. * Returns the squared distance between the vectors "value1" and "value2"
  76267. * @param value1 defines the first operand
  76268. * @param value2 defines the second operand
  76269. * @returns the squared distance
  76270. */
  76271. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76272. /**
  76273. * Returns a new Vector3 located at the center between "value1" and "value2"
  76274. * @param value1 defines the first operand
  76275. * @param value2 defines the second operand
  76276. * @returns the new Vector3
  76277. */
  76278. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76279. /**
  76280. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76281. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76282. * to something in order to rotate it from its local system to the given target system
  76283. * Note: axis1, axis2 and axis3 are normalized during this operation
  76284. * @param axis1 defines the first axis
  76285. * @param axis2 defines the second axis
  76286. * @param axis3 defines the third axis
  76287. * @returns a new Vector3
  76288. */
  76289. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76290. /**
  76291. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76292. * @param axis1 defines the first axis
  76293. * @param axis2 defines the second axis
  76294. * @param axis3 defines the third axis
  76295. * @param ref defines the Vector3 where to store the result
  76296. */
  76297. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76298. }
  76299. /**
  76300. * Vector4 class created for EulerAngle class conversion to Quaternion
  76301. */
  76302. export class Vector4 {
  76303. /** x value of the vector */
  76304. x: number;
  76305. /** y value of the vector */
  76306. y: number;
  76307. /** z value of the vector */
  76308. z: number;
  76309. /** w value of the vector */
  76310. w: number;
  76311. /**
  76312. * Creates a Vector4 object from the given floats.
  76313. * @param x x value of the vector
  76314. * @param y y value of the vector
  76315. * @param z z value of the vector
  76316. * @param w w value of the vector
  76317. */
  76318. constructor(
  76319. /** x value of the vector */
  76320. x: number,
  76321. /** y value of the vector */
  76322. y: number,
  76323. /** z value of the vector */
  76324. z: number,
  76325. /** w value of the vector */
  76326. w: number);
  76327. /**
  76328. * Returns the string with the Vector4 coordinates.
  76329. * @returns a string containing all the vector values
  76330. */
  76331. toString(): string;
  76332. /**
  76333. * Returns the string "Vector4".
  76334. * @returns "Vector4"
  76335. */
  76336. getClassName(): string;
  76337. /**
  76338. * Returns the Vector4 hash code.
  76339. * @returns a unique hash code
  76340. */
  76341. getHashCode(): number;
  76342. /**
  76343. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76344. * @returns the resulting array
  76345. */
  76346. asArray(): number[];
  76347. /**
  76348. * Populates the given array from the given index with the Vector4 coordinates.
  76349. * @param array array to populate
  76350. * @param index index of the array to start at (default: 0)
  76351. * @returns the Vector4.
  76352. */
  76353. toArray(array: FloatArray, index?: number): Vector4;
  76354. /**
  76355. * Adds the given vector to the current Vector4.
  76356. * @param otherVector the vector to add
  76357. * @returns the updated Vector4.
  76358. */
  76359. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76360. /**
  76361. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76362. * @param otherVector the vector to add
  76363. * @returns the resulting vector
  76364. */
  76365. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76366. /**
  76367. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76368. * @param otherVector the vector to add
  76369. * @param result the vector to store the result
  76370. * @returns the current Vector4.
  76371. */
  76372. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76373. /**
  76374. * Subtract in place the given vector from the current Vector4.
  76375. * @param otherVector the vector to subtract
  76376. * @returns the updated Vector4.
  76377. */
  76378. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76379. /**
  76380. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76381. * @param otherVector the vector to add
  76382. * @returns the new vector with the result
  76383. */
  76384. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76385. /**
  76386. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76387. * @param otherVector the vector to subtract
  76388. * @param result the vector to store the result
  76389. * @returns the current Vector4.
  76390. */
  76391. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76392. /**
  76393. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76394. */
  76395. /**
  76396. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76397. * @param x value to subtract
  76398. * @param y value to subtract
  76399. * @param z value to subtract
  76400. * @param w value to subtract
  76401. * @returns new vector containing the result
  76402. */
  76403. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76404. /**
  76405. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76406. * @param x value to subtract
  76407. * @param y value to subtract
  76408. * @param z value to subtract
  76409. * @param w value to subtract
  76410. * @param result the vector to store the result in
  76411. * @returns the current Vector4.
  76412. */
  76413. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76414. /**
  76415. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76416. * @returns a new vector with the negated values
  76417. */
  76418. negate(): Vector4;
  76419. /**
  76420. * Negate this vector in place
  76421. * @returns this
  76422. */
  76423. negateInPlace(): Vector4;
  76424. /**
  76425. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76426. * @param result defines the Vector3 object where to store the result
  76427. * @returns the current Vector4
  76428. */
  76429. negateToRef(result: Vector4): Vector4;
  76430. /**
  76431. * Multiplies the current Vector4 coordinates by scale (float).
  76432. * @param scale the number to scale with
  76433. * @returns the updated Vector4.
  76434. */
  76435. scaleInPlace(scale: number): Vector4;
  76436. /**
  76437. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76438. * @param scale the number to scale with
  76439. * @returns a new vector with the result
  76440. */
  76441. scale(scale: number): Vector4;
  76442. /**
  76443. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76444. * @param scale the number to scale with
  76445. * @param result a vector to store the result in
  76446. * @returns the current Vector4.
  76447. */
  76448. scaleToRef(scale: number, result: Vector4): Vector4;
  76449. /**
  76450. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76451. * @param scale defines the scale factor
  76452. * @param result defines the Vector4 object where to store the result
  76453. * @returns the unmodified current Vector4
  76454. */
  76455. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76456. /**
  76457. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76458. * @param otherVector the vector to compare against
  76459. * @returns true if they are equal
  76460. */
  76461. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76462. /**
  76463. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76464. * @param otherVector vector to compare against
  76465. * @param epsilon (Default: very small number)
  76466. * @returns true if they are equal
  76467. */
  76468. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76469. /**
  76470. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76471. * @param x x value to compare against
  76472. * @param y y value to compare against
  76473. * @param z z value to compare against
  76474. * @param w w value to compare against
  76475. * @returns true if equal
  76476. */
  76477. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76478. /**
  76479. * Multiplies in place the current Vector4 by the given one.
  76480. * @param otherVector vector to multiple with
  76481. * @returns the updated Vector4.
  76482. */
  76483. multiplyInPlace(otherVector: Vector4): Vector4;
  76484. /**
  76485. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76486. * @param otherVector vector to multiple with
  76487. * @returns resulting new vector
  76488. */
  76489. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76490. /**
  76491. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76492. * @param otherVector vector to multiple with
  76493. * @param result vector to store the result
  76494. * @returns the current Vector4.
  76495. */
  76496. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76497. /**
  76498. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76499. * @param x x value multiply with
  76500. * @param y y value multiply with
  76501. * @param z z value multiply with
  76502. * @param w w value multiply with
  76503. * @returns resulting new vector
  76504. */
  76505. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76506. /**
  76507. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76508. * @param otherVector vector to devide with
  76509. * @returns resulting new vector
  76510. */
  76511. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76512. /**
  76513. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76514. * @param otherVector vector to devide with
  76515. * @param result vector to store the result
  76516. * @returns the current Vector4.
  76517. */
  76518. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76519. /**
  76520. * Divides the current Vector3 coordinates by the given ones.
  76521. * @param otherVector vector to devide with
  76522. * @returns the updated Vector3.
  76523. */
  76524. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76525. /**
  76526. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76527. * @param other defines the second operand
  76528. * @returns the current updated Vector4
  76529. */
  76530. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76531. /**
  76532. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76533. * @param other defines the second operand
  76534. * @returns the current updated Vector4
  76535. */
  76536. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76537. /**
  76538. * Gets a new Vector4 from current Vector4 floored values
  76539. * @returns a new Vector4
  76540. */
  76541. floor(): Vector4;
  76542. /**
  76543. * Gets a new Vector4 from current Vector3 floored values
  76544. * @returns a new Vector4
  76545. */
  76546. fract(): Vector4;
  76547. /**
  76548. * Returns the Vector4 length (float).
  76549. * @returns the length
  76550. */
  76551. length(): number;
  76552. /**
  76553. * Returns the Vector4 squared length (float).
  76554. * @returns the length squared
  76555. */
  76556. lengthSquared(): number;
  76557. /**
  76558. * Normalizes in place the Vector4.
  76559. * @returns the updated Vector4.
  76560. */
  76561. normalize(): Vector4;
  76562. /**
  76563. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76564. * @returns this converted to a new vector3
  76565. */
  76566. toVector3(): Vector3;
  76567. /**
  76568. * Returns a new Vector4 copied from the current one.
  76569. * @returns the new cloned vector
  76570. */
  76571. clone(): Vector4;
  76572. /**
  76573. * Updates the current Vector4 with the given one coordinates.
  76574. * @param source the source vector to copy from
  76575. * @returns the updated Vector4.
  76576. */
  76577. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76578. /**
  76579. * Updates the current Vector4 coordinates with the given floats.
  76580. * @param x float to copy from
  76581. * @param y float to copy from
  76582. * @param z float to copy from
  76583. * @param w float to copy from
  76584. * @returns the updated Vector4.
  76585. */
  76586. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76587. /**
  76588. * Updates the current Vector4 coordinates with the given floats.
  76589. * @param x float to set from
  76590. * @param y float to set from
  76591. * @param z float to set from
  76592. * @param w float to set from
  76593. * @returns the updated Vector4.
  76594. */
  76595. set(x: number, y: number, z: number, w: number): Vector4;
  76596. /**
  76597. * Copies the given float to the current Vector3 coordinates
  76598. * @param v defines the x, y, z and w coordinates of the operand
  76599. * @returns the current updated Vector3
  76600. */
  76601. setAll(v: number): Vector4;
  76602. /**
  76603. * Returns a new Vector4 set from the starting index of the given array.
  76604. * @param array the array to pull values from
  76605. * @param offset the offset into the array to start at
  76606. * @returns the new vector
  76607. */
  76608. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76609. /**
  76610. * Updates the given vector "result" from the starting index of the given array.
  76611. * @param array the array to pull values from
  76612. * @param offset the offset into the array to start at
  76613. * @param result the vector to store the result in
  76614. */
  76615. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76616. /**
  76617. * Updates the given vector "result" from the starting index of the given Float32Array.
  76618. * @param array the array to pull values from
  76619. * @param offset the offset into the array to start at
  76620. * @param result the vector to store the result in
  76621. */
  76622. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76623. /**
  76624. * Updates the given vector "result" coordinates from the given floats.
  76625. * @param x float to set from
  76626. * @param y float to set from
  76627. * @param z float to set from
  76628. * @param w float to set from
  76629. * @param result the vector to the floats in
  76630. */
  76631. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76632. /**
  76633. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76634. * @returns the new vector
  76635. */
  76636. static Zero(): Vector4;
  76637. /**
  76638. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76639. * @returns the new vector
  76640. */
  76641. static One(): Vector4;
  76642. /**
  76643. * Returns a new normalized Vector4 from the given one.
  76644. * @param vector the vector to normalize
  76645. * @returns the vector
  76646. */
  76647. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76648. /**
  76649. * Updates the given vector "result" from the normalization of the given one.
  76650. * @param vector the vector to normalize
  76651. * @param result the vector to store the result in
  76652. */
  76653. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76654. /**
  76655. * Returns a vector with the minimum values from the left and right vectors
  76656. * @param left left vector to minimize
  76657. * @param right right vector to minimize
  76658. * @returns a new vector with the minimum of the left and right vector values
  76659. */
  76660. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76661. /**
  76662. * Returns a vector with the maximum values from the left and right vectors
  76663. * @param left left vector to maximize
  76664. * @param right right vector to maximize
  76665. * @returns a new vector with the maximum of the left and right vector values
  76666. */
  76667. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76668. /**
  76669. * Returns the distance (float) between the vectors "value1" and "value2".
  76670. * @param value1 value to calulate the distance between
  76671. * @param value2 value to calulate the distance between
  76672. * @return the distance between the two vectors
  76673. */
  76674. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76675. /**
  76676. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76677. * @param value1 value to calulate the distance between
  76678. * @param value2 value to calulate the distance between
  76679. * @return the distance between the two vectors squared
  76680. */
  76681. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76682. /**
  76683. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76684. * @param value1 value to calulate the center between
  76685. * @param value2 value to calulate the center between
  76686. * @return the center between the two vectors
  76687. */
  76688. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76689. /**
  76690. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76691. * This methods computes transformed normalized direction vectors only.
  76692. * @param vector the vector to transform
  76693. * @param transformation the transformation matrix to apply
  76694. * @returns the new vector
  76695. */
  76696. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76697. /**
  76698. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76699. * This methods computes transformed normalized direction vectors only.
  76700. * @param vector the vector to transform
  76701. * @param transformation the transformation matrix to apply
  76702. * @param result the vector to store the result in
  76703. */
  76704. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76705. /**
  76706. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76707. * This methods computes transformed normalized direction vectors only.
  76708. * @param x value to transform
  76709. * @param y value to transform
  76710. * @param z value to transform
  76711. * @param w value to transform
  76712. * @param transformation the transformation matrix to apply
  76713. * @param result the vector to store the results in
  76714. */
  76715. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76716. /**
  76717. * Creates a new Vector4 from a Vector3
  76718. * @param source defines the source data
  76719. * @param w defines the 4th component (default is 0)
  76720. * @returns a new Vector4
  76721. */
  76722. static FromVector3(source: Vector3, w?: number): Vector4;
  76723. }
  76724. /**
  76725. * Class used to store quaternion data
  76726. * @see https://en.wikipedia.org/wiki/Quaternion
  76727. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76728. */
  76729. export class Quaternion {
  76730. /** defines the first component (0 by default) */
  76731. x: number;
  76732. /** defines the second component (0 by default) */
  76733. y: number;
  76734. /** defines the third component (0 by default) */
  76735. z: number;
  76736. /** defines the fourth component (1.0 by default) */
  76737. w: number;
  76738. /**
  76739. * Creates a new Quaternion from the given floats
  76740. * @param x defines the first component (0 by default)
  76741. * @param y defines the second component (0 by default)
  76742. * @param z defines the third component (0 by default)
  76743. * @param w defines the fourth component (1.0 by default)
  76744. */
  76745. constructor(
  76746. /** defines the first component (0 by default) */
  76747. x?: number,
  76748. /** defines the second component (0 by default) */
  76749. y?: number,
  76750. /** defines the third component (0 by default) */
  76751. z?: number,
  76752. /** defines the fourth component (1.0 by default) */
  76753. w?: number);
  76754. /**
  76755. * Gets a string representation for the current quaternion
  76756. * @returns a string with the Quaternion coordinates
  76757. */
  76758. toString(): string;
  76759. /**
  76760. * Gets the class name of the quaternion
  76761. * @returns the string "Quaternion"
  76762. */
  76763. getClassName(): string;
  76764. /**
  76765. * Gets a hash code for this quaternion
  76766. * @returns the quaternion hash code
  76767. */
  76768. getHashCode(): number;
  76769. /**
  76770. * Copy the quaternion to an array
  76771. * @returns a new array populated with 4 elements from the quaternion coordinates
  76772. */
  76773. asArray(): number[];
  76774. /**
  76775. * Check if two quaternions are equals
  76776. * @param otherQuaternion defines the second operand
  76777. * @return true if the current quaternion and the given one coordinates are strictly equals
  76778. */
  76779. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76780. /**
  76781. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76782. * @param otherQuaternion defines the other quaternion
  76783. * @param epsilon defines the minimal distance to consider equality
  76784. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76785. */
  76786. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76787. /**
  76788. * Clone the current quaternion
  76789. * @returns a new quaternion copied from the current one
  76790. */
  76791. clone(): Quaternion;
  76792. /**
  76793. * Copy a quaternion to the current one
  76794. * @param other defines the other quaternion
  76795. * @returns the updated current quaternion
  76796. */
  76797. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76798. /**
  76799. * Updates the current quaternion with the given float coordinates
  76800. * @param x defines the x coordinate
  76801. * @param y defines the y coordinate
  76802. * @param z defines the z coordinate
  76803. * @param w defines the w coordinate
  76804. * @returns the updated current quaternion
  76805. */
  76806. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76807. /**
  76808. * Updates the current quaternion from the given float coordinates
  76809. * @param x defines the x coordinate
  76810. * @param y defines the y coordinate
  76811. * @param z defines the z coordinate
  76812. * @param w defines the w coordinate
  76813. * @returns the updated current quaternion
  76814. */
  76815. set(x: number, y: number, z: number, w: number): Quaternion;
  76816. /**
  76817. * Adds two quaternions
  76818. * @param other defines the second operand
  76819. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76820. */
  76821. add(other: DeepImmutable<Quaternion>): Quaternion;
  76822. /**
  76823. * Add a quaternion to the current one
  76824. * @param other defines the quaternion to add
  76825. * @returns the current quaternion
  76826. */
  76827. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76828. /**
  76829. * Subtract two quaternions
  76830. * @param other defines the second operand
  76831. * @returns a new quaternion as the subtraction result of the given one from the current one
  76832. */
  76833. subtract(other: Quaternion): Quaternion;
  76834. /**
  76835. * Multiplies the current quaternion by a scale factor
  76836. * @param value defines the scale factor
  76837. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76838. */
  76839. scale(value: number): Quaternion;
  76840. /**
  76841. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76842. * @param scale defines the scale factor
  76843. * @param result defines the Quaternion object where to store the result
  76844. * @returns the unmodified current quaternion
  76845. */
  76846. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76847. /**
  76848. * Multiplies in place the current quaternion by a scale factor
  76849. * @param value defines the scale factor
  76850. * @returns the current modified quaternion
  76851. */
  76852. scaleInPlace(value: number): Quaternion;
  76853. /**
  76854. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76855. * @param scale defines the scale factor
  76856. * @param result defines the Quaternion object where to store the result
  76857. * @returns the unmodified current quaternion
  76858. */
  76859. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76860. /**
  76861. * Multiplies two quaternions
  76862. * @param q1 defines the second operand
  76863. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76864. */
  76865. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76866. /**
  76867. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76868. * @param q1 defines the second operand
  76869. * @param result defines the target quaternion
  76870. * @returns the current quaternion
  76871. */
  76872. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76873. /**
  76874. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76875. * @param q1 defines the second operand
  76876. * @returns the currentupdated quaternion
  76877. */
  76878. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76879. /**
  76880. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76881. * @param ref defines the target quaternion
  76882. * @returns the current quaternion
  76883. */
  76884. conjugateToRef(ref: Quaternion): Quaternion;
  76885. /**
  76886. * Conjugates in place (1-q) the current quaternion
  76887. * @returns the current updated quaternion
  76888. */
  76889. conjugateInPlace(): Quaternion;
  76890. /**
  76891. * Conjugates in place (1-q) the current quaternion
  76892. * @returns a new quaternion
  76893. */
  76894. conjugate(): Quaternion;
  76895. /**
  76896. * Gets length of current quaternion
  76897. * @returns the quaternion length (float)
  76898. */
  76899. length(): number;
  76900. /**
  76901. * Normalize in place the current quaternion
  76902. * @returns the current updated quaternion
  76903. */
  76904. normalize(): Quaternion;
  76905. /**
  76906. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76907. * @param order is a reserved parameter and is ignore for now
  76908. * @returns a new Vector3 containing the Euler angles
  76909. */
  76910. toEulerAngles(order?: string): Vector3;
  76911. /**
  76912. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76913. * @param result defines the vector which will be filled with the Euler angles
  76914. * @param order is a reserved parameter and is ignore for now
  76915. * @returns the current unchanged quaternion
  76916. */
  76917. toEulerAnglesToRef(result: Vector3): Quaternion;
  76918. /**
  76919. * Updates the given rotation matrix with the current quaternion values
  76920. * @param result defines the target matrix
  76921. * @returns the current unchanged quaternion
  76922. */
  76923. toRotationMatrix(result: Matrix): Quaternion;
  76924. /**
  76925. * Updates the current quaternion from the given rotation matrix values
  76926. * @param matrix defines the source matrix
  76927. * @returns the current updated quaternion
  76928. */
  76929. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76930. /**
  76931. * Creates a new quaternion from a rotation matrix
  76932. * @param matrix defines the source matrix
  76933. * @returns a new quaternion created from the given rotation matrix values
  76934. */
  76935. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76936. /**
  76937. * Updates the given quaternion with the given rotation matrix values
  76938. * @param matrix defines the source matrix
  76939. * @param result defines the target quaternion
  76940. */
  76941. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76942. /**
  76943. * Returns the dot product (float) between the quaternions "left" and "right"
  76944. * @param left defines the left operand
  76945. * @param right defines the right operand
  76946. * @returns the dot product
  76947. */
  76948. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76949. /**
  76950. * Checks if the two quaternions are close to each other
  76951. * @param quat0 defines the first quaternion to check
  76952. * @param quat1 defines the second quaternion to check
  76953. * @returns true if the two quaternions are close to each other
  76954. */
  76955. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76956. /**
  76957. * Creates an empty quaternion
  76958. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76959. */
  76960. static Zero(): Quaternion;
  76961. /**
  76962. * Inverse a given quaternion
  76963. * @param q defines the source quaternion
  76964. * @returns a new quaternion as the inverted current quaternion
  76965. */
  76966. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76967. /**
  76968. * Inverse a given quaternion
  76969. * @param q defines the source quaternion
  76970. * @param result the quaternion the result will be stored in
  76971. * @returns the result quaternion
  76972. */
  76973. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76974. /**
  76975. * Creates an identity quaternion
  76976. * @returns the identity quaternion
  76977. */
  76978. static Identity(): Quaternion;
  76979. /**
  76980. * Gets a boolean indicating if the given quaternion is identity
  76981. * @param quaternion defines the quaternion to check
  76982. * @returns true if the quaternion is identity
  76983. */
  76984. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76985. /**
  76986. * Creates a quaternion from a rotation around an axis
  76987. * @param axis defines the axis to use
  76988. * @param angle defines the angle to use
  76989. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76990. */
  76991. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76992. /**
  76993. * Creates a rotation around an axis and stores it into the given quaternion
  76994. * @param axis defines the axis to use
  76995. * @param angle defines the angle to use
  76996. * @param result defines the target quaternion
  76997. * @returns the target quaternion
  76998. */
  76999. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77000. /**
  77001. * Creates a new quaternion from data stored into an array
  77002. * @param array defines the data source
  77003. * @param offset defines the offset in the source array where the data starts
  77004. * @returns a new quaternion
  77005. */
  77006. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77007. /**
  77008. * Create a quaternion from Euler rotation angles
  77009. * @param x Pitch
  77010. * @param y Yaw
  77011. * @param z Roll
  77012. * @returns the new Quaternion
  77013. */
  77014. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77015. /**
  77016. * Updates a quaternion from Euler rotation angles
  77017. * @param x Pitch
  77018. * @param y Yaw
  77019. * @param z Roll
  77020. * @param result the quaternion to store the result
  77021. * @returns the updated quaternion
  77022. */
  77023. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77024. /**
  77025. * Create a quaternion from Euler rotation vector
  77026. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77027. * @returns the new Quaternion
  77028. */
  77029. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77030. /**
  77031. * Updates a quaternion from Euler rotation vector
  77032. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77033. * @param result the quaternion to store the result
  77034. * @returns the updated quaternion
  77035. */
  77036. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77037. /**
  77038. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77039. * @param yaw defines the rotation around Y axis
  77040. * @param pitch defines the rotation around X axis
  77041. * @param roll defines the rotation around Z axis
  77042. * @returns the new quaternion
  77043. */
  77044. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77045. /**
  77046. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77047. * @param yaw defines the rotation around Y axis
  77048. * @param pitch defines the rotation around X axis
  77049. * @param roll defines the rotation around Z axis
  77050. * @param result defines the target quaternion
  77051. */
  77052. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77053. /**
  77054. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77055. * @param alpha defines the rotation around first axis
  77056. * @param beta defines the rotation around second axis
  77057. * @param gamma defines the rotation around third axis
  77058. * @returns the new quaternion
  77059. */
  77060. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77061. /**
  77062. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77063. * @param alpha defines the rotation around first axis
  77064. * @param beta defines the rotation around second axis
  77065. * @param gamma defines the rotation around third axis
  77066. * @param result defines the target quaternion
  77067. */
  77068. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77069. /**
  77070. * 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)
  77071. * @param axis1 defines the first axis
  77072. * @param axis2 defines the second axis
  77073. * @param axis3 defines the third axis
  77074. * @returns the new quaternion
  77075. */
  77076. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77077. /**
  77078. * 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
  77079. * @param axis1 defines the first axis
  77080. * @param axis2 defines the second axis
  77081. * @param axis3 defines the third axis
  77082. * @param ref defines the target quaternion
  77083. */
  77084. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77085. /**
  77086. * Interpolates between two quaternions
  77087. * @param left defines first quaternion
  77088. * @param right defines second quaternion
  77089. * @param amount defines the gradient to use
  77090. * @returns the new interpolated quaternion
  77091. */
  77092. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77093. /**
  77094. * Interpolates between two quaternions and stores it into a target quaternion
  77095. * @param left defines first quaternion
  77096. * @param right defines second quaternion
  77097. * @param amount defines the gradient to use
  77098. * @param result defines the target quaternion
  77099. */
  77100. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77101. /**
  77102. * Interpolate between two quaternions using Hermite interpolation
  77103. * @param value1 defines first quaternion
  77104. * @param tangent1 defines the incoming tangent
  77105. * @param value2 defines second quaternion
  77106. * @param tangent2 defines the outgoing tangent
  77107. * @param amount defines the target quaternion
  77108. * @returns the new interpolated quaternion
  77109. */
  77110. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77111. }
  77112. /**
  77113. * Class used to store matrix data (4x4)
  77114. */
  77115. export class Matrix {
  77116. private static _updateFlagSeed;
  77117. private static _identityReadOnly;
  77118. private _isIdentity;
  77119. private _isIdentityDirty;
  77120. private _isIdentity3x2;
  77121. private _isIdentity3x2Dirty;
  77122. /**
  77123. * Gets the update flag of the matrix which is an unique number for the matrix.
  77124. * It will be incremented every time the matrix data change.
  77125. * You can use it to speed the comparison between two versions of the same matrix.
  77126. */
  77127. updateFlag: number;
  77128. private readonly _m;
  77129. /**
  77130. * Gets the internal data of the matrix
  77131. */
  77132. get m(): DeepImmutable<Float32Array>;
  77133. /** @hidden */
  77134. _markAsUpdated(): void;
  77135. /** @hidden */
  77136. private _updateIdentityStatus;
  77137. /**
  77138. * Creates an empty matrix (filled with zeros)
  77139. */
  77140. constructor();
  77141. /**
  77142. * Check if the current matrix is identity
  77143. * @returns true is the matrix is the identity matrix
  77144. */
  77145. isIdentity(): boolean;
  77146. /**
  77147. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77148. * @returns true is the matrix is the identity matrix
  77149. */
  77150. isIdentityAs3x2(): boolean;
  77151. /**
  77152. * Gets the determinant of the matrix
  77153. * @returns the matrix determinant
  77154. */
  77155. determinant(): number;
  77156. /**
  77157. * Returns the matrix as a Float32Array
  77158. * @returns the matrix underlying array
  77159. */
  77160. toArray(): DeepImmutable<Float32Array>;
  77161. /**
  77162. * Returns the matrix as a Float32Array
  77163. * @returns the matrix underlying array.
  77164. */
  77165. asArray(): DeepImmutable<Float32Array>;
  77166. /**
  77167. * Inverts the current matrix in place
  77168. * @returns the current inverted matrix
  77169. */
  77170. invert(): Matrix;
  77171. /**
  77172. * Sets all the matrix elements to zero
  77173. * @returns the current matrix
  77174. */
  77175. reset(): Matrix;
  77176. /**
  77177. * Adds the current matrix with a second one
  77178. * @param other defines the matrix to add
  77179. * @returns a new matrix as the addition of the current matrix and the given one
  77180. */
  77181. add(other: DeepImmutable<Matrix>): Matrix;
  77182. /**
  77183. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77184. * @param other defines the matrix to add
  77185. * @param result defines the target matrix
  77186. * @returns the current matrix
  77187. */
  77188. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77189. /**
  77190. * Adds in place the given matrix to the current matrix
  77191. * @param other defines the second operand
  77192. * @returns the current updated matrix
  77193. */
  77194. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77195. /**
  77196. * Sets the given matrix to the current inverted Matrix
  77197. * @param other defines the target matrix
  77198. * @returns the unmodified current matrix
  77199. */
  77200. invertToRef(other: Matrix): Matrix;
  77201. /**
  77202. * add a value at the specified position in the current Matrix
  77203. * @param index the index of the value within the matrix. between 0 and 15.
  77204. * @param value the value to be added
  77205. * @returns the current updated matrix
  77206. */
  77207. addAtIndex(index: number, value: number): Matrix;
  77208. /**
  77209. * mutiply the specified position in the current Matrix by a value
  77210. * @param index the index of the value within the matrix. between 0 and 15.
  77211. * @param value the value to be added
  77212. * @returns the current updated matrix
  77213. */
  77214. multiplyAtIndex(index: number, value: number): Matrix;
  77215. /**
  77216. * Inserts the translation vector (using 3 floats) in the current matrix
  77217. * @param x defines the 1st component of the translation
  77218. * @param y defines the 2nd component of the translation
  77219. * @param z defines the 3rd component of the translation
  77220. * @returns the current updated matrix
  77221. */
  77222. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77223. /**
  77224. * Adds the translation vector (using 3 floats) in the current matrix
  77225. * @param x defines the 1st component of the translation
  77226. * @param y defines the 2nd component of the translation
  77227. * @param z defines the 3rd component of the translation
  77228. * @returns the current updated matrix
  77229. */
  77230. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77231. /**
  77232. * Inserts the translation vector in the current matrix
  77233. * @param vector3 defines the translation to insert
  77234. * @returns the current updated matrix
  77235. */
  77236. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77237. /**
  77238. * Gets the translation value of the current matrix
  77239. * @returns a new Vector3 as the extracted translation from the matrix
  77240. */
  77241. getTranslation(): Vector3;
  77242. /**
  77243. * Fill a Vector3 with the extracted translation from the matrix
  77244. * @param result defines the Vector3 where to store the translation
  77245. * @returns the current matrix
  77246. */
  77247. getTranslationToRef(result: Vector3): Matrix;
  77248. /**
  77249. * Remove rotation and scaling part from the matrix
  77250. * @returns the updated matrix
  77251. */
  77252. removeRotationAndScaling(): Matrix;
  77253. /**
  77254. * Multiply two matrices
  77255. * @param other defines the second operand
  77256. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77257. */
  77258. multiply(other: DeepImmutable<Matrix>): Matrix;
  77259. /**
  77260. * Copy the current matrix from the given one
  77261. * @param other defines the source matrix
  77262. * @returns the current updated matrix
  77263. */
  77264. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77265. /**
  77266. * Populates the given array from the starting index with the current matrix values
  77267. * @param array defines the target array
  77268. * @param offset defines the offset in the target array where to start storing values
  77269. * @returns the current matrix
  77270. */
  77271. copyToArray(array: Float32Array, offset?: number): Matrix;
  77272. /**
  77273. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77274. * @param other defines the second operand
  77275. * @param result defines the matrix where to store the multiplication
  77276. * @returns the current matrix
  77277. */
  77278. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77279. /**
  77280. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77281. * @param other defines the second operand
  77282. * @param result defines the array where to store the multiplication
  77283. * @param offset defines the offset in the target array where to start storing values
  77284. * @returns the current matrix
  77285. */
  77286. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77287. /**
  77288. * Check equality between this matrix and a second one
  77289. * @param value defines the second matrix to compare
  77290. * @returns true is the current matrix and the given one values are strictly equal
  77291. */
  77292. equals(value: DeepImmutable<Matrix>): boolean;
  77293. /**
  77294. * Clone the current matrix
  77295. * @returns a new matrix from the current matrix
  77296. */
  77297. clone(): Matrix;
  77298. /**
  77299. * Returns the name of the current matrix class
  77300. * @returns the string "Matrix"
  77301. */
  77302. getClassName(): string;
  77303. /**
  77304. * Gets the hash code of the current matrix
  77305. * @returns the hash code
  77306. */
  77307. getHashCode(): number;
  77308. /**
  77309. * Decomposes the current Matrix into a translation, rotation and scaling components
  77310. * @param scale defines the scale vector3 given as a reference to update
  77311. * @param rotation defines the rotation quaternion given as a reference to update
  77312. * @param translation defines the translation vector3 given as a reference to update
  77313. * @returns true if operation was successful
  77314. */
  77315. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77316. /**
  77317. * Gets specific row of the matrix
  77318. * @param index defines the number of the row to get
  77319. * @returns the index-th row of the current matrix as a new Vector4
  77320. */
  77321. getRow(index: number): Nullable<Vector4>;
  77322. /**
  77323. * Sets the index-th row of the current matrix to the vector4 values
  77324. * @param index defines the number of the row to set
  77325. * @param row defines the target vector4
  77326. * @returns the updated current matrix
  77327. */
  77328. setRow(index: number, row: Vector4): Matrix;
  77329. /**
  77330. * Compute the transpose of the matrix
  77331. * @returns the new transposed matrix
  77332. */
  77333. transpose(): Matrix;
  77334. /**
  77335. * Compute the transpose of the matrix and store it in a given matrix
  77336. * @param result defines the target matrix
  77337. * @returns the current matrix
  77338. */
  77339. transposeToRef(result: Matrix): Matrix;
  77340. /**
  77341. * Sets the index-th row of the current matrix with the given 4 x float values
  77342. * @param index defines the row index
  77343. * @param x defines the x component to set
  77344. * @param y defines the y component to set
  77345. * @param z defines the z component to set
  77346. * @param w defines the w component to set
  77347. * @returns the updated current matrix
  77348. */
  77349. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77350. /**
  77351. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77352. * @param scale defines the scale factor
  77353. * @returns a new matrix
  77354. */
  77355. scale(scale: number): Matrix;
  77356. /**
  77357. * Scale the current matrix values by a factor to a given result matrix
  77358. * @param scale defines the scale factor
  77359. * @param result defines the matrix to store the result
  77360. * @returns the current matrix
  77361. */
  77362. scaleToRef(scale: number, result: Matrix): Matrix;
  77363. /**
  77364. * Scale the current matrix values by a factor and add the result to a given matrix
  77365. * @param scale defines the scale factor
  77366. * @param result defines the Matrix to store the result
  77367. * @returns the current matrix
  77368. */
  77369. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77370. /**
  77371. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77372. * @param ref matrix to store the result
  77373. */
  77374. toNormalMatrix(ref: Matrix): void;
  77375. /**
  77376. * Gets only rotation part of the current matrix
  77377. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77378. */
  77379. getRotationMatrix(): Matrix;
  77380. /**
  77381. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77382. * @param result defines the target matrix to store data to
  77383. * @returns the current matrix
  77384. */
  77385. getRotationMatrixToRef(result: Matrix): Matrix;
  77386. /**
  77387. * Toggles model matrix from being right handed to left handed in place and vice versa
  77388. */
  77389. toggleModelMatrixHandInPlace(): void;
  77390. /**
  77391. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77392. */
  77393. toggleProjectionMatrixHandInPlace(): void;
  77394. /**
  77395. * Creates a matrix from an array
  77396. * @param array defines the source array
  77397. * @param offset defines an offset in the source array
  77398. * @returns a new Matrix set from the starting index of the given array
  77399. */
  77400. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77401. /**
  77402. * Copy the content of an array into a given matrix
  77403. * @param array defines the source array
  77404. * @param offset defines an offset in the source array
  77405. * @param result defines the target matrix
  77406. */
  77407. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77408. /**
  77409. * Stores an array into a matrix after having multiplied each component by a given factor
  77410. * @param array defines the source array
  77411. * @param offset defines the offset in the source array
  77412. * @param scale defines the scaling factor
  77413. * @param result defines the target matrix
  77414. */
  77415. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77416. /**
  77417. * Gets an identity matrix that must not be updated
  77418. */
  77419. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77420. /**
  77421. * Stores a list of values (16) inside a given matrix
  77422. * @param initialM11 defines 1st value of 1st row
  77423. * @param initialM12 defines 2nd value of 1st row
  77424. * @param initialM13 defines 3rd value of 1st row
  77425. * @param initialM14 defines 4th value of 1st row
  77426. * @param initialM21 defines 1st value of 2nd row
  77427. * @param initialM22 defines 2nd value of 2nd row
  77428. * @param initialM23 defines 3rd value of 2nd row
  77429. * @param initialM24 defines 4th value of 2nd row
  77430. * @param initialM31 defines 1st value of 3rd row
  77431. * @param initialM32 defines 2nd value of 3rd row
  77432. * @param initialM33 defines 3rd value of 3rd row
  77433. * @param initialM34 defines 4th value of 3rd row
  77434. * @param initialM41 defines 1st value of 4th row
  77435. * @param initialM42 defines 2nd value of 4th row
  77436. * @param initialM43 defines 3rd value of 4th row
  77437. * @param initialM44 defines 4th value of 4th row
  77438. * @param result defines the target matrix
  77439. */
  77440. 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;
  77441. /**
  77442. * Creates new matrix from a list of values (16)
  77443. * @param initialM11 defines 1st value of 1st row
  77444. * @param initialM12 defines 2nd value of 1st row
  77445. * @param initialM13 defines 3rd value of 1st row
  77446. * @param initialM14 defines 4th value of 1st row
  77447. * @param initialM21 defines 1st value of 2nd row
  77448. * @param initialM22 defines 2nd value of 2nd row
  77449. * @param initialM23 defines 3rd value of 2nd row
  77450. * @param initialM24 defines 4th value of 2nd row
  77451. * @param initialM31 defines 1st value of 3rd row
  77452. * @param initialM32 defines 2nd value of 3rd row
  77453. * @param initialM33 defines 3rd value of 3rd row
  77454. * @param initialM34 defines 4th value of 3rd row
  77455. * @param initialM41 defines 1st value of 4th row
  77456. * @param initialM42 defines 2nd value of 4th row
  77457. * @param initialM43 defines 3rd value of 4th row
  77458. * @param initialM44 defines 4th value of 4th row
  77459. * @returns the new matrix
  77460. */
  77461. 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;
  77462. /**
  77463. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77464. * @param scale defines the scale vector3
  77465. * @param rotation defines the rotation quaternion
  77466. * @param translation defines the translation vector3
  77467. * @returns a new matrix
  77468. */
  77469. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77470. /**
  77471. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77472. * @param scale defines the scale vector3
  77473. * @param rotation defines the rotation quaternion
  77474. * @param translation defines the translation vector3
  77475. * @param result defines the target matrix
  77476. */
  77477. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77478. /**
  77479. * Creates a new identity matrix
  77480. * @returns a new identity matrix
  77481. */
  77482. static Identity(): Matrix;
  77483. /**
  77484. * Creates a new identity matrix and stores the result in a given matrix
  77485. * @param result defines the target matrix
  77486. */
  77487. static IdentityToRef(result: Matrix): void;
  77488. /**
  77489. * Creates a new zero matrix
  77490. * @returns a new zero matrix
  77491. */
  77492. static Zero(): Matrix;
  77493. /**
  77494. * Creates a new rotation matrix for "angle" radians around the X axis
  77495. * @param angle defines the angle (in radians) to use
  77496. * @return the new matrix
  77497. */
  77498. static RotationX(angle: number): Matrix;
  77499. /**
  77500. * Creates a new matrix as the invert of a given matrix
  77501. * @param source defines the source matrix
  77502. * @returns the new matrix
  77503. */
  77504. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77505. /**
  77506. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77507. * @param angle defines the angle (in radians) to use
  77508. * @param result defines the target matrix
  77509. */
  77510. static RotationXToRef(angle: number, result: Matrix): void;
  77511. /**
  77512. * Creates a new rotation matrix for "angle" radians around the Y axis
  77513. * @param angle defines the angle (in radians) to use
  77514. * @return the new matrix
  77515. */
  77516. static RotationY(angle: number): Matrix;
  77517. /**
  77518. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77519. * @param angle defines the angle (in radians) to use
  77520. * @param result defines the target matrix
  77521. */
  77522. static RotationYToRef(angle: number, result: Matrix): void;
  77523. /**
  77524. * Creates a new rotation matrix for "angle" radians around the Z axis
  77525. * @param angle defines the angle (in radians) to use
  77526. * @return the new matrix
  77527. */
  77528. static RotationZ(angle: number): Matrix;
  77529. /**
  77530. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77531. * @param angle defines the angle (in radians) to use
  77532. * @param result defines the target matrix
  77533. */
  77534. static RotationZToRef(angle: number, result: Matrix): void;
  77535. /**
  77536. * Creates a new rotation matrix for "angle" radians around the given axis
  77537. * @param axis defines the axis to use
  77538. * @param angle defines the angle (in radians) to use
  77539. * @return the new matrix
  77540. */
  77541. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77542. /**
  77543. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77544. * @param axis defines the axis to use
  77545. * @param angle defines the angle (in radians) to use
  77546. * @param result defines the target matrix
  77547. */
  77548. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77549. /**
  77550. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77551. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77552. * @param from defines the vector to align
  77553. * @param to defines the vector to align to
  77554. * @param result defines the target matrix
  77555. */
  77556. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77557. /**
  77558. * Creates a rotation matrix
  77559. * @param yaw defines the yaw angle in radians (Y axis)
  77560. * @param pitch defines the pitch angle in radians (X axis)
  77561. * @param roll defines the roll angle in radians (X axis)
  77562. * @returns the new rotation matrix
  77563. */
  77564. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77565. /**
  77566. * Creates a rotation matrix and stores it in a given matrix
  77567. * @param yaw defines the yaw angle in radians (Y axis)
  77568. * @param pitch defines the pitch angle in radians (X axis)
  77569. * @param roll defines the roll angle in radians (X axis)
  77570. * @param result defines the target matrix
  77571. */
  77572. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77573. /**
  77574. * Creates a scaling matrix
  77575. * @param x defines the scale factor on X axis
  77576. * @param y defines the scale factor on Y axis
  77577. * @param z defines the scale factor on Z axis
  77578. * @returns the new matrix
  77579. */
  77580. static Scaling(x: number, y: number, z: number): Matrix;
  77581. /**
  77582. * Creates a scaling matrix and stores it in a given matrix
  77583. * @param x defines the scale factor on X axis
  77584. * @param y defines the scale factor on Y axis
  77585. * @param z defines the scale factor on Z axis
  77586. * @param result defines the target matrix
  77587. */
  77588. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77589. /**
  77590. * Creates a translation matrix
  77591. * @param x defines the translation on X axis
  77592. * @param y defines the translation on Y axis
  77593. * @param z defines the translationon Z axis
  77594. * @returns the new matrix
  77595. */
  77596. static Translation(x: number, y: number, z: number): Matrix;
  77597. /**
  77598. * Creates a translation matrix and stores it in a given matrix
  77599. * @param x defines the translation on X axis
  77600. * @param y defines the translation on Y axis
  77601. * @param z defines the translationon Z axis
  77602. * @param result defines the target matrix
  77603. */
  77604. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77605. /**
  77606. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77607. * @param startValue defines the start value
  77608. * @param endValue defines the end value
  77609. * @param gradient defines the gradient factor
  77610. * @returns the new matrix
  77611. */
  77612. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77613. /**
  77614. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77615. * @param startValue defines the start value
  77616. * @param endValue defines the end value
  77617. * @param gradient defines the gradient factor
  77618. * @param result defines the Matrix object where to store data
  77619. */
  77620. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77621. /**
  77622. * Builds a new matrix whose values 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. * @returns the new matrix
  77630. */
  77631. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77632. /**
  77633. * Update a matrix to values which are computed by:
  77634. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77635. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77636. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77637. * @param startValue defines the first matrix
  77638. * @param endValue defines the second matrix
  77639. * @param gradient defines the gradient between the two matrices
  77640. * @param result defines the target matrix
  77641. */
  77642. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77643. /**
  77644. * 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"
  77645. * This function works in left handed mode
  77646. * @param eye defines the final position of the entity
  77647. * @param target defines where the entity should look at
  77648. * @param up defines the up vector for the entity
  77649. * @returns the new matrix
  77650. */
  77651. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77652. /**
  77653. * 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".
  77654. * This function works in left handed mode
  77655. * @param eye defines the final position of the entity
  77656. * @param target defines where the entity should look at
  77657. * @param up defines the up vector for the entity
  77658. * @param result defines the target matrix
  77659. */
  77660. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77661. /**
  77662. * 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"
  77663. * This function works in right handed mode
  77664. * @param eye defines the final position of the entity
  77665. * @param target defines where the entity should look at
  77666. * @param up defines the up vector for the entity
  77667. * @returns the new matrix
  77668. */
  77669. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77670. /**
  77671. * 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".
  77672. * This function works in right handed mode
  77673. * @param eye defines the final position of the entity
  77674. * @param target defines where the entity should look at
  77675. * @param up defines the up vector for the entity
  77676. * @param result defines the target matrix
  77677. */
  77678. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77679. /**
  77680. * Create a left-handed orthographic projection matrix
  77681. * @param width defines the viewport width
  77682. * @param height defines the viewport height
  77683. * @param znear defines the near clip plane
  77684. * @param zfar defines the far clip plane
  77685. * @returns a new matrix as a left-handed orthographic projection matrix
  77686. */
  77687. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77688. /**
  77689. * Store a left-handed orthographic projection to a given matrix
  77690. * @param width defines the viewport width
  77691. * @param height defines the viewport height
  77692. * @param znear defines the near clip plane
  77693. * @param zfar defines the far clip plane
  77694. * @param result defines the target matrix
  77695. */
  77696. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77697. /**
  77698. * Create a left-handed orthographic projection 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. * @returns a new matrix as a left-handed orthographic projection matrix
  77706. */
  77707. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77708. /**
  77709. * Stores a left-handed orthographic projection into a given 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. * @param result defines the target matrix
  77717. */
  77718. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77719. /**
  77720. * Creates a right-handed orthographic projection 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. * @returns a new matrix as a right-handed orthographic projection matrix
  77728. */
  77729. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77730. /**
  77731. * Stores a right-handed orthographic projection into a given matrix
  77732. * @param left defines the viewport left coordinate
  77733. * @param right defines the viewport right coordinate
  77734. * @param bottom defines the viewport bottom coordinate
  77735. * @param top defines the viewport top coordinate
  77736. * @param znear defines the near clip plane
  77737. * @param zfar defines the far clip plane
  77738. * @param result defines the target matrix
  77739. */
  77740. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77741. /**
  77742. * Creates a left-handed perspective projection matrix
  77743. * @param width defines the viewport width
  77744. * @param height defines the viewport height
  77745. * @param znear defines the near clip plane
  77746. * @param zfar defines the far clip plane
  77747. * @returns a new matrix as a left-handed perspective projection matrix
  77748. */
  77749. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77750. /**
  77751. * Creates a left-handed perspective projection matrix
  77752. * @param fov defines the horizontal field of view
  77753. * @param aspect defines the aspect ratio
  77754. * @param znear defines the near clip plane
  77755. * @param zfar defines the far clip plane
  77756. * @returns a new matrix as a left-handed perspective projection matrix
  77757. */
  77758. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77759. /**
  77760. * Stores a left-handed perspective projection into a given matrix
  77761. * @param fov defines the horizontal field of view
  77762. * @param aspect defines the aspect ratio
  77763. * @param znear defines the near clip plane
  77764. * @param zfar defines the far clip plane
  77765. * @param result defines the target matrix
  77766. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77767. */
  77768. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77769. /**
  77770. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77771. * @param fov defines the horizontal field of view
  77772. * @param aspect defines the aspect ratio
  77773. * @param znear defines the near clip plane
  77774. * @param zfar not used as infinity is used as far clip
  77775. * @param result defines the target matrix
  77776. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77777. */
  77778. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77779. /**
  77780. * Creates a right-handed perspective projection matrix
  77781. * @param fov defines the horizontal field of view
  77782. * @param aspect defines the aspect ratio
  77783. * @param znear defines the near clip plane
  77784. * @param zfar defines the far clip plane
  77785. * @returns a new matrix as a right-handed perspective projection matrix
  77786. */
  77787. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77788. /**
  77789. * Stores a right-handed perspective projection into a given matrix
  77790. * @param fov defines the horizontal field of view
  77791. * @param aspect defines the aspect ratio
  77792. * @param znear defines the near clip plane
  77793. * @param zfar defines the far clip plane
  77794. * @param result defines the target matrix
  77795. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77796. */
  77797. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77798. /**
  77799. * Stores a right-handed perspective projection into a given matrix
  77800. * @param fov defines the horizontal field of view
  77801. * @param aspect defines the aspect ratio
  77802. * @param znear defines the near clip plane
  77803. * @param zfar not used as infinity is used as far clip
  77804. * @param result defines the target matrix
  77805. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77806. */
  77807. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77808. /**
  77809. * Stores a perspective projection for WebVR info a given matrix
  77810. * @param fov defines the field of view
  77811. * @param znear defines the near clip plane
  77812. * @param zfar defines the far clip plane
  77813. * @param result defines the target matrix
  77814. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77815. */
  77816. static PerspectiveFovWebVRToRef(fov: {
  77817. upDegrees: number;
  77818. downDegrees: number;
  77819. leftDegrees: number;
  77820. rightDegrees: number;
  77821. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77822. /**
  77823. * Computes a complete transformation matrix
  77824. * @param viewport defines the viewport to use
  77825. * @param world defines the world matrix
  77826. * @param view defines the view matrix
  77827. * @param projection defines the projection matrix
  77828. * @param zmin defines the near clip plane
  77829. * @param zmax defines the far clip plane
  77830. * @returns the transformation matrix
  77831. */
  77832. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77833. /**
  77834. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77835. * @param matrix defines the matrix to use
  77836. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77837. */
  77838. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77839. /**
  77840. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77841. * @param matrix defines the matrix to use
  77842. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77843. */
  77844. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77845. /**
  77846. * Compute the transpose of a given matrix
  77847. * @param matrix defines the matrix to transpose
  77848. * @returns the new matrix
  77849. */
  77850. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77851. /**
  77852. * Compute the transpose of a matrix and store it in a target matrix
  77853. * @param matrix defines the matrix to transpose
  77854. * @param result defines the target matrix
  77855. */
  77856. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77857. /**
  77858. * Computes a reflection matrix from a plane
  77859. * @param plane defines the reflection plane
  77860. * @returns a new matrix
  77861. */
  77862. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77863. /**
  77864. * Computes a reflection matrix from a plane
  77865. * @param plane defines the reflection plane
  77866. * @param result defines the target matrix
  77867. */
  77868. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77869. /**
  77870. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77871. * @param xaxis defines the value of the 1st axis
  77872. * @param yaxis defines the value of the 2nd axis
  77873. * @param zaxis defines the value of the 3rd axis
  77874. * @param result defines the target matrix
  77875. */
  77876. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77877. /**
  77878. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77879. * @param quat defines the quaternion to use
  77880. * @param result defines the target matrix
  77881. */
  77882. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77883. }
  77884. /**
  77885. * @hidden
  77886. */
  77887. export class TmpVectors {
  77888. static Vector2: Vector2[];
  77889. static Vector3: Vector3[];
  77890. static Vector4: Vector4[];
  77891. static Quaternion: Quaternion[];
  77892. static Matrix: Matrix[];
  77893. }
  77894. }
  77895. declare module BABYLON {
  77896. /**
  77897. * Defines potential orientation for back face culling
  77898. */
  77899. export enum Orientation {
  77900. /**
  77901. * Clockwise
  77902. */
  77903. CW = 0,
  77904. /** Counter clockwise */
  77905. CCW = 1
  77906. }
  77907. /** Class used to represent a Bezier curve */
  77908. export class BezierCurve {
  77909. /**
  77910. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77911. * @param t defines the time
  77912. * @param x1 defines the left coordinate on X axis
  77913. * @param y1 defines the left coordinate on Y axis
  77914. * @param x2 defines the right coordinate on X axis
  77915. * @param y2 defines the right coordinate on Y axis
  77916. * @returns the interpolated value
  77917. */
  77918. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77919. }
  77920. /**
  77921. * Defines angle representation
  77922. */
  77923. export class Angle {
  77924. private _radians;
  77925. /**
  77926. * Creates an Angle object of "radians" radians (float).
  77927. * @param radians the angle in radians
  77928. */
  77929. constructor(radians: number);
  77930. /**
  77931. * Get value in degrees
  77932. * @returns the Angle value in degrees (float)
  77933. */
  77934. degrees(): number;
  77935. /**
  77936. * Get value in radians
  77937. * @returns the Angle value in radians (float)
  77938. */
  77939. radians(): number;
  77940. /**
  77941. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77942. * @param a defines first vector
  77943. * @param b defines second vector
  77944. * @returns a new Angle
  77945. */
  77946. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77947. /**
  77948. * Gets a new Angle object from the given float in radians
  77949. * @param radians defines the angle value in radians
  77950. * @returns a new Angle
  77951. */
  77952. static FromRadians(radians: number): Angle;
  77953. /**
  77954. * Gets a new Angle object from the given float in degrees
  77955. * @param degrees defines the angle value in degrees
  77956. * @returns a new Angle
  77957. */
  77958. static FromDegrees(degrees: number): Angle;
  77959. }
  77960. /**
  77961. * This represents an arc in a 2d space.
  77962. */
  77963. export class Arc2 {
  77964. /** Defines the start point of the arc */
  77965. startPoint: Vector2;
  77966. /** Defines the mid point of the arc */
  77967. midPoint: Vector2;
  77968. /** Defines the end point of the arc */
  77969. endPoint: Vector2;
  77970. /**
  77971. * Defines the center point of the arc.
  77972. */
  77973. centerPoint: Vector2;
  77974. /**
  77975. * Defines the radius of the arc.
  77976. */
  77977. radius: number;
  77978. /**
  77979. * Defines the angle of the arc (from mid point to end point).
  77980. */
  77981. angle: Angle;
  77982. /**
  77983. * Defines the start angle of the arc (from start point to middle point).
  77984. */
  77985. startAngle: Angle;
  77986. /**
  77987. * Defines the orientation of the arc (clock wise/counter clock wise).
  77988. */
  77989. orientation: Orientation;
  77990. /**
  77991. * Creates an Arc object from the three given points : start, middle and end.
  77992. * @param startPoint Defines the start point of the arc
  77993. * @param midPoint Defines the midlle point of the arc
  77994. * @param endPoint Defines the end point of the arc
  77995. */
  77996. constructor(
  77997. /** Defines the start point of the arc */
  77998. startPoint: Vector2,
  77999. /** Defines the mid point of the arc */
  78000. midPoint: Vector2,
  78001. /** Defines the end point of the arc */
  78002. endPoint: Vector2);
  78003. }
  78004. /**
  78005. * Represents a 2D path made up of multiple 2D points
  78006. */
  78007. export class Path2 {
  78008. private _points;
  78009. private _length;
  78010. /**
  78011. * If the path start and end point are the same
  78012. */
  78013. closed: boolean;
  78014. /**
  78015. * Creates a Path2 object from the starting 2D coordinates x and y.
  78016. * @param x the starting points x value
  78017. * @param y the starting points y value
  78018. */
  78019. constructor(x: number, y: number);
  78020. /**
  78021. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78022. * @param x the added points x value
  78023. * @param y the added points y value
  78024. * @returns the updated Path2.
  78025. */
  78026. addLineTo(x: number, y: number): Path2;
  78027. /**
  78028. * 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.
  78029. * @param midX middle point x value
  78030. * @param midY middle point y value
  78031. * @param endX end point x value
  78032. * @param endY end point y value
  78033. * @param numberOfSegments (default: 36)
  78034. * @returns the updated Path2.
  78035. */
  78036. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78037. /**
  78038. * Closes the Path2.
  78039. * @returns the Path2.
  78040. */
  78041. close(): Path2;
  78042. /**
  78043. * Gets the sum of the distance between each sequential point in the path
  78044. * @returns the Path2 total length (float).
  78045. */
  78046. length(): number;
  78047. /**
  78048. * Gets the points which construct the path
  78049. * @returns the Path2 internal array of points.
  78050. */
  78051. getPoints(): Vector2[];
  78052. /**
  78053. * Retreives the point at the distance aways from the starting point
  78054. * @param normalizedLengthPosition the length along the path to retreive the point from
  78055. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78056. */
  78057. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78058. /**
  78059. * Creates a new path starting from an x and y position
  78060. * @param x starting x value
  78061. * @param y starting y value
  78062. * @returns a new Path2 starting at the coordinates (x, y).
  78063. */
  78064. static StartingAt(x: number, y: number): Path2;
  78065. }
  78066. /**
  78067. * Represents a 3D path made up of multiple 3D points
  78068. */
  78069. export class Path3D {
  78070. /**
  78071. * an array of Vector3, the curve axis of the Path3D
  78072. */
  78073. path: Vector3[];
  78074. private _curve;
  78075. private _distances;
  78076. private _tangents;
  78077. private _normals;
  78078. private _binormals;
  78079. private _raw;
  78080. private _alignTangentsWithPath;
  78081. private readonly _pointAtData;
  78082. /**
  78083. * new Path3D(path, normal, raw)
  78084. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78085. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78086. * @param path an array of Vector3, the curve axis of the Path3D
  78087. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78088. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78089. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78090. */
  78091. constructor(
  78092. /**
  78093. * an array of Vector3, the curve axis of the Path3D
  78094. */
  78095. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78096. /**
  78097. * Returns the Path3D array of successive Vector3 designing its curve.
  78098. * @returns the Path3D array of successive Vector3 designing its curve.
  78099. */
  78100. getCurve(): Vector3[];
  78101. /**
  78102. * Returns the Path3D array of successive Vector3 designing its curve.
  78103. * @returns the Path3D array of successive Vector3 designing its curve.
  78104. */
  78105. getPoints(): Vector3[];
  78106. /**
  78107. * @returns the computed length (float) of the path.
  78108. */
  78109. length(): number;
  78110. /**
  78111. * Returns an array populated with tangent vectors on each Path3D curve point.
  78112. * @returns an array populated with tangent vectors on each Path3D curve point.
  78113. */
  78114. getTangents(): Vector3[];
  78115. /**
  78116. * Returns an array populated with normal vectors on each Path3D curve point.
  78117. * @returns an array populated with normal vectors on each Path3D curve point.
  78118. */
  78119. getNormals(): Vector3[];
  78120. /**
  78121. * Returns an array populated with binormal vectors on each Path3D curve point.
  78122. * @returns an array populated with binormal vectors on each Path3D curve point.
  78123. */
  78124. getBinormals(): Vector3[];
  78125. /**
  78126. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78127. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78128. */
  78129. getDistances(): number[];
  78130. /**
  78131. * Returns an interpolated point along this path
  78132. * @param position the position of the point along this path, from 0.0 to 1.0
  78133. * @returns a new Vector3 as the point
  78134. */
  78135. getPointAt(position: number): Vector3;
  78136. /**
  78137. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78138. * @param position the position of the point along this path, from 0.0 to 1.0
  78139. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78140. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78141. */
  78142. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78143. /**
  78144. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78145. * @param position the position of the point along this path, from 0.0 to 1.0
  78146. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78147. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78148. */
  78149. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78150. /**
  78151. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78152. * @param position the position of the point along this path, from 0.0 to 1.0
  78153. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78154. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78155. */
  78156. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78157. /**
  78158. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78159. * @param position the position of the point along this path, from 0.0 to 1.0
  78160. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78161. */
  78162. getDistanceAt(position: number): number;
  78163. /**
  78164. * Returns the array index of the previous point of an interpolated point along this path
  78165. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78166. * @returns the array index
  78167. */
  78168. getPreviousPointIndexAt(position: number): number;
  78169. /**
  78170. * 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)
  78171. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78172. * @returns the sub position
  78173. */
  78174. getSubPositionAt(position: number): number;
  78175. /**
  78176. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78177. * @param target the vector of which to get the closest position to
  78178. * @returns the position of the closest virtual point on this path to the target vector
  78179. */
  78180. getClosestPositionTo(target: Vector3): number;
  78181. /**
  78182. * Returns a sub path (slice) of this path
  78183. * @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
  78184. * @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
  78185. * @returns a sub path (slice) of this path
  78186. */
  78187. slice(start?: number, end?: number): Path3D;
  78188. /**
  78189. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78190. * @param path path which all values are copied into the curves points
  78191. * @param firstNormal which should be projected onto the curve
  78192. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78193. * @returns the same object updated.
  78194. */
  78195. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78196. private _compute;
  78197. private _getFirstNonNullVector;
  78198. private _getLastNonNullVector;
  78199. private _normalVector;
  78200. /**
  78201. * Updates the point at data for an interpolated point along this curve
  78202. * @param position the position of the point along this curve, from 0.0 to 1.0
  78203. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78204. * @returns the (updated) point at data
  78205. */
  78206. private _updatePointAtData;
  78207. /**
  78208. * Updates the point at data from the specified parameters
  78209. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78210. * @param point the interpolated point
  78211. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78212. */
  78213. private _setPointAtData;
  78214. /**
  78215. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78216. */
  78217. private _updateInterpolationMatrix;
  78218. }
  78219. /**
  78220. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78221. * A Curve3 is designed from a series of successive Vector3.
  78222. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78223. */
  78224. export class Curve3 {
  78225. private _points;
  78226. private _length;
  78227. /**
  78228. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78229. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78230. * @param v1 (Vector3) the control point
  78231. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78232. * @param nbPoints (integer) the wanted number of points in the curve
  78233. * @returns the created Curve3
  78234. */
  78235. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78236. /**
  78237. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78238. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78239. * @param v1 (Vector3) the first control point
  78240. * @param v2 (Vector3) the second control point
  78241. * @param v3 (Vector3) the end point of the Cubic Bezier
  78242. * @param nbPoints (integer) the wanted number of points in the curve
  78243. * @returns the created Curve3
  78244. */
  78245. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78246. /**
  78247. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78248. * @param p1 (Vector3) the origin point of the Hermite Spline
  78249. * @param t1 (Vector3) the tangent vector at the origin point
  78250. * @param p2 (Vector3) the end point of the Hermite Spline
  78251. * @param t2 (Vector3) the tangent vector at the end point
  78252. * @param nbPoints (integer) the wanted number of points in the curve
  78253. * @returns the created Curve3
  78254. */
  78255. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78256. /**
  78257. * Returns a Curve3 object along a CatmullRom Spline curve :
  78258. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78259. * @param nbPoints (integer) the wanted number of points between each curve control points
  78260. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78261. * @returns the created Curve3
  78262. */
  78263. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78264. /**
  78265. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78266. * A Curve3 is designed from a series of successive Vector3.
  78267. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78268. * @param points points which make up the curve
  78269. */
  78270. constructor(points: Vector3[]);
  78271. /**
  78272. * @returns the Curve3 stored array of successive Vector3
  78273. */
  78274. getPoints(): Vector3[];
  78275. /**
  78276. * @returns the computed length (float) of the curve.
  78277. */
  78278. length(): number;
  78279. /**
  78280. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78281. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78282. * curveA and curveB keep unchanged.
  78283. * @param curve the curve to continue from this curve
  78284. * @returns the newly constructed curve
  78285. */
  78286. continue(curve: DeepImmutable<Curve3>): Curve3;
  78287. private _computeLength;
  78288. }
  78289. }
  78290. declare module BABYLON {
  78291. /**
  78292. * This represents the main contract an easing function should follow.
  78293. * Easing functions are used throughout the animation system.
  78294. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78295. */
  78296. export interface IEasingFunction {
  78297. /**
  78298. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78299. * of the easing function.
  78300. * The link below provides some of the most common examples of easing functions.
  78301. * @see https://easings.net/
  78302. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78303. * @returns the corresponding value on the curve defined by the easing function
  78304. */
  78305. ease(gradient: number): number;
  78306. }
  78307. /**
  78308. * Base class used for every default easing function.
  78309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78310. */
  78311. export class EasingFunction implements IEasingFunction {
  78312. /**
  78313. * Interpolation follows the mathematical formula associated with the easing function.
  78314. */
  78315. static readonly EASINGMODE_EASEIN: number;
  78316. /**
  78317. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78318. */
  78319. static readonly EASINGMODE_EASEOUT: number;
  78320. /**
  78321. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78322. */
  78323. static readonly EASINGMODE_EASEINOUT: number;
  78324. private _easingMode;
  78325. /**
  78326. * Sets the easing mode of the current function.
  78327. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78328. */
  78329. setEasingMode(easingMode: number): void;
  78330. /**
  78331. * Gets the current easing mode.
  78332. * @returns the easing mode
  78333. */
  78334. getEasingMode(): number;
  78335. /**
  78336. * @hidden
  78337. */
  78338. easeInCore(gradient: number): number;
  78339. /**
  78340. * Given an input gradient between 0 and 1, this returns the corresponding value
  78341. * of the easing function.
  78342. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78343. * @returns the corresponding value on the curve defined by the easing function
  78344. */
  78345. ease(gradient: number): number;
  78346. }
  78347. /**
  78348. * Easing function with a circle shape (see link below).
  78349. * @see https://easings.net/#easeInCirc
  78350. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78351. */
  78352. export class CircleEase extends EasingFunction implements IEasingFunction {
  78353. /** @hidden */
  78354. easeInCore(gradient: number): number;
  78355. }
  78356. /**
  78357. * Easing function with a ease back shape (see link below).
  78358. * @see https://easings.net/#easeInBack
  78359. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78360. */
  78361. export class BackEase extends EasingFunction implements IEasingFunction {
  78362. /** Defines the amplitude of the function */
  78363. amplitude: number;
  78364. /**
  78365. * Instantiates a back ease easing
  78366. * @see https://easings.net/#easeInBack
  78367. * @param amplitude Defines the amplitude of the function
  78368. */
  78369. constructor(
  78370. /** Defines the amplitude of the function */
  78371. amplitude?: number);
  78372. /** @hidden */
  78373. easeInCore(gradient: number): number;
  78374. }
  78375. /**
  78376. * Easing function with a bouncing shape (see link below).
  78377. * @see https://easings.net/#easeInBounce
  78378. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78379. */
  78380. export class BounceEase extends EasingFunction implements IEasingFunction {
  78381. /** Defines the number of bounces */
  78382. bounces: number;
  78383. /** Defines the amplitude of the bounce */
  78384. bounciness: number;
  78385. /**
  78386. * Instantiates a bounce easing
  78387. * @see https://easings.net/#easeInBounce
  78388. * @param bounces Defines the number of bounces
  78389. * @param bounciness Defines the amplitude of the bounce
  78390. */
  78391. constructor(
  78392. /** Defines the number of bounces */
  78393. bounces?: number,
  78394. /** Defines the amplitude of the bounce */
  78395. bounciness?: number);
  78396. /** @hidden */
  78397. easeInCore(gradient: number): number;
  78398. }
  78399. /**
  78400. * Easing function with a power of 3 shape (see link below).
  78401. * @see https://easings.net/#easeInCubic
  78402. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78403. */
  78404. export class CubicEase extends EasingFunction implements IEasingFunction {
  78405. /** @hidden */
  78406. easeInCore(gradient: number): number;
  78407. }
  78408. /**
  78409. * Easing function with an elastic shape (see link below).
  78410. * @see https://easings.net/#easeInElastic
  78411. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78412. */
  78413. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78414. /** Defines the number of oscillations*/
  78415. oscillations: number;
  78416. /** Defines the amplitude of the oscillations*/
  78417. springiness: number;
  78418. /**
  78419. * Instantiates an elastic easing function
  78420. * @see https://easings.net/#easeInElastic
  78421. * @param oscillations Defines the number of oscillations
  78422. * @param springiness Defines the amplitude of the oscillations
  78423. */
  78424. constructor(
  78425. /** Defines the number of oscillations*/
  78426. oscillations?: number,
  78427. /** Defines the amplitude of the oscillations*/
  78428. springiness?: number);
  78429. /** @hidden */
  78430. easeInCore(gradient: number): number;
  78431. }
  78432. /**
  78433. * Easing function with an exponential shape (see link below).
  78434. * @see https://easings.net/#easeInExpo
  78435. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78436. */
  78437. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78438. /** Defines the exponent of the function */
  78439. exponent: number;
  78440. /**
  78441. * Instantiates an exponential easing function
  78442. * @see https://easings.net/#easeInExpo
  78443. * @param exponent Defines the exponent of the function
  78444. */
  78445. constructor(
  78446. /** Defines the exponent of the function */
  78447. exponent?: number);
  78448. /** @hidden */
  78449. easeInCore(gradient: number): number;
  78450. }
  78451. /**
  78452. * Easing function with a power shape (see link below).
  78453. * @see https://easings.net/#easeInQuad
  78454. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78455. */
  78456. export class PowerEase extends EasingFunction implements IEasingFunction {
  78457. /** Defines the power of the function */
  78458. power: number;
  78459. /**
  78460. * Instantiates an power base easing function
  78461. * @see https://easings.net/#easeInQuad
  78462. * @param power Defines the power of the function
  78463. */
  78464. constructor(
  78465. /** Defines the power of the function */
  78466. power?: number);
  78467. /** @hidden */
  78468. easeInCore(gradient: number): number;
  78469. }
  78470. /**
  78471. * Easing function with a power of 2 shape (see link below).
  78472. * @see https://easings.net/#easeInQuad
  78473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78474. */
  78475. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78476. /** @hidden */
  78477. easeInCore(gradient: number): number;
  78478. }
  78479. /**
  78480. * Easing function with a power of 4 shape (see link below).
  78481. * @see https://easings.net/#easeInQuart
  78482. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78483. */
  78484. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78485. /** @hidden */
  78486. easeInCore(gradient: number): number;
  78487. }
  78488. /**
  78489. * Easing function with a power of 5 shape (see link below).
  78490. * @see https://easings.net/#easeInQuint
  78491. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78492. */
  78493. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78494. /** @hidden */
  78495. easeInCore(gradient: number): number;
  78496. }
  78497. /**
  78498. * Easing function with a sin shape (see link below).
  78499. * @see https://easings.net/#easeInSine
  78500. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78501. */
  78502. export class SineEase extends EasingFunction implements IEasingFunction {
  78503. /** @hidden */
  78504. easeInCore(gradient: number): number;
  78505. }
  78506. /**
  78507. * Easing function with a bezier shape (see link below).
  78508. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78509. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78510. */
  78511. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78512. /** Defines the x component of the start tangent in the bezier curve */
  78513. x1: number;
  78514. /** Defines the y component of the start tangent in the bezier curve */
  78515. y1: number;
  78516. /** Defines the x component of the end tangent in the bezier curve */
  78517. x2: number;
  78518. /** Defines the y component of the end tangent in the bezier curve */
  78519. y2: number;
  78520. /**
  78521. * Instantiates a bezier function
  78522. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78523. * @param x1 Defines the x component of the start tangent in the bezier curve
  78524. * @param y1 Defines the y component of the start tangent in the bezier curve
  78525. * @param x2 Defines the x component of the end tangent in the bezier curve
  78526. * @param y2 Defines the y component of the end tangent in the bezier curve
  78527. */
  78528. constructor(
  78529. /** Defines the x component of the start tangent in the bezier curve */
  78530. x1?: number,
  78531. /** Defines the y component of the start tangent in the bezier curve */
  78532. y1?: number,
  78533. /** Defines the x component of the end tangent in the bezier curve */
  78534. x2?: number,
  78535. /** Defines the y component of the end tangent in the bezier curve */
  78536. y2?: number);
  78537. /** @hidden */
  78538. easeInCore(gradient: number): number;
  78539. }
  78540. }
  78541. declare module BABYLON {
  78542. /**
  78543. * Class used to hold a RBG color
  78544. */
  78545. export class Color3 {
  78546. /**
  78547. * Defines the red component (between 0 and 1, default is 0)
  78548. */
  78549. r: number;
  78550. /**
  78551. * Defines the green component (between 0 and 1, default is 0)
  78552. */
  78553. g: number;
  78554. /**
  78555. * Defines the blue component (between 0 and 1, default is 0)
  78556. */
  78557. b: number;
  78558. /**
  78559. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78560. * @param r defines the red component (between 0 and 1, default is 0)
  78561. * @param g defines the green component (between 0 and 1, default is 0)
  78562. * @param b defines the blue component (between 0 and 1, default is 0)
  78563. */
  78564. constructor(
  78565. /**
  78566. * Defines the red component (between 0 and 1, default is 0)
  78567. */
  78568. r?: number,
  78569. /**
  78570. * Defines the green component (between 0 and 1, default is 0)
  78571. */
  78572. g?: number,
  78573. /**
  78574. * Defines the blue component (between 0 and 1, default is 0)
  78575. */
  78576. b?: number);
  78577. /**
  78578. * Creates a string with the Color3 current values
  78579. * @returns the string representation of the Color3 object
  78580. */
  78581. toString(): string;
  78582. /**
  78583. * Returns the string "Color3"
  78584. * @returns "Color3"
  78585. */
  78586. getClassName(): string;
  78587. /**
  78588. * Compute the Color3 hash code
  78589. * @returns an unique number that can be used to hash Color3 objects
  78590. */
  78591. getHashCode(): number;
  78592. /**
  78593. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78594. * @param array defines the array where to store the r,g,b components
  78595. * @param index defines an optional index in the target array to define where to start storing values
  78596. * @returns the current Color3 object
  78597. */
  78598. toArray(array: FloatArray, index?: number): Color3;
  78599. /**
  78600. * Returns a new Color4 object from the current Color3 and the given alpha
  78601. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78602. * @returns a new Color4 object
  78603. */
  78604. toColor4(alpha?: number): Color4;
  78605. /**
  78606. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78607. * @returns the new array
  78608. */
  78609. asArray(): number[];
  78610. /**
  78611. * Returns the luminance value
  78612. * @returns a float value
  78613. */
  78614. toLuminance(): number;
  78615. /**
  78616. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78617. * @param otherColor defines the second operand
  78618. * @returns the new Color3 object
  78619. */
  78620. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78621. /**
  78622. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78623. * @param otherColor defines the second operand
  78624. * @param result defines the Color3 object where to store the result
  78625. * @returns the current Color3
  78626. */
  78627. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78628. /**
  78629. * Determines equality between Color3 objects
  78630. * @param otherColor defines the second operand
  78631. * @returns true if the rgb values are equal to the given ones
  78632. */
  78633. equals(otherColor: DeepImmutable<Color3>): boolean;
  78634. /**
  78635. * Determines equality between the current Color3 object and a set of r,b,g values
  78636. * @param r defines the red component to check
  78637. * @param g defines the green component to check
  78638. * @param b defines the blue component to check
  78639. * @returns true if the rgb values are equal to the given ones
  78640. */
  78641. equalsFloats(r: number, g: number, b: number): boolean;
  78642. /**
  78643. * Multiplies in place each rgb value by scale
  78644. * @param scale defines the scaling factor
  78645. * @returns the updated Color3
  78646. */
  78647. scale(scale: number): Color3;
  78648. /**
  78649. * Multiplies the rgb values by scale and stores the result into "result"
  78650. * @param scale defines the scaling factor
  78651. * @param result defines the Color3 object where to store the result
  78652. * @returns the unmodified current Color3
  78653. */
  78654. scaleToRef(scale: number, result: Color3): Color3;
  78655. /**
  78656. * Scale the current Color3 values by a factor and add the result to a given Color3
  78657. * @param scale defines the scale factor
  78658. * @param result defines color to store the result into
  78659. * @returns the unmodified current Color3
  78660. */
  78661. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78662. /**
  78663. * Clamps the rgb values by the min and max values and stores the result into "result"
  78664. * @param min defines minimum clamping value (default is 0)
  78665. * @param max defines maximum clamping value (default is 1)
  78666. * @param result defines color to store the result into
  78667. * @returns the original Color3
  78668. */
  78669. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78670. /**
  78671. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78672. * @param otherColor defines the second operand
  78673. * @returns the new Color3
  78674. */
  78675. add(otherColor: DeepImmutable<Color3>): Color3;
  78676. /**
  78677. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78678. * @param otherColor defines the second operand
  78679. * @param result defines Color3 object to store the result into
  78680. * @returns the unmodified current Color3
  78681. */
  78682. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78683. /**
  78684. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78685. * @param otherColor defines the second operand
  78686. * @returns the new Color3
  78687. */
  78688. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78689. /**
  78690. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78691. * @param otherColor defines the second operand
  78692. * @param result defines Color3 object to store the result into
  78693. * @returns the unmodified current Color3
  78694. */
  78695. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78696. /**
  78697. * Copy the current object
  78698. * @returns a new Color3 copied the current one
  78699. */
  78700. clone(): Color3;
  78701. /**
  78702. * Copies the rgb values from the source in the current Color3
  78703. * @param source defines the source Color3 object
  78704. * @returns the updated Color3 object
  78705. */
  78706. copyFrom(source: DeepImmutable<Color3>): Color3;
  78707. /**
  78708. * Updates the Color3 rgb values from the given floats
  78709. * @param r defines the red component to read from
  78710. * @param g defines the green component to read from
  78711. * @param b defines the blue component to read from
  78712. * @returns the current Color3 object
  78713. */
  78714. copyFromFloats(r: number, g: number, b: number): Color3;
  78715. /**
  78716. * Updates the Color3 rgb values from the given floats
  78717. * @param r defines the red component to read from
  78718. * @param g defines the green component to read from
  78719. * @param b defines the blue component to read from
  78720. * @returns the current Color3 object
  78721. */
  78722. set(r: number, g: number, b: number): Color3;
  78723. /**
  78724. * Compute the Color3 hexadecimal code as a string
  78725. * @returns a string containing the hexadecimal representation of the Color3 object
  78726. */
  78727. toHexString(): string;
  78728. /**
  78729. * Computes a new Color3 converted from the current one to linear space
  78730. * @returns a new Color3 object
  78731. */
  78732. toLinearSpace(): Color3;
  78733. /**
  78734. * Converts current color in rgb space to HSV values
  78735. * @returns a new color3 representing the HSV values
  78736. */
  78737. toHSV(): Color3;
  78738. /**
  78739. * Converts current color in rgb space to HSV values
  78740. * @param result defines the Color3 where to store the HSV values
  78741. */
  78742. toHSVToRef(result: Color3): void;
  78743. /**
  78744. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78745. * @param convertedColor defines the Color3 object where to store the linear space version
  78746. * @returns the unmodified Color3
  78747. */
  78748. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78749. /**
  78750. * Computes a new Color3 converted from the current one to gamma space
  78751. * @returns a new Color3 object
  78752. */
  78753. toGammaSpace(): Color3;
  78754. /**
  78755. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78756. * @param convertedColor defines the Color3 object where to store the gamma space version
  78757. * @returns the unmodified Color3
  78758. */
  78759. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78760. private static _BlackReadOnly;
  78761. /**
  78762. * Convert Hue, saturation and value to a Color3 (RGB)
  78763. * @param hue defines the hue
  78764. * @param saturation defines the saturation
  78765. * @param value defines the value
  78766. * @param result defines the Color3 where to store the RGB values
  78767. */
  78768. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78769. /**
  78770. * Creates a new Color3 from the string containing valid hexadecimal values
  78771. * @param hex defines a string containing valid hexadecimal values
  78772. * @returns a new Color3 object
  78773. */
  78774. static FromHexString(hex: string): Color3;
  78775. /**
  78776. * Creates a new Color3 from the starting index of the given array
  78777. * @param array defines the source array
  78778. * @param offset defines an offset in the source array
  78779. * @returns a new Color3 object
  78780. */
  78781. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78782. /**
  78783. * Creates a new Color3 from integer values (< 256)
  78784. * @param r defines the red component to read from (value between 0 and 255)
  78785. * @param g defines the green component to read from (value between 0 and 255)
  78786. * @param b defines the blue component to read from (value between 0 and 255)
  78787. * @returns a new Color3 object
  78788. */
  78789. static FromInts(r: number, g: number, b: number): Color3;
  78790. /**
  78791. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78792. * @param start defines the start Color3 value
  78793. * @param end defines the end Color3 value
  78794. * @param amount defines the gradient value between start and end
  78795. * @returns a new Color3 object
  78796. */
  78797. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78798. /**
  78799. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78800. * @param left defines the start value
  78801. * @param right defines the end value
  78802. * @param amount defines the gradient factor
  78803. * @param result defines the Color3 object where to store the result
  78804. */
  78805. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78806. /**
  78807. * Returns a Color3 value containing a red color
  78808. * @returns a new Color3 object
  78809. */
  78810. static Red(): Color3;
  78811. /**
  78812. * Returns a Color3 value containing a green color
  78813. * @returns a new Color3 object
  78814. */
  78815. static Green(): Color3;
  78816. /**
  78817. * Returns a Color3 value containing a blue color
  78818. * @returns a new Color3 object
  78819. */
  78820. static Blue(): Color3;
  78821. /**
  78822. * Returns a Color3 value containing a black color
  78823. * @returns a new Color3 object
  78824. */
  78825. static Black(): Color3;
  78826. /**
  78827. * Gets a Color3 value containing a black color that must not be updated
  78828. */
  78829. static get BlackReadOnly(): DeepImmutable<Color3>;
  78830. /**
  78831. * Returns a Color3 value containing a white color
  78832. * @returns a new Color3 object
  78833. */
  78834. static White(): Color3;
  78835. /**
  78836. * Returns a Color3 value containing a purple color
  78837. * @returns a new Color3 object
  78838. */
  78839. static Purple(): Color3;
  78840. /**
  78841. * Returns a Color3 value containing a magenta color
  78842. * @returns a new Color3 object
  78843. */
  78844. static Magenta(): Color3;
  78845. /**
  78846. * Returns a Color3 value containing a yellow color
  78847. * @returns a new Color3 object
  78848. */
  78849. static Yellow(): Color3;
  78850. /**
  78851. * Returns a Color3 value containing a gray color
  78852. * @returns a new Color3 object
  78853. */
  78854. static Gray(): Color3;
  78855. /**
  78856. * Returns a Color3 value containing a teal color
  78857. * @returns a new Color3 object
  78858. */
  78859. static Teal(): Color3;
  78860. /**
  78861. * Returns a Color3 value containing a random color
  78862. * @returns a new Color3 object
  78863. */
  78864. static Random(): Color3;
  78865. }
  78866. /**
  78867. * Class used to hold a RBGA color
  78868. */
  78869. export class Color4 {
  78870. /**
  78871. * Defines the red component (between 0 and 1, default is 0)
  78872. */
  78873. r: number;
  78874. /**
  78875. * Defines the green component (between 0 and 1, default is 0)
  78876. */
  78877. g: number;
  78878. /**
  78879. * Defines the blue component (between 0 and 1, default is 0)
  78880. */
  78881. b: number;
  78882. /**
  78883. * Defines the alpha component (between 0 and 1, default is 1)
  78884. */
  78885. a: number;
  78886. /**
  78887. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78888. * @param r defines the red component (between 0 and 1, default is 0)
  78889. * @param g defines the green component (between 0 and 1, default is 0)
  78890. * @param b defines the blue component (between 0 and 1, default is 0)
  78891. * @param a defines the alpha component (between 0 and 1, default is 1)
  78892. */
  78893. constructor(
  78894. /**
  78895. * Defines the red component (between 0 and 1, default is 0)
  78896. */
  78897. r?: number,
  78898. /**
  78899. * Defines the green component (between 0 and 1, default is 0)
  78900. */
  78901. g?: number,
  78902. /**
  78903. * Defines the blue component (between 0 and 1, default is 0)
  78904. */
  78905. b?: number,
  78906. /**
  78907. * Defines the alpha component (between 0 and 1, default is 1)
  78908. */
  78909. a?: number);
  78910. /**
  78911. * Adds in place the given Color4 values to the current Color4 object
  78912. * @param right defines the second operand
  78913. * @returns the current updated Color4 object
  78914. */
  78915. addInPlace(right: DeepImmutable<Color4>): Color4;
  78916. /**
  78917. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78918. * @returns the new array
  78919. */
  78920. asArray(): number[];
  78921. /**
  78922. * Stores from the starting index in the given array the Color4 successive values
  78923. * @param array defines the array where to store the r,g,b components
  78924. * @param index defines an optional index in the target array to define where to start storing values
  78925. * @returns the current Color4 object
  78926. */
  78927. toArray(array: number[], index?: number): Color4;
  78928. /**
  78929. * Determines equality between Color4 objects
  78930. * @param otherColor defines the second operand
  78931. * @returns true if the rgba values are equal to the given ones
  78932. */
  78933. equals(otherColor: DeepImmutable<Color4>): boolean;
  78934. /**
  78935. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78936. * @param right defines the second operand
  78937. * @returns a new Color4 object
  78938. */
  78939. add(right: DeepImmutable<Color4>): Color4;
  78940. /**
  78941. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78942. * @param right defines the second operand
  78943. * @returns a new Color4 object
  78944. */
  78945. subtract(right: DeepImmutable<Color4>): Color4;
  78946. /**
  78947. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78948. * @param right defines the second operand
  78949. * @param result defines the Color4 object where to store the result
  78950. * @returns the current Color4 object
  78951. */
  78952. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78953. /**
  78954. * Creates a new Color4 with the current Color4 values multiplied by scale
  78955. * @param scale defines the scaling factor to apply
  78956. * @returns a new Color4 object
  78957. */
  78958. scale(scale: number): Color4;
  78959. /**
  78960. * Multiplies the current Color4 values by scale and stores the result in "result"
  78961. * @param scale defines the scaling factor to apply
  78962. * @param result defines the Color4 object where to store the result
  78963. * @returns the current unmodified Color4
  78964. */
  78965. scaleToRef(scale: number, result: Color4): Color4;
  78966. /**
  78967. * Scale the current Color4 values by a factor and add the result to a given Color4
  78968. * @param scale defines the scale factor
  78969. * @param result defines the Color4 object where to store the result
  78970. * @returns the unmodified current Color4
  78971. */
  78972. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78973. /**
  78974. * Clamps the rgb values by the min and max values and stores the result into "result"
  78975. * @param min defines minimum clamping value (default is 0)
  78976. * @param max defines maximum clamping value (default is 1)
  78977. * @param result defines color to store the result into.
  78978. * @returns the cuurent Color4
  78979. */
  78980. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78981. /**
  78982. * Multipy an Color4 value by another and return a new Color4 object
  78983. * @param color defines the Color4 value to multiply by
  78984. * @returns a new Color4 object
  78985. */
  78986. multiply(color: Color4): Color4;
  78987. /**
  78988. * Multipy a Color4 value by another and push the result in a reference value
  78989. * @param color defines the Color4 value to multiply by
  78990. * @param result defines the Color4 to fill the result in
  78991. * @returns the result Color4
  78992. */
  78993. multiplyToRef(color: Color4, result: Color4): Color4;
  78994. /**
  78995. * Creates a string with the Color4 current values
  78996. * @returns the string representation of the Color4 object
  78997. */
  78998. toString(): string;
  78999. /**
  79000. * Returns the string "Color4"
  79001. * @returns "Color4"
  79002. */
  79003. getClassName(): string;
  79004. /**
  79005. * Compute the Color4 hash code
  79006. * @returns an unique number that can be used to hash Color4 objects
  79007. */
  79008. getHashCode(): number;
  79009. /**
  79010. * Creates a new Color4 copied from the current one
  79011. * @returns a new Color4 object
  79012. */
  79013. clone(): Color4;
  79014. /**
  79015. * Copies the given Color4 values into the current one
  79016. * @param source defines the source Color4 object
  79017. * @returns the current updated Color4 object
  79018. */
  79019. copyFrom(source: Color4): Color4;
  79020. /**
  79021. * Copies the given float values into the current one
  79022. * @param r defines the red component to read from
  79023. * @param g defines the green component to read from
  79024. * @param b defines the blue component to read from
  79025. * @param a defines the alpha component to read from
  79026. * @returns the current updated Color4 object
  79027. */
  79028. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79029. /**
  79030. * Copies the given float values into the current one
  79031. * @param r defines the red component to read from
  79032. * @param g defines the green component to read from
  79033. * @param b defines the blue component to read from
  79034. * @param a defines the alpha component to read from
  79035. * @returns the current updated Color4 object
  79036. */
  79037. set(r: number, g: number, b: number, a: number): Color4;
  79038. /**
  79039. * Compute the Color4 hexadecimal code as a string
  79040. * @returns a string containing the hexadecimal representation of the Color4 object
  79041. */
  79042. toHexString(): string;
  79043. /**
  79044. * Computes a new Color4 converted from the current one to linear space
  79045. * @returns a new Color4 object
  79046. */
  79047. toLinearSpace(): Color4;
  79048. /**
  79049. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79050. * @param convertedColor defines the Color4 object where to store the linear space version
  79051. * @returns the unmodified Color4
  79052. */
  79053. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79054. /**
  79055. * Computes a new Color4 converted from the current one to gamma space
  79056. * @returns a new Color4 object
  79057. */
  79058. toGammaSpace(): Color4;
  79059. /**
  79060. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79061. * @param convertedColor defines the Color4 object where to store the gamma space version
  79062. * @returns the unmodified Color4
  79063. */
  79064. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79065. /**
  79066. * Creates a new Color4 from the string containing valid hexadecimal values
  79067. * @param hex defines a string containing valid hexadecimal values
  79068. * @returns a new Color4 object
  79069. */
  79070. static FromHexString(hex: string): Color4;
  79071. /**
  79072. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79073. * @param left defines the start value
  79074. * @param right defines the end value
  79075. * @param amount defines the gradient factor
  79076. * @returns a new Color4 object
  79077. */
  79078. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79079. /**
  79080. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79081. * @param left defines the start value
  79082. * @param right defines the end value
  79083. * @param amount defines the gradient factor
  79084. * @param result defines the Color4 object where to store data
  79085. */
  79086. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79087. /**
  79088. * Creates a new Color4 from a Color3 and an alpha value
  79089. * @param color3 defines the source Color3 to read from
  79090. * @param alpha defines the alpha component (1.0 by default)
  79091. * @returns a new Color4 object
  79092. */
  79093. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79094. /**
  79095. * Creates a new Color4 from the starting index element of the given array
  79096. * @param array defines the source array to read from
  79097. * @param offset defines the offset in the source array
  79098. * @returns a new Color4 object
  79099. */
  79100. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79101. /**
  79102. * Creates a new Color3 from integer values (< 256)
  79103. * @param r defines the red component to read from (value between 0 and 255)
  79104. * @param g defines the green component to read from (value between 0 and 255)
  79105. * @param b defines the blue component to read from (value between 0 and 255)
  79106. * @param a defines the alpha component to read from (value between 0 and 255)
  79107. * @returns a new Color3 object
  79108. */
  79109. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79110. /**
  79111. * Check the content of a given array and convert it to an array containing RGBA data
  79112. * If the original array was already containing count * 4 values then it is returned directly
  79113. * @param colors defines the array to check
  79114. * @param count defines the number of RGBA data to expect
  79115. * @returns an array containing count * 4 values (RGBA)
  79116. */
  79117. static CheckColors4(colors: number[], count: number): number[];
  79118. }
  79119. /**
  79120. * @hidden
  79121. */
  79122. export class TmpColors {
  79123. static Color3: Color3[];
  79124. static Color4: Color4[];
  79125. }
  79126. }
  79127. declare module BABYLON {
  79128. /**
  79129. * Defines an interface which represents an animation key frame
  79130. */
  79131. export interface IAnimationKey {
  79132. /**
  79133. * Frame of the key frame
  79134. */
  79135. frame: number;
  79136. /**
  79137. * Value at the specifies key frame
  79138. */
  79139. value: any;
  79140. /**
  79141. * The input tangent for the cubic hermite spline
  79142. */
  79143. inTangent?: any;
  79144. /**
  79145. * The output tangent for the cubic hermite spline
  79146. */
  79147. outTangent?: any;
  79148. /**
  79149. * The animation interpolation type
  79150. */
  79151. interpolation?: AnimationKeyInterpolation;
  79152. }
  79153. /**
  79154. * Enum for the animation key frame interpolation type
  79155. */
  79156. export enum AnimationKeyInterpolation {
  79157. /**
  79158. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79159. */
  79160. STEP = 1
  79161. }
  79162. }
  79163. declare module BABYLON {
  79164. /**
  79165. * Represents the range of an animation
  79166. */
  79167. export class AnimationRange {
  79168. /**The name of the animation range**/
  79169. name: string;
  79170. /**The starting frame of the animation */
  79171. from: number;
  79172. /**The ending frame of the animation*/
  79173. to: number;
  79174. /**
  79175. * Initializes the range of an animation
  79176. * @param name The name of the animation range
  79177. * @param from The starting frame of the animation
  79178. * @param to The ending frame of the animation
  79179. */
  79180. constructor(
  79181. /**The name of the animation range**/
  79182. name: string,
  79183. /**The starting frame of the animation */
  79184. from: number,
  79185. /**The ending frame of the animation*/
  79186. to: number);
  79187. /**
  79188. * Makes a copy of the animation range
  79189. * @returns A copy of the animation range
  79190. */
  79191. clone(): AnimationRange;
  79192. }
  79193. }
  79194. declare module BABYLON {
  79195. /**
  79196. * Composed of a frame, and an action function
  79197. */
  79198. export class AnimationEvent {
  79199. /** The frame for which the event is triggered **/
  79200. frame: number;
  79201. /** The event to perform when triggered **/
  79202. action: (currentFrame: number) => void;
  79203. /** Specifies if the event should be triggered only once**/
  79204. onlyOnce?: boolean | undefined;
  79205. /**
  79206. * Specifies if the animation event is done
  79207. */
  79208. isDone: boolean;
  79209. /**
  79210. * Initializes the animation event
  79211. * @param frame The frame for which the event is triggered
  79212. * @param action The event to perform when triggered
  79213. * @param onlyOnce Specifies if the event should be triggered only once
  79214. */
  79215. constructor(
  79216. /** The frame for which the event is triggered **/
  79217. frame: number,
  79218. /** The event to perform when triggered **/
  79219. action: (currentFrame: number) => void,
  79220. /** Specifies if the event should be triggered only once**/
  79221. onlyOnce?: boolean | undefined);
  79222. /** @hidden */
  79223. _clone(): AnimationEvent;
  79224. }
  79225. }
  79226. declare module BABYLON {
  79227. /**
  79228. * Interface used to define a behavior
  79229. */
  79230. export interface Behavior<T> {
  79231. /** gets or sets behavior's name */
  79232. name: string;
  79233. /**
  79234. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79235. */
  79236. init(): void;
  79237. /**
  79238. * Called when the behavior is attached to a target
  79239. * @param target defines the target where the behavior is attached to
  79240. */
  79241. attach(target: T): void;
  79242. /**
  79243. * Called when the behavior is detached from its target
  79244. */
  79245. detach(): void;
  79246. }
  79247. /**
  79248. * Interface implemented by classes supporting behaviors
  79249. */
  79250. export interface IBehaviorAware<T> {
  79251. /**
  79252. * Attach a behavior
  79253. * @param behavior defines the behavior to attach
  79254. * @returns the current host
  79255. */
  79256. addBehavior(behavior: Behavior<T>): T;
  79257. /**
  79258. * Remove a behavior from the current object
  79259. * @param behavior defines the behavior to detach
  79260. * @returns the current host
  79261. */
  79262. removeBehavior(behavior: Behavior<T>): T;
  79263. /**
  79264. * Gets a behavior using its name to search
  79265. * @param name defines the name to search
  79266. * @returns the behavior or null if not found
  79267. */
  79268. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79269. }
  79270. }
  79271. declare module BABYLON {
  79272. /**
  79273. * Defines an array and its length.
  79274. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79275. */
  79276. export interface ISmartArrayLike<T> {
  79277. /**
  79278. * The data of the array.
  79279. */
  79280. data: Array<T>;
  79281. /**
  79282. * The active length of the array.
  79283. */
  79284. length: number;
  79285. }
  79286. /**
  79287. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79288. */
  79289. export class SmartArray<T> implements ISmartArrayLike<T> {
  79290. /**
  79291. * The full set of data from the array.
  79292. */
  79293. data: Array<T>;
  79294. /**
  79295. * The active length of the array.
  79296. */
  79297. length: number;
  79298. protected _id: number;
  79299. /**
  79300. * Instantiates a Smart Array.
  79301. * @param capacity defines the default capacity of the array.
  79302. */
  79303. constructor(capacity: number);
  79304. /**
  79305. * Pushes a value at the end of the active data.
  79306. * @param value defines the object to push in the array.
  79307. */
  79308. push(value: T): void;
  79309. /**
  79310. * Iterates over the active data and apply the lambda to them.
  79311. * @param func defines the action to apply on each value.
  79312. */
  79313. forEach(func: (content: T) => void): void;
  79314. /**
  79315. * Sorts the full sets of data.
  79316. * @param compareFn defines the comparison function to apply.
  79317. */
  79318. sort(compareFn: (a: T, b: T) => number): void;
  79319. /**
  79320. * Resets the active data to an empty array.
  79321. */
  79322. reset(): void;
  79323. /**
  79324. * Releases all the data from the array as well as the array.
  79325. */
  79326. dispose(): void;
  79327. /**
  79328. * Concats the active data with a given array.
  79329. * @param array defines the data to concatenate with.
  79330. */
  79331. concat(array: any): void;
  79332. /**
  79333. * Returns the position of a value in the active data.
  79334. * @param value defines the value to find the index for
  79335. * @returns the index if found in the active data otherwise -1
  79336. */
  79337. indexOf(value: T): number;
  79338. /**
  79339. * Returns whether an element is part of the active data.
  79340. * @param value defines the value to look for
  79341. * @returns true if found in the active data otherwise false
  79342. */
  79343. contains(value: T): boolean;
  79344. private static _GlobalId;
  79345. }
  79346. /**
  79347. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79348. * The data in this array can only be present once
  79349. */
  79350. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79351. private _duplicateId;
  79352. /**
  79353. * Pushes a value at the end of the active data.
  79354. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79355. * @param value defines the object to push in the array.
  79356. */
  79357. push(value: T): void;
  79358. /**
  79359. * Pushes a value at the end of the active data.
  79360. * If the data is already present, it won t be added again
  79361. * @param value defines the object to push in the array.
  79362. * @returns true if added false if it was already present
  79363. */
  79364. pushNoDuplicate(value: T): boolean;
  79365. /**
  79366. * Resets the active data to an empty array.
  79367. */
  79368. reset(): void;
  79369. /**
  79370. * Concats the active data with a given array.
  79371. * This ensures no dupplicate will be present in the result.
  79372. * @param array defines the data to concatenate with.
  79373. */
  79374. concatWithNoDuplicate(array: any): void;
  79375. }
  79376. }
  79377. declare module BABYLON {
  79378. /**
  79379. * @ignore
  79380. * This is a list of all the different input types that are available in the application.
  79381. * Fo instance: ArcRotateCameraGamepadInput...
  79382. */
  79383. export var CameraInputTypes: {};
  79384. /**
  79385. * This is the contract to implement in order to create a new input class.
  79386. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79387. */
  79388. export interface ICameraInput<TCamera extends Camera> {
  79389. /**
  79390. * Defines the camera the input is attached to.
  79391. */
  79392. camera: Nullable<TCamera>;
  79393. /**
  79394. * Gets the class name of the current intput.
  79395. * @returns the class name
  79396. */
  79397. getClassName(): string;
  79398. /**
  79399. * Get the friendly name associated with the input class.
  79400. * @returns the input friendly name
  79401. */
  79402. getSimpleName(): string;
  79403. /**
  79404. * Attach the input controls to a specific dom element to get the input from.
  79405. * @param element Defines the element the controls should be listened from
  79406. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79407. */
  79408. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79409. /**
  79410. * Detach the current controls from the specified dom element.
  79411. * @param element Defines the element to stop listening the inputs from
  79412. */
  79413. detachControl(element: Nullable<HTMLElement>): void;
  79414. /**
  79415. * Update the current camera state depending on the inputs that have been used this frame.
  79416. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79417. */
  79418. checkInputs?: () => void;
  79419. }
  79420. /**
  79421. * Represents a map of input types to input instance or input index to input instance.
  79422. */
  79423. export interface CameraInputsMap<TCamera extends Camera> {
  79424. /**
  79425. * Accessor to the input by input type.
  79426. */
  79427. [name: string]: ICameraInput<TCamera>;
  79428. /**
  79429. * Accessor to the input by input index.
  79430. */
  79431. [idx: number]: ICameraInput<TCamera>;
  79432. }
  79433. /**
  79434. * This represents the input manager used within a camera.
  79435. * It helps dealing with all the different kind of input attached to a camera.
  79436. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79437. */
  79438. export class CameraInputsManager<TCamera extends Camera> {
  79439. /**
  79440. * Defines the list of inputs attahed to the camera.
  79441. */
  79442. attached: CameraInputsMap<TCamera>;
  79443. /**
  79444. * Defines the dom element the camera is collecting inputs from.
  79445. * This is null if the controls have not been attached.
  79446. */
  79447. attachedElement: Nullable<HTMLElement>;
  79448. /**
  79449. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79450. */
  79451. noPreventDefault: boolean;
  79452. /**
  79453. * Defined the camera the input manager belongs to.
  79454. */
  79455. camera: TCamera;
  79456. /**
  79457. * Update the current camera state depending on the inputs that have been used this frame.
  79458. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79459. */
  79460. checkInputs: () => void;
  79461. /**
  79462. * Instantiate a new Camera Input Manager.
  79463. * @param camera Defines the camera the input manager blongs to
  79464. */
  79465. constructor(camera: TCamera);
  79466. /**
  79467. * Add an input method to a camera
  79468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79469. * @param input camera input method
  79470. */
  79471. add(input: ICameraInput<TCamera>): void;
  79472. /**
  79473. * Remove a specific input method from a camera
  79474. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79475. * @param inputToRemove camera input method
  79476. */
  79477. remove(inputToRemove: ICameraInput<TCamera>): void;
  79478. /**
  79479. * Remove a specific input type from a camera
  79480. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79481. * @param inputType the type of the input to remove
  79482. */
  79483. removeByType(inputType: string): void;
  79484. private _addCheckInputs;
  79485. /**
  79486. * Attach the input controls to the currently attached dom element to listen the events from.
  79487. * @param input Defines the input to attach
  79488. */
  79489. attachInput(input: ICameraInput<TCamera>): void;
  79490. /**
  79491. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79492. * @param element Defines the dom element to collect the events from
  79493. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79494. */
  79495. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79496. /**
  79497. * Detach the current manager inputs controls from a specific dom element.
  79498. * @param element Defines the dom element to collect the events from
  79499. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79500. */
  79501. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79502. /**
  79503. * Rebuild the dynamic inputCheck function from the current list of
  79504. * defined inputs in the manager.
  79505. */
  79506. rebuildInputCheck(): void;
  79507. /**
  79508. * Remove all attached input methods from a camera
  79509. */
  79510. clear(): void;
  79511. /**
  79512. * Serialize the current input manager attached to a camera.
  79513. * This ensures than once parsed,
  79514. * the input associated to the camera will be identical to the current ones
  79515. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79516. */
  79517. serialize(serializedCamera: any): void;
  79518. /**
  79519. * Parses an input manager serialized JSON to restore the previous list of inputs
  79520. * and states associated to a camera.
  79521. * @param parsedCamera Defines the JSON to parse
  79522. */
  79523. parse(parsedCamera: any): void;
  79524. }
  79525. }
  79526. declare module BABYLON {
  79527. /**
  79528. * Class used to store data that will be store in GPU memory
  79529. */
  79530. export class Buffer {
  79531. private _engine;
  79532. private _buffer;
  79533. /** @hidden */
  79534. _data: Nullable<DataArray>;
  79535. private _updatable;
  79536. private _instanced;
  79537. private _divisor;
  79538. /**
  79539. * Gets the byte stride.
  79540. */
  79541. readonly byteStride: number;
  79542. /**
  79543. * Constructor
  79544. * @param engine the engine
  79545. * @param data the data to use for this buffer
  79546. * @param updatable whether the data is updatable
  79547. * @param stride the stride (optional)
  79548. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79549. * @param instanced whether the buffer is instanced (optional)
  79550. * @param useBytes set to true if the stride in in bytes (optional)
  79551. * @param divisor sets an optional divisor for instances (1 by default)
  79552. */
  79553. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79554. /**
  79555. * Create a new VertexBuffer based on the current buffer
  79556. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79557. * @param offset defines offset in the buffer (0 by default)
  79558. * @param size defines the size in floats of attributes (position is 3 for instance)
  79559. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79560. * @param instanced defines if the vertex buffer contains indexed data
  79561. * @param useBytes defines if the offset and stride are in bytes *
  79562. * @param divisor sets an optional divisor for instances (1 by default)
  79563. * @returns the new vertex buffer
  79564. */
  79565. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79566. /**
  79567. * Gets a boolean indicating if the Buffer is updatable?
  79568. * @returns true if the buffer is updatable
  79569. */
  79570. isUpdatable(): boolean;
  79571. /**
  79572. * Gets current buffer's data
  79573. * @returns a DataArray or null
  79574. */
  79575. getData(): Nullable<DataArray>;
  79576. /**
  79577. * Gets underlying native buffer
  79578. * @returns underlying native buffer
  79579. */
  79580. getBuffer(): Nullable<DataBuffer>;
  79581. /**
  79582. * Gets the stride in float32 units (i.e. byte stride / 4).
  79583. * May not be an integer if the byte stride is not divisible by 4.
  79584. * @returns the stride in float32 units
  79585. * @deprecated Please use byteStride instead.
  79586. */
  79587. getStrideSize(): number;
  79588. /**
  79589. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79590. * @param data defines the data to store
  79591. */
  79592. create(data?: Nullable<DataArray>): void;
  79593. /** @hidden */
  79594. _rebuild(): void;
  79595. /**
  79596. * Update current buffer data
  79597. * @param data defines the data to store
  79598. */
  79599. update(data: DataArray): void;
  79600. /**
  79601. * Updates the data directly.
  79602. * @param data the new data
  79603. * @param offset the new offset
  79604. * @param vertexCount the vertex count (optional)
  79605. * @param useBytes set to true if the offset is in bytes
  79606. */
  79607. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79608. /**
  79609. * Release all resources
  79610. */
  79611. dispose(): void;
  79612. }
  79613. /**
  79614. * Specialized buffer used to store vertex data
  79615. */
  79616. export class VertexBuffer {
  79617. /** @hidden */
  79618. _buffer: Buffer;
  79619. private _kind;
  79620. private _size;
  79621. private _ownsBuffer;
  79622. private _instanced;
  79623. private _instanceDivisor;
  79624. /**
  79625. * The byte type.
  79626. */
  79627. static readonly BYTE: number;
  79628. /**
  79629. * The unsigned byte type.
  79630. */
  79631. static readonly UNSIGNED_BYTE: number;
  79632. /**
  79633. * The short type.
  79634. */
  79635. static readonly SHORT: number;
  79636. /**
  79637. * The unsigned short type.
  79638. */
  79639. static readonly UNSIGNED_SHORT: number;
  79640. /**
  79641. * The integer type.
  79642. */
  79643. static readonly INT: number;
  79644. /**
  79645. * The unsigned integer type.
  79646. */
  79647. static readonly UNSIGNED_INT: number;
  79648. /**
  79649. * The float type.
  79650. */
  79651. static readonly FLOAT: number;
  79652. /**
  79653. * Gets or sets the instance divisor when in instanced mode
  79654. */
  79655. get instanceDivisor(): number;
  79656. set instanceDivisor(value: number);
  79657. /**
  79658. * Gets the byte stride.
  79659. */
  79660. readonly byteStride: number;
  79661. /**
  79662. * Gets the byte offset.
  79663. */
  79664. readonly byteOffset: number;
  79665. /**
  79666. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79667. */
  79668. readonly normalized: boolean;
  79669. /**
  79670. * Gets the data type of each component in the array.
  79671. */
  79672. readonly type: number;
  79673. /**
  79674. * Constructor
  79675. * @param engine the engine
  79676. * @param data the data to use for this vertex buffer
  79677. * @param kind the vertex buffer kind
  79678. * @param updatable whether the data is updatable
  79679. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79680. * @param stride the stride (optional)
  79681. * @param instanced whether the buffer is instanced (optional)
  79682. * @param offset the offset of the data (optional)
  79683. * @param size the number of components (optional)
  79684. * @param type the type of the component (optional)
  79685. * @param normalized whether the data contains normalized data (optional)
  79686. * @param useBytes set to true if stride and offset are in bytes (optional)
  79687. * @param divisor defines the instance divisor to use (1 by default)
  79688. */
  79689. 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);
  79690. /** @hidden */
  79691. _rebuild(): void;
  79692. /**
  79693. * Returns the kind of the VertexBuffer (string)
  79694. * @returns a string
  79695. */
  79696. getKind(): string;
  79697. /**
  79698. * Gets a boolean indicating if the VertexBuffer is updatable?
  79699. * @returns true if the buffer is updatable
  79700. */
  79701. isUpdatable(): boolean;
  79702. /**
  79703. * Gets current buffer's data
  79704. * @returns a DataArray or null
  79705. */
  79706. getData(): Nullable<DataArray>;
  79707. /**
  79708. * Gets underlying native buffer
  79709. * @returns underlying native buffer
  79710. */
  79711. getBuffer(): Nullable<DataBuffer>;
  79712. /**
  79713. * Gets the stride in float32 units (i.e. byte stride / 4).
  79714. * May not be an integer if the byte stride is not divisible by 4.
  79715. * @returns the stride in float32 units
  79716. * @deprecated Please use byteStride instead.
  79717. */
  79718. getStrideSize(): number;
  79719. /**
  79720. * Returns the offset as a multiple of the type byte length.
  79721. * @returns the offset in bytes
  79722. * @deprecated Please use byteOffset instead.
  79723. */
  79724. getOffset(): number;
  79725. /**
  79726. * Returns the number of components per vertex attribute (integer)
  79727. * @returns the size in float
  79728. */
  79729. getSize(): number;
  79730. /**
  79731. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79732. * @returns true if this buffer is instanced
  79733. */
  79734. getIsInstanced(): boolean;
  79735. /**
  79736. * Returns the instancing divisor, zero for non-instanced (integer).
  79737. * @returns a number
  79738. */
  79739. getInstanceDivisor(): number;
  79740. /**
  79741. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79742. * @param data defines the data to store
  79743. */
  79744. create(data?: DataArray): void;
  79745. /**
  79746. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79747. * This function will create a new buffer if the current one is not updatable
  79748. * @param data defines the data to store
  79749. */
  79750. update(data: DataArray): void;
  79751. /**
  79752. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79753. * Returns the directly updated WebGLBuffer.
  79754. * @param data the new data
  79755. * @param offset the new offset
  79756. * @param useBytes set to true if the offset is in bytes
  79757. */
  79758. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79759. /**
  79760. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79761. */
  79762. dispose(): void;
  79763. /**
  79764. * Enumerates each value of this vertex buffer as numbers.
  79765. * @param count the number of values to enumerate
  79766. * @param callback the callback function called for each value
  79767. */
  79768. forEach(count: number, callback: (value: number, index: number) => void): void;
  79769. /**
  79770. * Positions
  79771. */
  79772. static readonly PositionKind: string;
  79773. /**
  79774. * Normals
  79775. */
  79776. static readonly NormalKind: string;
  79777. /**
  79778. * Tangents
  79779. */
  79780. static readonly TangentKind: string;
  79781. /**
  79782. * Texture coordinates
  79783. */
  79784. static readonly UVKind: string;
  79785. /**
  79786. * Texture coordinates 2
  79787. */
  79788. static readonly UV2Kind: string;
  79789. /**
  79790. * Texture coordinates 3
  79791. */
  79792. static readonly UV3Kind: string;
  79793. /**
  79794. * Texture coordinates 4
  79795. */
  79796. static readonly UV4Kind: string;
  79797. /**
  79798. * Texture coordinates 5
  79799. */
  79800. static readonly UV5Kind: string;
  79801. /**
  79802. * Texture coordinates 6
  79803. */
  79804. static readonly UV6Kind: string;
  79805. /**
  79806. * Colors
  79807. */
  79808. static readonly ColorKind: string;
  79809. /**
  79810. * Matrix indices (for bones)
  79811. */
  79812. static readonly MatricesIndicesKind: string;
  79813. /**
  79814. * Matrix weights (for bones)
  79815. */
  79816. static readonly MatricesWeightsKind: string;
  79817. /**
  79818. * Additional matrix indices (for bones)
  79819. */
  79820. static readonly MatricesIndicesExtraKind: string;
  79821. /**
  79822. * Additional matrix weights (for bones)
  79823. */
  79824. static readonly MatricesWeightsExtraKind: string;
  79825. /**
  79826. * Deduces the stride given a kind.
  79827. * @param kind The kind string to deduce
  79828. * @returns The deduced stride
  79829. */
  79830. static DeduceStride(kind: string): number;
  79831. /**
  79832. * Gets the byte length of the given type.
  79833. * @param type the type
  79834. * @returns the number of bytes
  79835. */
  79836. static GetTypeByteLength(type: number): number;
  79837. /**
  79838. * Enumerates each value of the given parameters as numbers.
  79839. * @param data the data to enumerate
  79840. * @param byteOffset the byte offset of the data
  79841. * @param byteStride the byte stride of the data
  79842. * @param componentCount the number of components per element
  79843. * @param componentType the type of the component
  79844. * @param count the number of values to enumerate
  79845. * @param normalized whether the data is normalized
  79846. * @param callback the callback function called for each value
  79847. */
  79848. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79849. private static _GetFloatValue;
  79850. }
  79851. }
  79852. declare module BABYLON {
  79853. /**
  79854. * @hidden
  79855. */
  79856. export class IntersectionInfo {
  79857. bu: Nullable<number>;
  79858. bv: Nullable<number>;
  79859. distance: number;
  79860. faceId: number;
  79861. subMeshId: number;
  79862. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79863. }
  79864. }
  79865. declare module BABYLON {
  79866. /**
  79867. * Represens a plane by the equation ax + by + cz + d = 0
  79868. */
  79869. export class Plane {
  79870. private static _TmpMatrix;
  79871. /**
  79872. * Normal of the plane (a,b,c)
  79873. */
  79874. normal: Vector3;
  79875. /**
  79876. * d component of the plane
  79877. */
  79878. d: number;
  79879. /**
  79880. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79881. * @param a a component of the plane
  79882. * @param b b component of the plane
  79883. * @param c c component of the plane
  79884. * @param d d component of the plane
  79885. */
  79886. constructor(a: number, b: number, c: number, d: number);
  79887. /**
  79888. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79889. */
  79890. asArray(): number[];
  79891. /**
  79892. * @returns a new plane copied from the current Plane.
  79893. */
  79894. clone(): Plane;
  79895. /**
  79896. * @returns the string "Plane".
  79897. */
  79898. getClassName(): string;
  79899. /**
  79900. * @returns the Plane hash code.
  79901. */
  79902. getHashCode(): number;
  79903. /**
  79904. * Normalize the current Plane in place.
  79905. * @returns the updated Plane.
  79906. */
  79907. normalize(): Plane;
  79908. /**
  79909. * Applies a transformation the plane and returns the result
  79910. * @param transformation the transformation matrix to be applied to the plane
  79911. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79912. */
  79913. transform(transformation: DeepImmutable<Matrix>): Plane;
  79914. /**
  79915. * Calcualtte the dot product between the point and the plane normal
  79916. * @param point point to calculate the dot product with
  79917. * @returns the dot product (float) of the point coordinates and the plane normal.
  79918. */
  79919. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79920. /**
  79921. * Updates the current Plane from the plane defined by the three given points.
  79922. * @param point1 one of the points used to contruct the plane
  79923. * @param point2 one of the points used to contruct the plane
  79924. * @param point3 one of the points used to contruct the plane
  79925. * @returns the updated Plane.
  79926. */
  79927. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79928. /**
  79929. * Checks if the plane is facing a given direction
  79930. * @param direction the direction to check if the plane is facing
  79931. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79932. * @returns True is the vector "direction" is the same side than the plane normal.
  79933. */
  79934. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79935. /**
  79936. * Calculates the distance to a point
  79937. * @param point point to calculate distance to
  79938. * @returns the signed distance (float) from the given point to the Plane.
  79939. */
  79940. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79941. /**
  79942. * Creates a plane from an array
  79943. * @param array the array to create a plane from
  79944. * @returns a new Plane from the given array.
  79945. */
  79946. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79947. /**
  79948. * Creates a plane from three points
  79949. * @param point1 point used to create the plane
  79950. * @param point2 point used to create the plane
  79951. * @param point3 point used to create the plane
  79952. * @returns a new Plane defined by the three given points.
  79953. */
  79954. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79955. /**
  79956. * Creates a plane from an origin point and a normal
  79957. * @param origin origin of the plane to be constructed
  79958. * @param normal normal of the plane to be constructed
  79959. * @returns a new Plane the normal vector to this plane at the given origin point.
  79960. * Note : the vector "normal" is updated because normalized.
  79961. */
  79962. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79963. /**
  79964. * Calculates the distance from a plane and a point
  79965. * @param origin origin of the plane to be constructed
  79966. * @param normal normal of the plane to be constructed
  79967. * @param point point to calculate distance to
  79968. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79969. */
  79970. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79971. }
  79972. }
  79973. declare module BABYLON {
  79974. /**
  79975. * Class used to store bounding sphere information
  79976. */
  79977. export class BoundingSphere {
  79978. /**
  79979. * Gets the center of the bounding sphere in local space
  79980. */
  79981. readonly center: Vector3;
  79982. /**
  79983. * Radius of the bounding sphere in local space
  79984. */
  79985. radius: number;
  79986. /**
  79987. * Gets the center of the bounding sphere in world space
  79988. */
  79989. readonly centerWorld: Vector3;
  79990. /**
  79991. * Radius of the bounding sphere in world space
  79992. */
  79993. radiusWorld: number;
  79994. /**
  79995. * Gets the minimum vector in local space
  79996. */
  79997. readonly minimum: Vector3;
  79998. /**
  79999. * Gets the maximum vector in local space
  80000. */
  80001. readonly maximum: Vector3;
  80002. private _worldMatrix;
  80003. private static readonly TmpVector3;
  80004. /**
  80005. * Creates a new bounding sphere
  80006. * @param min defines the minimum vector (in local space)
  80007. * @param max defines the maximum vector (in local space)
  80008. * @param worldMatrix defines the new world matrix
  80009. */
  80010. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80011. /**
  80012. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80013. * @param min defines the new minimum vector (in local space)
  80014. * @param max defines the new maximum vector (in local space)
  80015. * @param worldMatrix defines the new world matrix
  80016. */
  80017. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80018. /**
  80019. * Scale the current bounding sphere by applying a scale factor
  80020. * @param factor defines the scale factor to apply
  80021. * @returns the current bounding box
  80022. */
  80023. scale(factor: number): BoundingSphere;
  80024. /**
  80025. * Gets the world matrix of the bounding box
  80026. * @returns a matrix
  80027. */
  80028. getWorldMatrix(): DeepImmutable<Matrix>;
  80029. /** @hidden */
  80030. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80031. /**
  80032. * Tests if the bounding sphere is intersecting the frustum planes
  80033. * @param frustumPlanes defines the frustum planes to test
  80034. * @returns true if there is an intersection
  80035. */
  80036. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80037. /**
  80038. * Tests if the bounding sphere center is in between the frustum planes.
  80039. * Used for optimistic fast inclusion.
  80040. * @param frustumPlanes defines the frustum planes to test
  80041. * @returns true if the sphere center is in between the frustum planes
  80042. */
  80043. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80044. /**
  80045. * Tests if a point is inside the bounding sphere
  80046. * @param point defines the point to test
  80047. * @returns true if the point is inside the bounding sphere
  80048. */
  80049. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80050. /**
  80051. * Checks if two sphere intersct
  80052. * @param sphere0 sphere 0
  80053. * @param sphere1 sphere 1
  80054. * @returns true if the speres intersect
  80055. */
  80056. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80057. }
  80058. }
  80059. declare module BABYLON {
  80060. /**
  80061. * Class used to store bounding box information
  80062. */
  80063. export class BoundingBox implements ICullable {
  80064. /**
  80065. * Gets the 8 vectors representing the bounding box in local space
  80066. */
  80067. readonly vectors: Vector3[];
  80068. /**
  80069. * Gets the center of the bounding box in local space
  80070. */
  80071. readonly center: Vector3;
  80072. /**
  80073. * Gets the center of the bounding box in world space
  80074. */
  80075. readonly centerWorld: Vector3;
  80076. /**
  80077. * Gets the extend size in local space
  80078. */
  80079. readonly extendSize: Vector3;
  80080. /**
  80081. * Gets the extend size in world space
  80082. */
  80083. readonly extendSizeWorld: Vector3;
  80084. /**
  80085. * Gets the OBB (object bounding box) directions
  80086. */
  80087. readonly directions: Vector3[];
  80088. /**
  80089. * Gets the 8 vectors representing the bounding box in world space
  80090. */
  80091. readonly vectorsWorld: Vector3[];
  80092. /**
  80093. * Gets the minimum vector in world space
  80094. */
  80095. readonly minimumWorld: Vector3;
  80096. /**
  80097. * Gets the maximum vector in world space
  80098. */
  80099. readonly maximumWorld: Vector3;
  80100. /**
  80101. * Gets the minimum vector in local space
  80102. */
  80103. readonly minimum: Vector3;
  80104. /**
  80105. * Gets the maximum vector in local space
  80106. */
  80107. readonly maximum: Vector3;
  80108. private _worldMatrix;
  80109. private static readonly TmpVector3;
  80110. /**
  80111. * @hidden
  80112. */
  80113. _tag: number;
  80114. /**
  80115. * Creates a new bounding box
  80116. * @param min defines the minimum vector (in local space)
  80117. * @param max defines the maximum vector (in local space)
  80118. * @param worldMatrix defines the new world matrix
  80119. */
  80120. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80121. /**
  80122. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80123. * @param min defines the new minimum vector (in local space)
  80124. * @param max defines the new maximum vector (in local space)
  80125. * @param worldMatrix defines the new world matrix
  80126. */
  80127. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80128. /**
  80129. * Scale the current bounding box by applying a scale factor
  80130. * @param factor defines the scale factor to apply
  80131. * @returns the current bounding box
  80132. */
  80133. scale(factor: number): BoundingBox;
  80134. /**
  80135. * Gets the world matrix of the bounding box
  80136. * @returns a matrix
  80137. */
  80138. getWorldMatrix(): DeepImmutable<Matrix>;
  80139. /** @hidden */
  80140. _update(world: DeepImmutable<Matrix>): void;
  80141. /**
  80142. * Tests if the bounding box is intersecting the frustum planes
  80143. * @param frustumPlanes defines the frustum planes to test
  80144. * @returns true if there is an intersection
  80145. */
  80146. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80147. /**
  80148. * Tests if the bounding box is entirely inside the frustum planes
  80149. * @param frustumPlanes defines the frustum planes to test
  80150. * @returns true if there is an inclusion
  80151. */
  80152. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80153. /**
  80154. * Tests if a point is inside the bounding box
  80155. * @param point defines the point to test
  80156. * @returns true if the point is inside the bounding box
  80157. */
  80158. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80159. /**
  80160. * Tests if the bounding box intersects with a bounding sphere
  80161. * @param sphere defines the sphere to test
  80162. * @returns true if there is an intersection
  80163. */
  80164. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80165. /**
  80166. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80167. * @param min defines the min vector to use
  80168. * @param max defines the max vector to use
  80169. * @returns true if there is an intersection
  80170. */
  80171. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80172. /**
  80173. * Tests if two bounding boxes are intersections
  80174. * @param box0 defines the first box to test
  80175. * @param box1 defines the second box to test
  80176. * @returns true if there is an intersection
  80177. */
  80178. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80179. /**
  80180. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80181. * @param minPoint defines the minimum vector of the bounding box
  80182. * @param maxPoint defines the maximum vector of the bounding box
  80183. * @param sphereCenter defines the sphere center
  80184. * @param sphereRadius defines the sphere radius
  80185. * @returns true if there is an intersection
  80186. */
  80187. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80188. /**
  80189. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80190. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80191. * @param frustumPlanes defines the frustum planes to test
  80192. * @return true if there is an inclusion
  80193. */
  80194. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80195. /**
  80196. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80197. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80198. * @param frustumPlanes defines the frustum planes to test
  80199. * @return true if there is an intersection
  80200. */
  80201. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80202. }
  80203. }
  80204. declare module BABYLON {
  80205. /** @hidden */
  80206. export class Collider {
  80207. /** Define if a collision was found */
  80208. collisionFound: boolean;
  80209. /**
  80210. * Define last intersection point in local space
  80211. */
  80212. intersectionPoint: Vector3;
  80213. /**
  80214. * Define last collided mesh
  80215. */
  80216. collidedMesh: Nullable<AbstractMesh>;
  80217. private _collisionPoint;
  80218. private _planeIntersectionPoint;
  80219. private _tempVector;
  80220. private _tempVector2;
  80221. private _tempVector3;
  80222. private _tempVector4;
  80223. private _edge;
  80224. private _baseToVertex;
  80225. private _destinationPoint;
  80226. private _slidePlaneNormal;
  80227. private _displacementVector;
  80228. /** @hidden */
  80229. _radius: Vector3;
  80230. /** @hidden */
  80231. _retry: number;
  80232. private _velocity;
  80233. private _basePoint;
  80234. private _epsilon;
  80235. /** @hidden */
  80236. _velocityWorldLength: number;
  80237. /** @hidden */
  80238. _basePointWorld: Vector3;
  80239. private _velocityWorld;
  80240. private _normalizedVelocity;
  80241. /** @hidden */
  80242. _initialVelocity: Vector3;
  80243. /** @hidden */
  80244. _initialPosition: Vector3;
  80245. private _nearestDistance;
  80246. private _collisionMask;
  80247. get collisionMask(): number;
  80248. set collisionMask(mask: number);
  80249. /**
  80250. * Gets the plane normal used to compute the sliding response (in local space)
  80251. */
  80252. get slidePlaneNormal(): Vector3;
  80253. /** @hidden */
  80254. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80255. /** @hidden */
  80256. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80257. /** @hidden */
  80258. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80259. /** @hidden */
  80260. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80261. /** @hidden */
  80262. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80263. /** @hidden */
  80264. _getResponse(pos: Vector3, vel: Vector3): void;
  80265. }
  80266. }
  80267. declare module BABYLON {
  80268. /**
  80269. * Interface for cullable objects
  80270. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80271. */
  80272. export interface ICullable {
  80273. /**
  80274. * Checks if the object or part of the object is in the frustum
  80275. * @param frustumPlanes Camera near/planes
  80276. * @returns true if the object is in frustum otherwise false
  80277. */
  80278. isInFrustum(frustumPlanes: Plane[]): boolean;
  80279. /**
  80280. * Checks if a cullable object (mesh...) is in the camera frustum
  80281. * Unlike isInFrustum this cheks the full bounding box
  80282. * @param frustumPlanes Camera near/planes
  80283. * @returns true if the object is in frustum otherwise false
  80284. */
  80285. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80286. }
  80287. /**
  80288. * Info for a bounding data of a mesh
  80289. */
  80290. export class BoundingInfo implements ICullable {
  80291. /**
  80292. * Bounding box for the mesh
  80293. */
  80294. readonly boundingBox: BoundingBox;
  80295. /**
  80296. * Bounding sphere for the mesh
  80297. */
  80298. readonly boundingSphere: BoundingSphere;
  80299. private _isLocked;
  80300. private static readonly TmpVector3;
  80301. /**
  80302. * Constructs bounding info
  80303. * @param minimum min vector of the bounding box/sphere
  80304. * @param maximum max vector of the bounding box/sphere
  80305. * @param worldMatrix defines the new world matrix
  80306. */
  80307. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80308. /**
  80309. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80310. * @param min defines the new minimum vector (in local space)
  80311. * @param max defines the new maximum vector (in local space)
  80312. * @param worldMatrix defines the new world matrix
  80313. */
  80314. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80315. /**
  80316. * min vector of the bounding box/sphere
  80317. */
  80318. get minimum(): Vector3;
  80319. /**
  80320. * max vector of the bounding box/sphere
  80321. */
  80322. get maximum(): Vector3;
  80323. /**
  80324. * If the info is locked and won't be updated to avoid perf overhead
  80325. */
  80326. get isLocked(): boolean;
  80327. set isLocked(value: boolean);
  80328. /**
  80329. * Updates the bounding sphere and box
  80330. * @param world world matrix to be used to update
  80331. */
  80332. update(world: DeepImmutable<Matrix>): void;
  80333. /**
  80334. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80335. * @param center New center of the bounding info
  80336. * @param extend New extend of the bounding info
  80337. * @returns the current bounding info
  80338. */
  80339. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80340. /**
  80341. * Scale the current bounding info by applying a scale factor
  80342. * @param factor defines the scale factor to apply
  80343. * @returns the current bounding info
  80344. */
  80345. scale(factor: number): BoundingInfo;
  80346. /**
  80347. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80348. * @param frustumPlanes defines the frustum to test
  80349. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80350. * @returns true if the bounding info is in the frustum planes
  80351. */
  80352. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80353. /**
  80354. * Gets the world distance between the min and max points of the bounding box
  80355. */
  80356. get diagonalLength(): number;
  80357. /**
  80358. * Checks if a cullable object (mesh...) is in the camera frustum
  80359. * Unlike isInFrustum this cheks the full bounding box
  80360. * @param frustumPlanes Camera near/planes
  80361. * @returns true if the object is in frustum otherwise false
  80362. */
  80363. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80364. /** @hidden */
  80365. _checkCollision(collider: Collider): boolean;
  80366. /**
  80367. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80368. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80369. * @param point the point to check intersection with
  80370. * @returns if the point intersects
  80371. */
  80372. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80373. /**
  80374. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80375. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80376. * @param boundingInfo the bounding info to check intersection with
  80377. * @param precise if the intersection should be done using OBB
  80378. * @returns if the bounding info intersects
  80379. */
  80380. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80381. }
  80382. }
  80383. declare module BABYLON {
  80384. /**
  80385. * Extracts minimum and maximum values from a list of indexed positions
  80386. * @param positions defines the positions to use
  80387. * @param indices defines the indices to the positions
  80388. * @param indexStart defines the start index
  80389. * @param indexCount defines the end index
  80390. * @param bias defines bias value to add to the result
  80391. * @return minimum and maximum values
  80392. */
  80393. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80394. minimum: Vector3;
  80395. maximum: Vector3;
  80396. };
  80397. /**
  80398. * Extracts minimum and maximum values from a list of positions
  80399. * @param positions defines the positions to use
  80400. * @param start defines the start index in the positions array
  80401. * @param count defines the number of positions to handle
  80402. * @param bias defines bias value to add to the result
  80403. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80404. * @return minimum and maximum values
  80405. */
  80406. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80407. minimum: Vector3;
  80408. maximum: Vector3;
  80409. };
  80410. }
  80411. declare module BABYLON {
  80412. /** @hidden */
  80413. export class WebGLDataBuffer extends DataBuffer {
  80414. private _buffer;
  80415. constructor(resource: WebGLBuffer);
  80416. get underlyingResource(): any;
  80417. }
  80418. }
  80419. declare module BABYLON {
  80420. /** @hidden */
  80421. export class WebGLPipelineContext implements IPipelineContext {
  80422. engine: ThinEngine;
  80423. program: Nullable<WebGLProgram>;
  80424. context?: WebGLRenderingContext;
  80425. vertexShader?: WebGLShader;
  80426. fragmentShader?: WebGLShader;
  80427. isParallelCompiled: boolean;
  80428. onCompiled?: () => void;
  80429. transformFeedback?: WebGLTransformFeedback | null;
  80430. vertexCompilationError: Nullable<string>;
  80431. fragmentCompilationError: Nullable<string>;
  80432. programLinkError: Nullable<string>;
  80433. programValidationError: Nullable<string>;
  80434. get isAsync(): boolean;
  80435. get isReady(): boolean;
  80436. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80437. }
  80438. }
  80439. declare module BABYLON {
  80440. interface ThinEngine {
  80441. /**
  80442. * Create an uniform buffer
  80443. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80444. * @param elements defines the content of the uniform buffer
  80445. * @returns the webGL uniform buffer
  80446. */
  80447. createUniformBuffer(elements: FloatArray): DataBuffer;
  80448. /**
  80449. * Create a dynamic uniform buffer
  80450. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80451. * @param elements defines the content of the uniform buffer
  80452. * @returns the webGL uniform buffer
  80453. */
  80454. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80455. /**
  80456. * Update an existing uniform buffer
  80457. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80458. * @param uniformBuffer defines the target uniform buffer
  80459. * @param elements defines the content to update
  80460. * @param offset defines the offset in the uniform buffer where update should start
  80461. * @param count defines the size of the data to update
  80462. */
  80463. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80464. /**
  80465. * Bind an uniform buffer to the current webGL context
  80466. * @param buffer defines the buffer to bind
  80467. */
  80468. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80469. /**
  80470. * Bind a buffer to the current webGL context at a given location
  80471. * @param buffer defines the buffer to bind
  80472. * @param location defines the index where to bind the buffer
  80473. */
  80474. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80475. /**
  80476. * Bind a specific block at a given index in a specific shader program
  80477. * @param pipelineContext defines the pipeline context to use
  80478. * @param blockName defines the block name
  80479. * @param index defines the index where to bind the block
  80480. */
  80481. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80482. }
  80483. }
  80484. declare module BABYLON {
  80485. /**
  80486. * Uniform buffer objects.
  80487. *
  80488. * Handles blocks of uniform on the GPU.
  80489. *
  80490. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80491. *
  80492. * For more information, please refer to :
  80493. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80494. */
  80495. export class UniformBuffer {
  80496. private _engine;
  80497. private _buffer;
  80498. private _data;
  80499. private _bufferData;
  80500. private _dynamic?;
  80501. private _uniformLocations;
  80502. private _uniformSizes;
  80503. private _uniformLocationPointer;
  80504. private _needSync;
  80505. private _noUBO;
  80506. private _currentEffect;
  80507. /** @hidden */
  80508. _alreadyBound: boolean;
  80509. private static _MAX_UNIFORM_SIZE;
  80510. private static _tempBuffer;
  80511. /**
  80512. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80513. * This is dynamic to allow compat with webgl 1 and 2.
  80514. * You will need to pass the name of the uniform as well as the value.
  80515. */
  80516. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80517. /**
  80518. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80519. * This is dynamic to allow compat with webgl 1 and 2.
  80520. * You will need to pass the name of the uniform as well as the value.
  80521. */
  80522. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80523. /**
  80524. * Lambda to Update a single float in a uniform buffer.
  80525. * This is dynamic to allow compat with webgl 1 and 2.
  80526. * You will need to pass the name of the uniform as well as the value.
  80527. */
  80528. updateFloat: (name: string, x: number) => void;
  80529. /**
  80530. * Lambda to Update a vec2 of float in a uniform buffer.
  80531. * This is dynamic to allow compat with webgl 1 and 2.
  80532. * You will need to pass the name of the uniform as well as the value.
  80533. */
  80534. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80535. /**
  80536. * Lambda to Update a vec3 of float in a uniform buffer.
  80537. * This is dynamic to allow compat with webgl 1 and 2.
  80538. * You will need to pass the name of the uniform as well as the value.
  80539. */
  80540. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80541. /**
  80542. * Lambda to Update a vec4 of float in a uniform buffer.
  80543. * This is dynamic to allow compat with webgl 1 and 2.
  80544. * You will need to pass the name of the uniform as well as the value.
  80545. */
  80546. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80547. /**
  80548. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80549. * This is dynamic to allow compat with webgl 1 and 2.
  80550. * You will need to pass the name of the uniform as well as the value.
  80551. */
  80552. updateMatrix: (name: string, mat: Matrix) => void;
  80553. /**
  80554. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80555. * This is dynamic to allow compat with webgl 1 and 2.
  80556. * You will need to pass the name of the uniform as well as the value.
  80557. */
  80558. updateVector3: (name: string, vector: Vector3) => void;
  80559. /**
  80560. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80561. * This is dynamic to allow compat with webgl 1 and 2.
  80562. * You will need to pass the name of the uniform as well as the value.
  80563. */
  80564. updateVector4: (name: string, vector: Vector4) => void;
  80565. /**
  80566. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80567. * This is dynamic to allow compat with webgl 1 and 2.
  80568. * You will need to pass the name of the uniform as well as the value.
  80569. */
  80570. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80571. /**
  80572. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80573. * This is dynamic to allow compat with webgl 1 and 2.
  80574. * You will need to pass the name of the uniform as well as the value.
  80575. */
  80576. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80577. /**
  80578. * Instantiates a new Uniform buffer objects.
  80579. *
  80580. * Handles blocks of uniform on the GPU.
  80581. *
  80582. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80583. *
  80584. * For more information, please refer to :
  80585. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80586. * @param engine Define the engine the buffer is associated with
  80587. * @param data Define the data contained in the buffer
  80588. * @param dynamic Define if the buffer is updatable
  80589. */
  80590. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80591. /**
  80592. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80593. * or just falling back on setUniformXXX calls.
  80594. */
  80595. get useUbo(): boolean;
  80596. /**
  80597. * Indicates if the WebGL underlying uniform buffer is in sync
  80598. * with the javascript cache data.
  80599. */
  80600. get isSync(): boolean;
  80601. /**
  80602. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80603. * Also, a dynamic UniformBuffer will disable cache verification and always
  80604. * update the underlying WebGL uniform buffer to the GPU.
  80605. * @returns if Dynamic, otherwise false
  80606. */
  80607. isDynamic(): boolean;
  80608. /**
  80609. * The data cache on JS side.
  80610. * @returns the underlying data as a float array
  80611. */
  80612. getData(): Float32Array;
  80613. /**
  80614. * The underlying WebGL Uniform buffer.
  80615. * @returns the webgl buffer
  80616. */
  80617. getBuffer(): Nullable<DataBuffer>;
  80618. /**
  80619. * std140 layout specifies how to align data within an UBO structure.
  80620. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80621. * for specs.
  80622. */
  80623. private _fillAlignment;
  80624. /**
  80625. * Adds an uniform in the buffer.
  80626. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80627. * for the layout to be correct !
  80628. * @param name Name of the uniform, as used in the uniform block in the shader.
  80629. * @param size Data size, or data directly.
  80630. */
  80631. addUniform(name: string, size: number | number[]): void;
  80632. /**
  80633. * Adds a Matrix 4x4 to the uniform buffer.
  80634. * @param name Name of the uniform, as used in the uniform block in the shader.
  80635. * @param mat A 4x4 matrix.
  80636. */
  80637. addMatrix(name: string, mat: Matrix): void;
  80638. /**
  80639. * Adds a vec2 to the uniform buffer.
  80640. * @param name Name of the uniform, as used in the uniform block in the shader.
  80641. * @param x Define the x component value of the vec2
  80642. * @param y Define the y component value of the vec2
  80643. */
  80644. addFloat2(name: string, x: number, y: number): void;
  80645. /**
  80646. * Adds a vec3 to the uniform buffer.
  80647. * @param name Name of the uniform, as used in the uniform block in the shader.
  80648. * @param x Define the x component value of the vec3
  80649. * @param y Define the y component value of the vec3
  80650. * @param z Define the z component value of the vec3
  80651. */
  80652. addFloat3(name: string, x: number, y: number, z: number): void;
  80653. /**
  80654. * Adds a vec3 to the uniform buffer.
  80655. * @param name Name of the uniform, as used in the uniform block in the shader.
  80656. * @param color Define the vec3 from a Color
  80657. */
  80658. addColor3(name: string, color: Color3): void;
  80659. /**
  80660. * Adds a vec4 to the uniform buffer.
  80661. * @param name Name of the uniform, as used in the uniform block in the shader.
  80662. * @param color Define the rgb components from a Color
  80663. * @param alpha Define the a component of the vec4
  80664. */
  80665. addColor4(name: string, color: Color3, alpha: number): void;
  80666. /**
  80667. * Adds a vec3 to the uniform buffer.
  80668. * @param name Name of the uniform, as used in the uniform block in the shader.
  80669. * @param vector Define the vec3 components from a Vector
  80670. */
  80671. addVector3(name: string, vector: Vector3): void;
  80672. /**
  80673. * Adds a Matrix 3x3 to the uniform buffer.
  80674. * @param name Name of the uniform, as used in the uniform block in the shader.
  80675. */
  80676. addMatrix3x3(name: string): void;
  80677. /**
  80678. * Adds a Matrix 2x2 to the uniform buffer.
  80679. * @param name Name of the uniform, as used in the uniform block in the shader.
  80680. */
  80681. addMatrix2x2(name: string): void;
  80682. /**
  80683. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80684. */
  80685. create(): void;
  80686. /** @hidden */
  80687. _rebuild(): void;
  80688. /**
  80689. * Updates the WebGL Uniform Buffer on the GPU.
  80690. * If the `dynamic` flag is set to true, no cache comparison is done.
  80691. * Otherwise, the buffer will be updated only if the cache differs.
  80692. */
  80693. update(): void;
  80694. /**
  80695. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80696. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80697. * @param data Define the flattened data
  80698. * @param size Define the size of the data.
  80699. */
  80700. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80701. private _valueCache;
  80702. private _cacheMatrix;
  80703. private _updateMatrix3x3ForUniform;
  80704. private _updateMatrix3x3ForEffect;
  80705. private _updateMatrix2x2ForEffect;
  80706. private _updateMatrix2x2ForUniform;
  80707. private _updateFloatForEffect;
  80708. private _updateFloatForUniform;
  80709. private _updateFloat2ForEffect;
  80710. private _updateFloat2ForUniform;
  80711. private _updateFloat3ForEffect;
  80712. private _updateFloat3ForUniform;
  80713. private _updateFloat4ForEffect;
  80714. private _updateFloat4ForUniform;
  80715. private _updateMatrixForEffect;
  80716. private _updateMatrixForUniform;
  80717. private _updateVector3ForEffect;
  80718. private _updateVector3ForUniform;
  80719. private _updateVector4ForEffect;
  80720. private _updateVector4ForUniform;
  80721. private _updateColor3ForEffect;
  80722. private _updateColor3ForUniform;
  80723. private _updateColor4ForEffect;
  80724. private _updateColor4ForUniform;
  80725. /**
  80726. * Sets a sampler uniform on the effect.
  80727. * @param name Define the name of the sampler.
  80728. * @param texture Define the texture to set in the sampler
  80729. */
  80730. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80731. /**
  80732. * Directly updates the value of the uniform in the cache AND on the GPU.
  80733. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80734. * @param data Define the flattened data
  80735. */
  80736. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80737. /**
  80738. * Binds this uniform buffer to an effect.
  80739. * @param effect Define the effect to bind the buffer to
  80740. * @param name Name of the uniform block in the shader.
  80741. */
  80742. bindToEffect(effect: Effect, name: string): void;
  80743. /**
  80744. * Disposes the uniform buffer.
  80745. */
  80746. dispose(): void;
  80747. }
  80748. }
  80749. declare module BABYLON {
  80750. /**
  80751. * Enum that determines the text-wrapping mode to use.
  80752. */
  80753. export enum InspectableType {
  80754. /**
  80755. * Checkbox for booleans
  80756. */
  80757. Checkbox = 0,
  80758. /**
  80759. * Sliders for numbers
  80760. */
  80761. Slider = 1,
  80762. /**
  80763. * Vector3
  80764. */
  80765. Vector3 = 2,
  80766. /**
  80767. * Quaternions
  80768. */
  80769. Quaternion = 3,
  80770. /**
  80771. * Color3
  80772. */
  80773. Color3 = 4,
  80774. /**
  80775. * String
  80776. */
  80777. String = 5
  80778. }
  80779. /**
  80780. * Interface used to define custom inspectable properties.
  80781. * This interface is used by the inspector to display custom property grids
  80782. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80783. */
  80784. export interface IInspectable {
  80785. /**
  80786. * Gets the label to display
  80787. */
  80788. label: string;
  80789. /**
  80790. * Gets the name of the property to edit
  80791. */
  80792. propertyName: string;
  80793. /**
  80794. * Gets the type of the editor to use
  80795. */
  80796. type: InspectableType;
  80797. /**
  80798. * Gets the minimum value of the property when using in "slider" mode
  80799. */
  80800. min?: number;
  80801. /**
  80802. * Gets the maximum value of the property when using in "slider" mode
  80803. */
  80804. max?: number;
  80805. /**
  80806. * Gets the setp to use when using in "slider" mode
  80807. */
  80808. step?: number;
  80809. }
  80810. }
  80811. declare module BABYLON {
  80812. /**
  80813. * Class used to provide helper for timing
  80814. */
  80815. export class TimingTools {
  80816. /**
  80817. * Polyfill for setImmediate
  80818. * @param action defines the action to execute after the current execution block
  80819. */
  80820. static SetImmediate(action: () => void): void;
  80821. }
  80822. }
  80823. declare module BABYLON {
  80824. /**
  80825. * Class used to enable instatition of objects by class name
  80826. */
  80827. export class InstantiationTools {
  80828. /**
  80829. * Use this object to register external classes like custom textures or material
  80830. * to allow the laoders to instantiate them
  80831. */
  80832. static RegisteredExternalClasses: {
  80833. [key: string]: Object;
  80834. };
  80835. /**
  80836. * Tries to instantiate a new object from a given class name
  80837. * @param className defines the class name to instantiate
  80838. * @returns the new object or null if the system was not able to do the instantiation
  80839. */
  80840. static Instantiate(className: string): any;
  80841. }
  80842. }
  80843. declare module BABYLON {
  80844. /**
  80845. * Define options used to create a depth texture
  80846. */
  80847. export class DepthTextureCreationOptions {
  80848. /** Specifies whether or not a stencil should be allocated in the texture */
  80849. generateStencil?: boolean;
  80850. /** Specifies whether or not bilinear filtering is enable on the texture */
  80851. bilinearFiltering?: boolean;
  80852. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80853. comparisonFunction?: number;
  80854. /** Specifies if the created texture is a cube texture */
  80855. isCube?: boolean;
  80856. }
  80857. }
  80858. declare module BABYLON {
  80859. interface ThinEngine {
  80860. /**
  80861. * Creates a depth stencil cube texture.
  80862. * This is only available in WebGL 2.
  80863. * @param size The size of face edge in the cube texture.
  80864. * @param options The options defining the cube texture.
  80865. * @returns The cube texture
  80866. */
  80867. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80868. /**
  80869. * Creates a cube texture
  80870. * @param rootUrl defines the url where the files to load is located
  80871. * @param scene defines the current scene
  80872. * @param files defines the list of files to load (1 per face)
  80873. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80874. * @param onLoad defines an optional callback raised when the texture is loaded
  80875. * @param onError defines an optional callback raised if there is an issue to load the texture
  80876. * @param format defines the format of the data
  80877. * @param forcedExtension defines the extension to use to pick the right loader
  80878. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80879. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80880. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80881. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80882. * @returns the cube texture as an InternalTexture
  80883. */
  80884. 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;
  80885. /**
  80886. * Creates a cube texture
  80887. * @param rootUrl defines the url where the files to load is located
  80888. * @param scene defines the current scene
  80889. * @param files defines the list of files to load (1 per face)
  80890. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80891. * @param onLoad defines an optional callback raised when the texture is loaded
  80892. * @param onError defines an optional callback raised if there is an issue to load the texture
  80893. * @param format defines the format of the data
  80894. * @param forcedExtension defines the extension to use to pick the right loader
  80895. * @returns the cube texture as an InternalTexture
  80896. */
  80897. 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;
  80898. /**
  80899. * Creates a cube texture
  80900. * @param rootUrl defines the url where the files to load is located
  80901. * @param scene defines the current scene
  80902. * @param files defines the list of files to load (1 per face)
  80903. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80904. * @param onLoad defines an optional callback raised when the texture is loaded
  80905. * @param onError defines an optional callback raised if there is an issue to load the texture
  80906. * @param format defines the format of the data
  80907. * @param forcedExtension defines the extension to use to pick the right loader
  80908. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80909. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80910. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80911. * @returns the cube texture as an InternalTexture
  80912. */
  80913. 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;
  80914. /** @hidden */
  80915. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80916. /** @hidden */
  80917. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80918. /** @hidden */
  80919. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80920. /** @hidden */
  80921. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80922. /**
  80923. * @hidden
  80924. */
  80925. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80926. }
  80927. }
  80928. declare module BABYLON {
  80929. /**
  80930. * Class for creating a cube texture
  80931. */
  80932. export class CubeTexture extends BaseTexture {
  80933. private _delayedOnLoad;
  80934. /**
  80935. * Observable triggered once the texture has been loaded.
  80936. */
  80937. onLoadObservable: Observable<CubeTexture>;
  80938. /**
  80939. * The url of the texture
  80940. */
  80941. url: string;
  80942. /**
  80943. * Gets or sets the center of the bounding box associated with the cube texture.
  80944. * It must define where the camera used to render the texture was set
  80945. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80946. */
  80947. boundingBoxPosition: Vector3;
  80948. private _boundingBoxSize;
  80949. /**
  80950. * Gets or sets the size of the bounding box associated with the cube texture
  80951. * When defined, the cubemap will switch to local mode
  80952. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80953. * @example https://www.babylonjs-playground.com/#RNASML
  80954. */
  80955. set boundingBoxSize(value: Vector3);
  80956. /**
  80957. * Returns the bounding box size
  80958. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80959. */
  80960. get boundingBoxSize(): Vector3;
  80961. protected _rotationY: number;
  80962. /**
  80963. * Sets texture matrix rotation angle around Y axis in radians.
  80964. */
  80965. set rotationY(value: number);
  80966. /**
  80967. * Gets texture matrix rotation angle around Y axis radians.
  80968. */
  80969. get rotationY(): number;
  80970. /**
  80971. * Are mip maps generated for this texture or not.
  80972. */
  80973. get noMipmap(): boolean;
  80974. private _noMipmap;
  80975. private _files;
  80976. protected _forcedExtension: Nullable<string>;
  80977. private _extensions;
  80978. private _textureMatrix;
  80979. private _format;
  80980. private _createPolynomials;
  80981. /** @hidden */
  80982. _prefiltered: boolean;
  80983. /**
  80984. * Creates a cube texture from an array of image urls
  80985. * @param files defines an array of image urls
  80986. * @param scene defines the hosting scene
  80987. * @param noMipmap specifies if mip maps are not used
  80988. * @returns a cube texture
  80989. */
  80990. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80991. /**
  80992. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80993. * @param url defines the url of the prefiltered texture
  80994. * @param scene defines the scene the texture is attached to
  80995. * @param forcedExtension defines the extension of the file if different from the url
  80996. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80997. * @return the prefiltered texture
  80998. */
  80999. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81000. /**
  81001. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81002. * as prefiltered data.
  81003. * @param rootUrl defines the url of the texture or the root name of the six images
  81004. * @param scene defines the scene the texture is attached to
  81005. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81006. * @param noMipmap defines if mipmaps should be created or not
  81007. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81008. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81009. * @param onError defines a callback triggered in case of error during load
  81010. * @param format defines the internal format to use for the texture once loaded
  81011. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81012. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81013. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81014. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81015. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81016. * @return the cube texture
  81017. */
  81018. 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);
  81019. /**
  81020. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81021. */
  81022. get isPrefiltered(): boolean;
  81023. /**
  81024. * Get the current class name of the texture useful for serialization or dynamic coding.
  81025. * @returns "CubeTexture"
  81026. */
  81027. getClassName(): string;
  81028. /**
  81029. * Update the url (and optional buffer) of this texture if url was null during construction.
  81030. * @param url the url of the texture
  81031. * @param forcedExtension defines the extension to use
  81032. * @param onLoad callback called when the texture is loaded (defaults to null)
  81033. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81034. */
  81035. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81036. /**
  81037. * Delays loading of the cube texture
  81038. * @param forcedExtension defines the extension to use
  81039. */
  81040. delayLoad(forcedExtension?: string): void;
  81041. /**
  81042. * Returns the reflection texture matrix
  81043. * @returns the reflection texture matrix
  81044. */
  81045. getReflectionTextureMatrix(): Matrix;
  81046. /**
  81047. * Sets the reflection texture matrix
  81048. * @param value Reflection texture matrix
  81049. */
  81050. setReflectionTextureMatrix(value: Matrix): void;
  81051. /**
  81052. * Parses text to create a cube texture
  81053. * @param parsedTexture define the serialized text to read from
  81054. * @param scene defines the hosting scene
  81055. * @param rootUrl defines the root url of the cube texture
  81056. * @returns a cube texture
  81057. */
  81058. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81059. /**
  81060. * Makes a clone, or deep copy, of the cube texture
  81061. * @returns a new cube texture
  81062. */
  81063. clone(): CubeTexture;
  81064. }
  81065. }
  81066. declare module BABYLON {
  81067. /**
  81068. * Manages the defines for the Material
  81069. */
  81070. export class MaterialDefines {
  81071. /** @hidden */
  81072. protected _keys: string[];
  81073. private _isDirty;
  81074. /** @hidden */
  81075. _renderId: number;
  81076. /** @hidden */
  81077. _areLightsDirty: boolean;
  81078. /** @hidden */
  81079. _areLightsDisposed: boolean;
  81080. /** @hidden */
  81081. _areAttributesDirty: boolean;
  81082. /** @hidden */
  81083. _areTexturesDirty: boolean;
  81084. /** @hidden */
  81085. _areFresnelDirty: boolean;
  81086. /** @hidden */
  81087. _areMiscDirty: boolean;
  81088. /** @hidden */
  81089. _areImageProcessingDirty: boolean;
  81090. /** @hidden */
  81091. _normals: boolean;
  81092. /** @hidden */
  81093. _uvs: boolean;
  81094. /** @hidden */
  81095. _needNormals: boolean;
  81096. /** @hidden */
  81097. _needUVs: boolean;
  81098. [id: string]: any;
  81099. /**
  81100. * Specifies if the material needs to be re-calculated
  81101. */
  81102. get isDirty(): boolean;
  81103. /**
  81104. * Marks the material to indicate that it has been re-calculated
  81105. */
  81106. markAsProcessed(): void;
  81107. /**
  81108. * Marks the material to indicate that it needs to be re-calculated
  81109. */
  81110. markAsUnprocessed(): void;
  81111. /**
  81112. * Marks the material to indicate all of its defines need to be re-calculated
  81113. */
  81114. markAllAsDirty(): void;
  81115. /**
  81116. * Marks the material to indicate that image processing needs to be re-calculated
  81117. */
  81118. markAsImageProcessingDirty(): void;
  81119. /**
  81120. * Marks the material to indicate the lights need to be re-calculated
  81121. * @param disposed Defines whether the light is dirty due to dispose or not
  81122. */
  81123. markAsLightDirty(disposed?: boolean): void;
  81124. /**
  81125. * Marks the attribute state as changed
  81126. */
  81127. markAsAttributesDirty(): void;
  81128. /**
  81129. * Marks the texture state as changed
  81130. */
  81131. markAsTexturesDirty(): void;
  81132. /**
  81133. * Marks the fresnel state as changed
  81134. */
  81135. markAsFresnelDirty(): void;
  81136. /**
  81137. * Marks the misc state as changed
  81138. */
  81139. markAsMiscDirty(): void;
  81140. /**
  81141. * Rebuilds the material defines
  81142. */
  81143. rebuild(): void;
  81144. /**
  81145. * Specifies if two material defines are equal
  81146. * @param other - A material define instance to compare to
  81147. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81148. */
  81149. isEqual(other: MaterialDefines): boolean;
  81150. /**
  81151. * Clones this instance's defines to another instance
  81152. * @param other - material defines to clone values to
  81153. */
  81154. cloneTo(other: MaterialDefines): void;
  81155. /**
  81156. * Resets the material define values
  81157. */
  81158. reset(): void;
  81159. /**
  81160. * Converts the material define values to a string
  81161. * @returns - String of material define information
  81162. */
  81163. toString(): string;
  81164. }
  81165. }
  81166. declare module BABYLON {
  81167. /**
  81168. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81169. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81170. * 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;
  81171. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81172. */
  81173. export class ColorCurves {
  81174. private _dirty;
  81175. private _tempColor;
  81176. private _globalCurve;
  81177. private _highlightsCurve;
  81178. private _midtonesCurve;
  81179. private _shadowsCurve;
  81180. private _positiveCurve;
  81181. private _negativeCurve;
  81182. private _globalHue;
  81183. private _globalDensity;
  81184. private _globalSaturation;
  81185. private _globalExposure;
  81186. /**
  81187. * Gets the global Hue value.
  81188. * 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).
  81189. */
  81190. get globalHue(): number;
  81191. /**
  81192. * Sets the global Hue value.
  81193. * 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).
  81194. */
  81195. set globalHue(value: number);
  81196. /**
  81197. * Gets the global Density value.
  81198. * 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.
  81199. * Values less than zero provide a filter of opposite hue.
  81200. */
  81201. get globalDensity(): number;
  81202. /**
  81203. * Sets the global Density value.
  81204. * 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.
  81205. * Values less than zero provide a filter of opposite hue.
  81206. */
  81207. set globalDensity(value: number);
  81208. /**
  81209. * Gets the global Saturation value.
  81210. * 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.
  81211. */
  81212. get globalSaturation(): number;
  81213. /**
  81214. * Sets the global Saturation value.
  81215. * 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.
  81216. */
  81217. set globalSaturation(value: number);
  81218. /**
  81219. * Gets the global Exposure value.
  81220. * 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.
  81221. */
  81222. get globalExposure(): number;
  81223. /**
  81224. * Sets the global Exposure value.
  81225. * 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.
  81226. */
  81227. set globalExposure(value: number);
  81228. private _highlightsHue;
  81229. private _highlightsDensity;
  81230. private _highlightsSaturation;
  81231. private _highlightsExposure;
  81232. /**
  81233. * Gets the highlights Hue value.
  81234. * 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).
  81235. */
  81236. get highlightsHue(): number;
  81237. /**
  81238. * Sets the highlights Hue value.
  81239. * 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).
  81240. */
  81241. set highlightsHue(value: number);
  81242. /**
  81243. * Gets the highlights Density value.
  81244. * 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.
  81245. * Values less than zero provide a filter of opposite hue.
  81246. */
  81247. get highlightsDensity(): number;
  81248. /**
  81249. * Sets the highlights Density value.
  81250. * 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.
  81251. * Values less than zero provide a filter of opposite hue.
  81252. */
  81253. set highlightsDensity(value: number);
  81254. /**
  81255. * Gets the highlights Saturation value.
  81256. * 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.
  81257. */
  81258. get highlightsSaturation(): number;
  81259. /**
  81260. * Sets the highlights Saturation value.
  81261. * 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.
  81262. */
  81263. set highlightsSaturation(value: number);
  81264. /**
  81265. * Gets the highlights Exposure value.
  81266. * 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.
  81267. */
  81268. get highlightsExposure(): number;
  81269. /**
  81270. * Sets the highlights Exposure value.
  81271. * 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.
  81272. */
  81273. set highlightsExposure(value: number);
  81274. private _midtonesHue;
  81275. private _midtonesDensity;
  81276. private _midtonesSaturation;
  81277. private _midtonesExposure;
  81278. /**
  81279. * Gets the midtones Hue value.
  81280. * 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).
  81281. */
  81282. get midtonesHue(): number;
  81283. /**
  81284. * Sets the midtones Hue value.
  81285. * 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).
  81286. */
  81287. set midtonesHue(value: number);
  81288. /**
  81289. * Gets the midtones Density value.
  81290. * 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.
  81291. * Values less than zero provide a filter of opposite hue.
  81292. */
  81293. get midtonesDensity(): number;
  81294. /**
  81295. * Sets the midtones Density value.
  81296. * 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.
  81297. * Values less than zero provide a filter of opposite hue.
  81298. */
  81299. set midtonesDensity(value: number);
  81300. /**
  81301. * Gets the midtones Saturation value.
  81302. * 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.
  81303. */
  81304. get midtonesSaturation(): number;
  81305. /**
  81306. * Sets the midtones Saturation value.
  81307. * 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.
  81308. */
  81309. set midtonesSaturation(value: number);
  81310. /**
  81311. * Gets the midtones Exposure value.
  81312. * 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.
  81313. */
  81314. get midtonesExposure(): number;
  81315. /**
  81316. * Sets the midtones Exposure value.
  81317. * 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.
  81318. */
  81319. set midtonesExposure(value: number);
  81320. private _shadowsHue;
  81321. private _shadowsDensity;
  81322. private _shadowsSaturation;
  81323. private _shadowsExposure;
  81324. /**
  81325. * Gets the shadows Hue value.
  81326. * 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).
  81327. */
  81328. get shadowsHue(): number;
  81329. /**
  81330. * Sets the shadows Hue value.
  81331. * 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).
  81332. */
  81333. set shadowsHue(value: number);
  81334. /**
  81335. * Gets the shadows Density value.
  81336. * 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.
  81337. * Values less than zero provide a filter of opposite hue.
  81338. */
  81339. get shadowsDensity(): number;
  81340. /**
  81341. * Sets the shadows Density value.
  81342. * 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.
  81343. * Values less than zero provide a filter of opposite hue.
  81344. */
  81345. set shadowsDensity(value: number);
  81346. /**
  81347. * Gets the shadows Saturation value.
  81348. * 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.
  81349. */
  81350. get shadowsSaturation(): number;
  81351. /**
  81352. * Sets the shadows Saturation value.
  81353. * 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.
  81354. */
  81355. set shadowsSaturation(value: number);
  81356. /**
  81357. * Gets the shadows Exposure value.
  81358. * 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.
  81359. */
  81360. get shadowsExposure(): number;
  81361. /**
  81362. * Sets the shadows Exposure value.
  81363. * 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.
  81364. */
  81365. set shadowsExposure(value: number);
  81366. /**
  81367. * Returns the class name
  81368. * @returns The class name
  81369. */
  81370. getClassName(): string;
  81371. /**
  81372. * Binds the color curves to the shader.
  81373. * @param colorCurves The color curve to bind
  81374. * @param effect The effect to bind to
  81375. * @param positiveUniform The positive uniform shader parameter
  81376. * @param neutralUniform The neutral uniform shader parameter
  81377. * @param negativeUniform The negative uniform shader parameter
  81378. */
  81379. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81380. /**
  81381. * Prepare the list of uniforms associated with the ColorCurves effects.
  81382. * @param uniformsList The list of uniforms used in the effect
  81383. */
  81384. static PrepareUniforms(uniformsList: string[]): void;
  81385. /**
  81386. * Returns color grading data based on a hue, density, saturation and exposure value.
  81387. * @param filterHue The hue of the color filter.
  81388. * @param filterDensity The density of the color filter.
  81389. * @param saturation The saturation.
  81390. * @param exposure The exposure.
  81391. * @param result The result data container.
  81392. */
  81393. private getColorGradingDataToRef;
  81394. /**
  81395. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81396. * @param value The input slider value in range [-100,100].
  81397. * @returns Adjusted value.
  81398. */
  81399. private static applyColorGradingSliderNonlinear;
  81400. /**
  81401. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81402. * @param hue The hue (H) input.
  81403. * @param saturation The saturation (S) input.
  81404. * @param brightness The brightness (B) input.
  81405. * @result An RGBA color represented as Vector4.
  81406. */
  81407. private static fromHSBToRef;
  81408. /**
  81409. * Returns a value clamped between min and max
  81410. * @param value The value to clamp
  81411. * @param min The minimum of value
  81412. * @param max The maximum of value
  81413. * @returns The clamped value.
  81414. */
  81415. private static clamp;
  81416. /**
  81417. * Clones the current color curve instance.
  81418. * @return The cloned curves
  81419. */
  81420. clone(): ColorCurves;
  81421. /**
  81422. * Serializes the current color curve instance to a json representation.
  81423. * @return a JSON representation
  81424. */
  81425. serialize(): any;
  81426. /**
  81427. * Parses the color curve from a json representation.
  81428. * @param source the JSON source to parse
  81429. * @return The parsed curves
  81430. */
  81431. static Parse(source: any): ColorCurves;
  81432. }
  81433. }
  81434. declare module BABYLON {
  81435. /**
  81436. * Interface to follow in your material defines to integrate easily the
  81437. * Image proccessing functions.
  81438. * @hidden
  81439. */
  81440. export interface IImageProcessingConfigurationDefines {
  81441. IMAGEPROCESSING: boolean;
  81442. VIGNETTE: boolean;
  81443. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81444. VIGNETTEBLENDMODEOPAQUE: boolean;
  81445. TONEMAPPING: boolean;
  81446. TONEMAPPING_ACES: boolean;
  81447. CONTRAST: boolean;
  81448. EXPOSURE: boolean;
  81449. COLORCURVES: boolean;
  81450. COLORGRADING: boolean;
  81451. COLORGRADING3D: boolean;
  81452. SAMPLER3DGREENDEPTH: boolean;
  81453. SAMPLER3DBGRMAP: boolean;
  81454. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81455. }
  81456. /**
  81457. * @hidden
  81458. */
  81459. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81460. IMAGEPROCESSING: boolean;
  81461. VIGNETTE: boolean;
  81462. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81463. VIGNETTEBLENDMODEOPAQUE: boolean;
  81464. TONEMAPPING: boolean;
  81465. TONEMAPPING_ACES: boolean;
  81466. CONTRAST: boolean;
  81467. COLORCURVES: boolean;
  81468. COLORGRADING: boolean;
  81469. COLORGRADING3D: boolean;
  81470. SAMPLER3DGREENDEPTH: boolean;
  81471. SAMPLER3DBGRMAP: boolean;
  81472. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81473. EXPOSURE: boolean;
  81474. constructor();
  81475. }
  81476. /**
  81477. * This groups together the common properties used for image processing either in direct forward pass
  81478. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81479. * or not.
  81480. */
  81481. export class ImageProcessingConfiguration {
  81482. /**
  81483. * Default tone mapping applied in BabylonJS.
  81484. */
  81485. static readonly TONEMAPPING_STANDARD: number;
  81486. /**
  81487. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81488. * to other engines rendering to increase portability.
  81489. */
  81490. static readonly TONEMAPPING_ACES: number;
  81491. /**
  81492. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81493. */
  81494. colorCurves: Nullable<ColorCurves>;
  81495. private _colorCurvesEnabled;
  81496. /**
  81497. * Gets wether the color curves effect is enabled.
  81498. */
  81499. get colorCurvesEnabled(): boolean;
  81500. /**
  81501. * Sets wether the color curves effect is enabled.
  81502. */
  81503. set colorCurvesEnabled(value: boolean);
  81504. private _colorGradingTexture;
  81505. /**
  81506. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81507. */
  81508. get colorGradingTexture(): Nullable<BaseTexture>;
  81509. /**
  81510. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81511. */
  81512. set colorGradingTexture(value: Nullable<BaseTexture>);
  81513. private _colorGradingEnabled;
  81514. /**
  81515. * Gets wether the color grading effect is enabled.
  81516. */
  81517. get colorGradingEnabled(): boolean;
  81518. /**
  81519. * Sets wether the color grading effect is enabled.
  81520. */
  81521. set colorGradingEnabled(value: boolean);
  81522. private _colorGradingWithGreenDepth;
  81523. /**
  81524. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81525. */
  81526. get colorGradingWithGreenDepth(): boolean;
  81527. /**
  81528. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81529. */
  81530. set colorGradingWithGreenDepth(value: boolean);
  81531. private _colorGradingBGR;
  81532. /**
  81533. * Gets wether the color grading texture contains BGR values.
  81534. */
  81535. get colorGradingBGR(): boolean;
  81536. /**
  81537. * Sets wether the color grading texture contains BGR values.
  81538. */
  81539. set colorGradingBGR(value: boolean);
  81540. /** @hidden */
  81541. _exposure: number;
  81542. /**
  81543. * Gets the Exposure used in the effect.
  81544. */
  81545. get exposure(): number;
  81546. /**
  81547. * Sets the Exposure used in the effect.
  81548. */
  81549. set exposure(value: number);
  81550. private _toneMappingEnabled;
  81551. /**
  81552. * Gets wether the tone mapping effect is enabled.
  81553. */
  81554. get toneMappingEnabled(): boolean;
  81555. /**
  81556. * Sets wether the tone mapping effect is enabled.
  81557. */
  81558. set toneMappingEnabled(value: boolean);
  81559. private _toneMappingType;
  81560. /**
  81561. * Gets the type of tone mapping effect.
  81562. */
  81563. get toneMappingType(): number;
  81564. /**
  81565. * Sets the type of tone mapping effect used in BabylonJS.
  81566. */
  81567. set toneMappingType(value: number);
  81568. protected _contrast: number;
  81569. /**
  81570. * Gets the contrast used in the effect.
  81571. */
  81572. get contrast(): number;
  81573. /**
  81574. * Sets the contrast used in the effect.
  81575. */
  81576. set contrast(value: number);
  81577. /**
  81578. * Vignette stretch size.
  81579. */
  81580. vignetteStretch: number;
  81581. /**
  81582. * Vignette centre X Offset.
  81583. */
  81584. vignetteCentreX: number;
  81585. /**
  81586. * Vignette centre Y Offset.
  81587. */
  81588. vignetteCentreY: number;
  81589. /**
  81590. * Vignette weight or intensity of the vignette effect.
  81591. */
  81592. vignetteWeight: number;
  81593. /**
  81594. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81595. * if vignetteEnabled is set to true.
  81596. */
  81597. vignetteColor: Color4;
  81598. /**
  81599. * Camera field of view used by the Vignette effect.
  81600. */
  81601. vignetteCameraFov: number;
  81602. private _vignetteBlendMode;
  81603. /**
  81604. * Gets the vignette blend mode allowing different kind of effect.
  81605. */
  81606. get vignetteBlendMode(): number;
  81607. /**
  81608. * Sets the vignette blend mode allowing different kind of effect.
  81609. */
  81610. set vignetteBlendMode(value: number);
  81611. private _vignetteEnabled;
  81612. /**
  81613. * Gets wether the vignette effect is enabled.
  81614. */
  81615. get vignetteEnabled(): boolean;
  81616. /**
  81617. * Sets wether the vignette effect is enabled.
  81618. */
  81619. set vignetteEnabled(value: boolean);
  81620. private _applyByPostProcess;
  81621. /**
  81622. * Gets wether the image processing is applied through a post process or not.
  81623. */
  81624. get applyByPostProcess(): boolean;
  81625. /**
  81626. * Sets wether the image processing is applied through a post process or not.
  81627. */
  81628. set applyByPostProcess(value: boolean);
  81629. private _isEnabled;
  81630. /**
  81631. * Gets wether the image processing is enabled or not.
  81632. */
  81633. get isEnabled(): boolean;
  81634. /**
  81635. * Sets wether the image processing is enabled or not.
  81636. */
  81637. set isEnabled(value: boolean);
  81638. /**
  81639. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81640. */
  81641. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81642. /**
  81643. * Method called each time the image processing information changes requires to recompile the effect.
  81644. */
  81645. protected _updateParameters(): void;
  81646. /**
  81647. * Gets the current class name.
  81648. * @return "ImageProcessingConfiguration"
  81649. */
  81650. getClassName(): string;
  81651. /**
  81652. * Prepare the list of uniforms associated with the Image Processing effects.
  81653. * @param uniforms The list of uniforms used in the effect
  81654. * @param defines the list of defines currently in use
  81655. */
  81656. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81657. /**
  81658. * Prepare the list of samplers associated with the Image Processing effects.
  81659. * @param samplersList The list of uniforms used in the effect
  81660. * @param defines the list of defines currently in use
  81661. */
  81662. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81663. /**
  81664. * Prepare the list of defines associated to the shader.
  81665. * @param defines the list of defines to complete
  81666. * @param forPostProcess Define if we are currently in post process mode or not
  81667. */
  81668. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81669. /**
  81670. * Returns true if all the image processing information are ready.
  81671. * @returns True if ready, otherwise, false
  81672. */
  81673. isReady(): boolean;
  81674. /**
  81675. * Binds the image processing to the shader.
  81676. * @param effect The effect to bind to
  81677. * @param overrideAspectRatio Override the aspect ratio of the effect
  81678. */
  81679. bind(effect: Effect, overrideAspectRatio?: number): void;
  81680. /**
  81681. * Clones the current image processing instance.
  81682. * @return The cloned image processing
  81683. */
  81684. clone(): ImageProcessingConfiguration;
  81685. /**
  81686. * Serializes the current image processing instance to a json representation.
  81687. * @return a JSON representation
  81688. */
  81689. serialize(): any;
  81690. /**
  81691. * Parses the image processing from a json representation.
  81692. * @param source the JSON source to parse
  81693. * @return The parsed image processing
  81694. */
  81695. static Parse(source: any): ImageProcessingConfiguration;
  81696. private static _VIGNETTEMODE_MULTIPLY;
  81697. private static _VIGNETTEMODE_OPAQUE;
  81698. /**
  81699. * Used to apply the vignette as a mix with the pixel color.
  81700. */
  81701. static get VIGNETTEMODE_MULTIPLY(): number;
  81702. /**
  81703. * Used to apply the vignette as a replacement of the pixel color.
  81704. */
  81705. static get VIGNETTEMODE_OPAQUE(): number;
  81706. }
  81707. }
  81708. declare module BABYLON {
  81709. /** @hidden */
  81710. export var postprocessVertexShader: {
  81711. name: string;
  81712. shader: string;
  81713. };
  81714. }
  81715. declare module BABYLON {
  81716. interface ThinEngine {
  81717. /**
  81718. * Creates a new render target texture
  81719. * @param size defines the size of the texture
  81720. * @param options defines the options used to create the texture
  81721. * @returns a new render target texture stored in an InternalTexture
  81722. */
  81723. createRenderTargetTexture(size: number | {
  81724. width: number;
  81725. height: number;
  81726. layers?: number;
  81727. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81728. /**
  81729. * Creates a depth stencil texture.
  81730. * This is only available in WebGL 2 or with the depth texture extension available.
  81731. * @param size The size of face edge in the texture.
  81732. * @param options The options defining the texture.
  81733. * @returns The texture
  81734. */
  81735. createDepthStencilTexture(size: number | {
  81736. width: number;
  81737. height: number;
  81738. layers?: number;
  81739. }, options: DepthTextureCreationOptions): InternalTexture;
  81740. /** @hidden */
  81741. _createDepthStencilTexture(size: number | {
  81742. width: number;
  81743. height: number;
  81744. layers?: number;
  81745. }, options: DepthTextureCreationOptions): InternalTexture;
  81746. }
  81747. }
  81748. declare module BABYLON {
  81749. /** Defines supported spaces */
  81750. export enum Space {
  81751. /** Local (object) space */
  81752. LOCAL = 0,
  81753. /** World space */
  81754. WORLD = 1,
  81755. /** Bone space */
  81756. BONE = 2
  81757. }
  81758. /** Defines the 3 main axes */
  81759. export class Axis {
  81760. /** X axis */
  81761. static X: Vector3;
  81762. /** Y axis */
  81763. static Y: Vector3;
  81764. /** Z axis */
  81765. static Z: Vector3;
  81766. }
  81767. }
  81768. declare module BABYLON {
  81769. /**
  81770. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81771. * This is the base of the follow, arc rotate cameras and Free camera
  81772. * @see http://doc.babylonjs.com/features/cameras
  81773. */
  81774. export class TargetCamera extends Camera {
  81775. private static _RigCamTransformMatrix;
  81776. private static _TargetTransformMatrix;
  81777. private static _TargetFocalPoint;
  81778. /**
  81779. * Define the current direction the camera is moving to
  81780. */
  81781. cameraDirection: Vector3;
  81782. /**
  81783. * Define the current rotation the camera is rotating to
  81784. */
  81785. cameraRotation: Vector2;
  81786. /**
  81787. * When set, the up vector of the camera will be updated by the rotation of the camera
  81788. */
  81789. updateUpVectorFromRotation: boolean;
  81790. private _tmpQuaternion;
  81791. /**
  81792. * Define the current rotation of the camera
  81793. */
  81794. rotation: Vector3;
  81795. /**
  81796. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81797. */
  81798. rotationQuaternion: Quaternion;
  81799. /**
  81800. * Define the current speed of the camera
  81801. */
  81802. speed: number;
  81803. /**
  81804. * Add constraint to the camera to prevent it to move freely in all directions and
  81805. * around all axis.
  81806. */
  81807. noRotationConstraint: boolean;
  81808. /**
  81809. * Define the current target of the camera as an object or a position.
  81810. */
  81811. lockedTarget: any;
  81812. /** @hidden */
  81813. _currentTarget: Vector3;
  81814. /** @hidden */
  81815. _initialFocalDistance: number;
  81816. /** @hidden */
  81817. _viewMatrix: Matrix;
  81818. /** @hidden */
  81819. _camMatrix: Matrix;
  81820. /** @hidden */
  81821. _cameraTransformMatrix: Matrix;
  81822. /** @hidden */
  81823. _cameraRotationMatrix: Matrix;
  81824. /** @hidden */
  81825. _referencePoint: Vector3;
  81826. /** @hidden */
  81827. _transformedReferencePoint: Vector3;
  81828. protected _globalCurrentTarget: Vector3;
  81829. protected _globalCurrentUpVector: Vector3;
  81830. /** @hidden */
  81831. _reset: () => void;
  81832. private _defaultUp;
  81833. /**
  81834. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81835. * This is the base of the follow, arc rotate cameras and Free camera
  81836. * @see http://doc.babylonjs.com/features/cameras
  81837. * @param name Defines the name of the camera in the scene
  81838. * @param position Defines the start position of the camera in the scene
  81839. * @param scene Defines the scene the camera belongs to
  81840. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81841. */
  81842. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81843. /**
  81844. * Gets the position in front of the camera at a given distance.
  81845. * @param distance The distance from the camera we want the position to be
  81846. * @returns the position
  81847. */
  81848. getFrontPosition(distance: number): Vector3;
  81849. /** @hidden */
  81850. _getLockedTargetPosition(): Nullable<Vector3>;
  81851. private _storedPosition;
  81852. private _storedRotation;
  81853. private _storedRotationQuaternion;
  81854. /**
  81855. * Store current camera state of the camera (fov, position, rotation, etc..)
  81856. * @returns the camera
  81857. */
  81858. storeState(): Camera;
  81859. /**
  81860. * Restored camera state. You must call storeState() first
  81861. * @returns whether it was successful or not
  81862. * @hidden
  81863. */
  81864. _restoreStateValues(): boolean;
  81865. /** @hidden */
  81866. _initCache(): void;
  81867. /** @hidden */
  81868. _updateCache(ignoreParentClass?: boolean): void;
  81869. /** @hidden */
  81870. _isSynchronizedViewMatrix(): boolean;
  81871. /** @hidden */
  81872. _computeLocalCameraSpeed(): number;
  81873. /**
  81874. * Defines the target the camera should look at.
  81875. * @param target Defines the new target as a Vector or a mesh
  81876. */
  81877. setTarget(target: Vector3): void;
  81878. /**
  81879. * Return the current target position of the camera. This value is expressed in local space.
  81880. * @returns the target position
  81881. */
  81882. getTarget(): Vector3;
  81883. /** @hidden */
  81884. _decideIfNeedsToMove(): boolean;
  81885. /** @hidden */
  81886. _updatePosition(): void;
  81887. /** @hidden */
  81888. _checkInputs(): void;
  81889. protected _updateCameraRotationMatrix(): void;
  81890. /**
  81891. * 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)
  81892. * @returns the current camera
  81893. */
  81894. private _rotateUpVectorWithCameraRotationMatrix;
  81895. private _cachedRotationZ;
  81896. private _cachedQuaternionRotationZ;
  81897. /** @hidden */
  81898. _getViewMatrix(): Matrix;
  81899. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81900. /**
  81901. * @hidden
  81902. */
  81903. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81904. /**
  81905. * @hidden
  81906. */
  81907. _updateRigCameras(): void;
  81908. private _getRigCamPositionAndTarget;
  81909. /**
  81910. * Gets the current object class name.
  81911. * @return the class name
  81912. */
  81913. getClassName(): string;
  81914. }
  81915. }
  81916. declare module BABYLON {
  81917. /**
  81918. * Gather the list of keyboard event types as constants.
  81919. */
  81920. export class KeyboardEventTypes {
  81921. /**
  81922. * The keydown event is fired when a key becomes active (pressed).
  81923. */
  81924. static readonly KEYDOWN: number;
  81925. /**
  81926. * The keyup event is fired when a key has been released.
  81927. */
  81928. static readonly KEYUP: number;
  81929. }
  81930. /**
  81931. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81932. */
  81933. export class KeyboardInfo {
  81934. /**
  81935. * Defines the type of event (KeyboardEventTypes)
  81936. */
  81937. type: number;
  81938. /**
  81939. * Defines the related dom event
  81940. */
  81941. event: KeyboardEvent;
  81942. /**
  81943. * Instantiates a new keyboard info.
  81944. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81945. * @param type Defines the type of event (KeyboardEventTypes)
  81946. * @param event Defines the related dom event
  81947. */
  81948. constructor(
  81949. /**
  81950. * Defines the type of event (KeyboardEventTypes)
  81951. */
  81952. type: number,
  81953. /**
  81954. * Defines the related dom event
  81955. */
  81956. event: KeyboardEvent);
  81957. }
  81958. /**
  81959. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81960. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81961. */
  81962. export class KeyboardInfoPre extends KeyboardInfo {
  81963. /**
  81964. * Defines the type of event (KeyboardEventTypes)
  81965. */
  81966. type: number;
  81967. /**
  81968. * Defines the related dom event
  81969. */
  81970. event: KeyboardEvent;
  81971. /**
  81972. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81973. */
  81974. skipOnPointerObservable: boolean;
  81975. /**
  81976. * Instantiates a new keyboard pre info.
  81977. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81978. * @param type Defines the type of event (KeyboardEventTypes)
  81979. * @param event Defines the related dom event
  81980. */
  81981. constructor(
  81982. /**
  81983. * Defines the type of event (KeyboardEventTypes)
  81984. */
  81985. type: number,
  81986. /**
  81987. * Defines the related dom event
  81988. */
  81989. event: KeyboardEvent);
  81990. }
  81991. }
  81992. declare module BABYLON {
  81993. /**
  81994. * Manage the keyboard inputs to control the movement of a free camera.
  81995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81996. */
  81997. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81998. /**
  81999. * Defines the camera the input is attached to.
  82000. */
  82001. camera: FreeCamera;
  82002. /**
  82003. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82004. */
  82005. keysUp: number[];
  82006. /**
  82007. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82008. */
  82009. keysDown: number[];
  82010. /**
  82011. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82012. */
  82013. keysLeft: number[];
  82014. /**
  82015. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82016. */
  82017. keysRight: number[];
  82018. private _keys;
  82019. private _onCanvasBlurObserver;
  82020. private _onKeyboardObserver;
  82021. private _engine;
  82022. private _scene;
  82023. /**
  82024. * Attach the input controls to a specific dom element to get the input from.
  82025. * @param element Defines the element the controls should be listened from
  82026. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82027. */
  82028. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82029. /**
  82030. * Detach the current controls from the specified dom element.
  82031. * @param element Defines the element to stop listening the inputs from
  82032. */
  82033. detachControl(element: Nullable<HTMLElement>): void;
  82034. /**
  82035. * Update the current camera state depending on the inputs that have been used this frame.
  82036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82037. */
  82038. checkInputs(): void;
  82039. /**
  82040. * Gets the class name of the current intput.
  82041. * @returns the class name
  82042. */
  82043. getClassName(): string;
  82044. /** @hidden */
  82045. _onLostFocus(): void;
  82046. /**
  82047. * Get the friendly name associated with the input class.
  82048. * @returns the input friendly name
  82049. */
  82050. getSimpleName(): string;
  82051. }
  82052. }
  82053. declare module BABYLON {
  82054. /**
  82055. * Interface describing all the common properties and methods a shadow light needs to implement.
  82056. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82057. * as well as binding the different shadow properties to the effects.
  82058. */
  82059. export interface IShadowLight extends Light {
  82060. /**
  82061. * The light id in the scene (used in scene.findLighById for instance)
  82062. */
  82063. id: string;
  82064. /**
  82065. * The position the shdow will be casted from.
  82066. */
  82067. position: Vector3;
  82068. /**
  82069. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82070. */
  82071. direction: Vector3;
  82072. /**
  82073. * The transformed position. Position of the light in world space taking parenting in account.
  82074. */
  82075. transformedPosition: Vector3;
  82076. /**
  82077. * The transformed direction. Direction of the light in world space taking parenting in account.
  82078. */
  82079. transformedDirection: Vector3;
  82080. /**
  82081. * The friendly name of the light in the scene.
  82082. */
  82083. name: string;
  82084. /**
  82085. * Defines the shadow projection clipping minimum z value.
  82086. */
  82087. shadowMinZ: number;
  82088. /**
  82089. * Defines the shadow projection clipping maximum z value.
  82090. */
  82091. shadowMaxZ: number;
  82092. /**
  82093. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82094. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82095. */
  82096. computeTransformedInformation(): boolean;
  82097. /**
  82098. * Gets the scene the light belongs to.
  82099. * @returns The scene
  82100. */
  82101. getScene(): Scene;
  82102. /**
  82103. * Callback defining a custom Projection Matrix Builder.
  82104. * This can be used to override the default projection matrix computation.
  82105. */
  82106. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82107. /**
  82108. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82109. * @param matrix The materix to updated with the projection information
  82110. * @param viewMatrix The transform matrix of the light
  82111. * @param renderList The list of mesh to render in the map
  82112. * @returns The current light
  82113. */
  82114. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82115. /**
  82116. * Gets the current depth scale used in ESM.
  82117. * @returns The scale
  82118. */
  82119. getDepthScale(): number;
  82120. /**
  82121. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82122. * @returns true if a cube texture needs to be use
  82123. */
  82124. needCube(): boolean;
  82125. /**
  82126. * Detects if the projection matrix requires to be recomputed this frame.
  82127. * @returns true if it requires to be recomputed otherwise, false.
  82128. */
  82129. needProjectionMatrixCompute(): boolean;
  82130. /**
  82131. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82132. */
  82133. forceProjectionMatrixCompute(): void;
  82134. /**
  82135. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82136. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82137. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82138. */
  82139. getShadowDirection(faceIndex?: number): Vector3;
  82140. /**
  82141. * Gets the minZ used for shadow according to both the scene and the light.
  82142. * @param activeCamera The camera we are returning the min for
  82143. * @returns the depth min z
  82144. */
  82145. getDepthMinZ(activeCamera: Camera): number;
  82146. /**
  82147. * Gets the maxZ used for shadow according to both the scene and the light.
  82148. * @param activeCamera The camera we are returning the max for
  82149. * @returns the depth max z
  82150. */
  82151. getDepthMaxZ(activeCamera: Camera): number;
  82152. }
  82153. /**
  82154. * Base implementation IShadowLight
  82155. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82156. */
  82157. export abstract class ShadowLight extends Light implements IShadowLight {
  82158. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82159. protected _position: Vector3;
  82160. protected _setPosition(value: Vector3): void;
  82161. /**
  82162. * Sets the position the shadow will be casted from. Also use as the light position for both
  82163. * point and spot lights.
  82164. */
  82165. get position(): Vector3;
  82166. /**
  82167. * Sets the position the shadow will be casted from. Also use as the light position for both
  82168. * point and spot lights.
  82169. */
  82170. set position(value: Vector3);
  82171. protected _direction: Vector3;
  82172. protected _setDirection(value: Vector3): void;
  82173. /**
  82174. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82175. * Also use as the light direction on spot and directional lights.
  82176. */
  82177. get direction(): Vector3;
  82178. /**
  82179. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82180. * Also use as the light direction on spot and directional lights.
  82181. */
  82182. set direction(value: Vector3);
  82183. protected _shadowMinZ: number;
  82184. /**
  82185. * Gets the shadow projection clipping minimum z value.
  82186. */
  82187. get shadowMinZ(): number;
  82188. /**
  82189. * Sets the shadow projection clipping minimum z value.
  82190. */
  82191. set shadowMinZ(value: number);
  82192. protected _shadowMaxZ: number;
  82193. /**
  82194. * Sets the shadow projection clipping maximum z value.
  82195. */
  82196. get shadowMaxZ(): number;
  82197. /**
  82198. * Gets the shadow projection clipping maximum z value.
  82199. */
  82200. set shadowMaxZ(value: number);
  82201. /**
  82202. * Callback defining a custom Projection Matrix Builder.
  82203. * This can be used to override the default projection matrix computation.
  82204. */
  82205. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82206. /**
  82207. * The transformed position. Position of the light in world space taking parenting in account.
  82208. */
  82209. transformedPosition: Vector3;
  82210. /**
  82211. * The transformed direction. Direction of the light in world space taking parenting in account.
  82212. */
  82213. transformedDirection: Vector3;
  82214. private _needProjectionMatrixCompute;
  82215. /**
  82216. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82217. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82218. */
  82219. computeTransformedInformation(): boolean;
  82220. /**
  82221. * Return the depth scale used for the shadow map.
  82222. * @returns the depth scale.
  82223. */
  82224. getDepthScale(): number;
  82225. /**
  82226. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82227. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82228. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82229. */
  82230. getShadowDirection(faceIndex?: number): Vector3;
  82231. /**
  82232. * Returns the ShadowLight absolute position in the World.
  82233. * @returns the position vector in world space
  82234. */
  82235. getAbsolutePosition(): Vector3;
  82236. /**
  82237. * Sets the ShadowLight direction toward the passed target.
  82238. * @param target The point to target in local space
  82239. * @returns the updated ShadowLight direction
  82240. */
  82241. setDirectionToTarget(target: Vector3): Vector3;
  82242. /**
  82243. * Returns the light rotation in euler definition.
  82244. * @returns the x y z rotation in local space.
  82245. */
  82246. getRotation(): Vector3;
  82247. /**
  82248. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82249. * @returns true if a cube texture needs to be use
  82250. */
  82251. needCube(): boolean;
  82252. /**
  82253. * Detects if the projection matrix requires to be recomputed this frame.
  82254. * @returns true if it requires to be recomputed otherwise, false.
  82255. */
  82256. needProjectionMatrixCompute(): boolean;
  82257. /**
  82258. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82259. */
  82260. forceProjectionMatrixCompute(): void;
  82261. /** @hidden */
  82262. _initCache(): void;
  82263. /** @hidden */
  82264. _isSynchronized(): boolean;
  82265. /**
  82266. * Computes the world matrix of the node
  82267. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82268. * @returns the world matrix
  82269. */
  82270. computeWorldMatrix(force?: boolean): Matrix;
  82271. /**
  82272. * Gets the minZ used for shadow according to both the scene and the light.
  82273. * @param activeCamera The camera we are returning the min for
  82274. * @returns the depth min z
  82275. */
  82276. getDepthMinZ(activeCamera: Camera): number;
  82277. /**
  82278. * Gets the maxZ used for shadow according to both the scene and the light.
  82279. * @param activeCamera The camera we are returning the max for
  82280. * @returns the depth max z
  82281. */
  82282. getDepthMaxZ(activeCamera: Camera): number;
  82283. /**
  82284. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82285. * @param matrix The materix to updated with the projection information
  82286. * @param viewMatrix The transform matrix of the light
  82287. * @param renderList The list of mesh to render in the map
  82288. * @returns The current light
  82289. */
  82290. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82291. }
  82292. }
  82293. declare module BABYLON {
  82294. /**
  82295. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82296. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82297. */
  82298. export class EffectFallbacks implements IEffectFallbacks {
  82299. private _defines;
  82300. private _currentRank;
  82301. private _maxRank;
  82302. private _mesh;
  82303. /**
  82304. * Removes the fallback from the bound mesh.
  82305. */
  82306. unBindMesh(): void;
  82307. /**
  82308. * Adds a fallback on the specified property.
  82309. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82310. * @param define The name of the define in the shader
  82311. */
  82312. addFallback(rank: number, define: string): void;
  82313. /**
  82314. * Sets the mesh to use CPU skinning when needing to fallback.
  82315. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82316. * @param mesh The mesh to use the fallbacks.
  82317. */
  82318. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82319. /**
  82320. * Checks to see if more fallbacks are still availible.
  82321. */
  82322. get hasMoreFallbacks(): boolean;
  82323. /**
  82324. * Removes the defines that should be removed when falling back.
  82325. * @param currentDefines defines the current define statements for the shader.
  82326. * @param effect defines the current effect we try to compile
  82327. * @returns The resulting defines with defines of the current rank removed.
  82328. */
  82329. reduce(currentDefines: string, effect: Effect): string;
  82330. }
  82331. }
  82332. declare module BABYLON {
  82333. /**
  82334. * "Static Class" containing the most commonly used helper while dealing with material for
  82335. * rendering purpose.
  82336. *
  82337. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82338. *
  82339. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82340. */
  82341. export class MaterialHelper {
  82342. /**
  82343. * Bind the current view position to an effect.
  82344. * @param effect The effect to be bound
  82345. * @param scene The scene the eyes position is used from
  82346. */
  82347. static BindEyePosition(effect: Effect, scene: Scene): void;
  82348. /**
  82349. * Helps preparing the defines values about the UVs in used in the effect.
  82350. * UVs are shared as much as we can accross channels in the shaders.
  82351. * @param texture The texture we are preparing the UVs for
  82352. * @param defines The defines to update
  82353. * @param key The channel key "diffuse", "specular"... used in the shader
  82354. */
  82355. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82356. /**
  82357. * Binds a texture matrix value to its corrsponding uniform
  82358. * @param texture The texture to bind the matrix for
  82359. * @param uniformBuffer The uniform buffer receivin the data
  82360. * @param key The channel key "diffuse", "specular"... used in the shader
  82361. */
  82362. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82363. /**
  82364. * Gets the current status of the fog (should it be enabled?)
  82365. * @param mesh defines the mesh to evaluate for fog support
  82366. * @param scene defines the hosting scene
  82367. * @returns true if fog must be enabled
  82368. */
  82369. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82370. /**
  82371. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82372. * @param mesh defines the current mesh
  82373. * @param scene defines the current scene
  82374. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82375. * @param pointsCloud defines if point cloud rendering has to be turned on
  82376. * @param fogEnabled defines if fog has to be turned on
  82377. * @param alphaTest defines if alpha testing has to be turned on
  82378. * @param defines defines the current list of defines
  82379. */
  82380. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82381. /**
  82382. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82383. * @param scene defines the current scene
  82384. * @param engine defines the current engine
  82385. * @param defines specifies the list of active defines
  82386. * @param useInstances defines if instances have to be turned on
  82387. * @param useClipPlane defines if clip plane have to be turned on
  82388. */
  82389. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82390. /**
  82391. * Prepares the defines for bones
  82392. * @param mesh The mesh containing the geometry data we will draw
  82393. * @param defines The defines to update
  82394. */
  82395. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82396. /**
  82397. * Prepares the defines for morph targets
  82398. * @param mesh The mesh containing the geometry data we will draw
  82399. * @param defines The defines to update
  82400. */
  82401. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82402. /**
  82403. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82404. * @param mesh The mesh containing the geometry data we will draw
  82405. * @param defines The defines to update
  82406. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82407. * @param useBones Precise whether bones should be used or not (override mesh info)
  82408. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82409. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82410. * @returns false if defines are considered not dirty and have not been checked
  82411. */
  82412. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82413. /**
  82414. * Prepares the defines related to multiview
  82415. * @param scene The scene we are intending to draw
  82416. * @param defines The defines to update
  82417. */
  82418. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82419. /**
  82420. * Prepares the defines related to the light information passed in parameter
  82421. * @param scene The scene we are intending to draw
  82422. * @param mesh The mesh the effect is compiling for
  82423. * @param light The light the effect is compiling for
  82424. * @param lightIndex The index of the light
  82425. * @param defines The defines to update
  82426. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82427. * @param state Defines the current state regarding what is needed (normals, etc...)
  82428. */
  82429. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82430. needNormals: boolean;
  82431. needRebuild: boolean;
  82432. shadowEnabled: boolean;
  82433. specularEnabled: boolean;
  82434. lightmapMode: boolean;
  82435. }): void;
  82436. /**
  82437. * Prepares the defines related to the light information passed in parameter
  82438. * @param scene The scene we are intending to draw
  82439. * @param mesh The mesh the effect is compiling for
  82440. * @param defines The defines to update
  82441. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82442. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82443. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82444. * @returns true if normals will be required for the rest of the effect
  82445. */
  82446. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82447. /**
  82448. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82449. * @param lightIndex defines the light index
  82450. * @param uniformsList The uniform list
  82451. * @param samplersList The sampler list
  82452. * @param projectedLightTexture defines if projected texture must be used
  82453. * @param uniformBuffersList defines an optional list of uniform buffers
  82454. */
  82455. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82456. /**
  82457. * Prepares the uniforms and samplers list to be used in the effect
  82458. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82459. * @param samplersList The sampler list
  82460. * @param defines The defines helping in the list generation
  82461. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82462. */
  82463. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82464. /**
  82465. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82466. * @param defines The defines to update while falling back
  82467. * @param fallbacks The authorized effect fallbacks
  82468. * @param maxSimultaneousLights The maximum number of lights allowed
  82469. * @param rank the current rank of the Effect
  82470. * @returns The newly affected rank
  82471. */
  82472. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82473. private static _TmpMorphInfluencers;
  82474. /**
  82475. * Prepares the list of attributes required for morph targets according to the effect defines.
  82476. * @param attribs The current list of supported attribs
  82477. * @param mesh The mesh to prepare the morph targets attributes for
  82478. * @param influencers The number of influencers
  82479. */
  82480. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82481. /**
  82482. * Prepares the list of attributes required for morph targets according to the effect defines.
  82483. * @param attribs The current list of supported attribs
  82484. * @param mesh The mesh to prepare the morph targets attributes for
  82485. * @param defines The current Defines of the effect
  82486. */
  82487. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82488. /**
  82489. * Prepares the list of attributes required for bones according to the effect defines.
  82490. * @param attribs The current list of supported attribs
  82491. * @param mesh The mesh to prepare the bones attributes for
  82492. * @param defines The current Defines of the effect
  82493. * @param fallbacks The current efffect fallback strategy
  82494. */
  82495. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82496. /**
  82497. * Check and prepare the list of attributes required for instances according to the effect defines.
  82498. * @param attribs The current list of supported attribs
  82499. * @param defines The current MaterialDefines of the effect
  82500. */
  82501. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82502. /**
  82503. * Add the list of attributes required for instances to the attribs array.
  82504. * @param attribs The current list of supported attribs
  82505. */
  82506. static PushAttributesForInstances(attribs: string[]): void;
  82507. /**
  82508. * Binds the light information to the effect.
  82509. * @param light The light containing the generator
  82510. * @param effect The effect we are binding the data to
  82511. * @param lightIndex The light index in the effect used to render
  82512. */
  82513. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82514. /**
  82515. * Binds the lights information from the scene to the effect for the given mesh.
  82516. * @param light Light to bind
  82517. * @param lightIndex Light index
  82518. * @param scene The scene where the light belongs to
  82519. * @param effect The effect we are binding the data to
  82520. * @param useSpecular Defines if specular is supported
  82521. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82522. */
  82523. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82524. /**
  82525. * Binds the lights 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 defines The generated defines for the effect
  82530. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82531. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82532. */
  82533. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82534. private static _tempFogColor;
  82535. /**
  82536. * Binds the fog information from the scene to the effect for the given mesh.
  82537. * @param scene The scene the lights belongs to
  82538. * @param mesh The mesh we are binding the information to render
  82539. * @param effect The effect we are binding the data to
  82540. * @param linearSpace Defines if the fog effect is applied in linear space
  82541. */
  82542. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82543. /**
  82544. * Binds the bones information from the mesh to the effect.
  82545. * @param mesh The mesh we are binding the information to render
  82546. * @param effect The effect we are binding the data to
  82547. */
  82548. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82549. /**
  82550. * Binds the morph targets information from the mesh to the effect.
  82551. * @param abstractMesh The mesh we are binding the information to render
  82552. * @param effect The effect we are binding the data to
  82553. */
  82554. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82555. /**
  82556. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82557. * @param defines The generated defines used in the effect
  82558. * @param effect The effect we are binding the data to
  82559. * @param scene The scene we are willing to render with logarithmic scale for
  82560. */
  82561. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82562. /**
  82563. * Binds the clip plane information from the scene to the effect.
  82564. * @param scene The scene the clip plane information are extracted from
  82565. * @param effect The effect we are binding the data to
  82566. */
  82567. static BindClipPlane(effect: Effect, scene: Scene): void;
  82568. }
  82569. }
  82570. declare module BABYLON {
  82571. /** @hidden */
  82572. export var packingFunctions: {
  82573. name: string;
  82574. shader: string;
  82575. };
  82576. }
  82577. declare module BABYLON {
  82578. /** @hidden */
  82579. export var clipPlaneFragmentDeclaration: {
  82580. name: string;
  82581. shader: string;
  82582. };
  82583. }
  82584. declare module BABYLON {
  82585. /** @hidden */
  82586. export var clipPlaneFragment: {
  82587. name: string;
  82588. shader: string;
  82589. };
  82590. }
  82591. declare module BABYLON {
  82592. /** @hidden */
  82593. export var shadowMapPixelShader: {
  82594. name: string;
  82595. shader: string;
  82596. };
  82597. }
  82598. declare module BABYLON {
  82599. /** @hidden */
  82600. export var bonesDeclaration: {
  82601. name: string;
  82602. shader: string;
  82603. };
  82604. }
  82605. declare module BABYLON {
  82606. /** @hidden */
  82607. export var morphTargetsVertexGlobalDeclaration: {
  82608. name: string;
  82609. shader: string;
  82610. };
  82611. }
  82612. declare module BABYLON {
  82613. /** @hidden */
  82614. export var morphTargetsVertexDeclaration: {
  82615. name: string;
  82616. shader: string;
  82617. };
  82618. }
  82619. declare module BABYLON {
  82620. /** @hidden */
  82621. export var instancesDeclaration: {
  82622. name: string;
  82623. shader: string;
  82624. };
  82625. }
  82626. declare module BABYLON {
  82627. /** @hidden */
  82628. export var helperFunctions: {
  82629. name: string;
  82630. shader: string;
  82631. };
  82632. }
  82633. declare module BABYLON {
  82634. /** @hidden */
  82635. export var clipPlaneVertexDeclaration: {
  82636. name: string;
  82637. shader: string;
  82638. };
  82639. }
  82640. declare module BABYLON {
  82641. /** @hidden */
  82642. export var morphTargetsVertex: {
  82643. name: string;
  82644. shader: string;
  82645. };
  82646. }
  82647. declare module BABYLON {
  82648. /** @hidden */
  82649. export var instancesVertex: {
  82650. name: string;
  82651. shader: string;
  82652. };
  82653. }
  82654. declare module BABYLON {
  82655. /** @hidden */
  82656. export var bonesVertex: {
  82657. name: string;
  82658. shader: string;
  82659. };
  82660. }
  82661. declare module BABYLON {
  82662. /** @hidden */
  82663. export var clipPlaneVertex: {
  82664. name: string;
  82665. shader: string;
  82666. };
  82667. }
  82668. declare module BABYLON {
  82669. /** @hidden */
  82670. export var shadowMapVertexShader: {
  82671. name: string;
  82672. shader: string;
  82673. };
  82674. }
  82675. declare module BABYLON {
  82676. /** @hidden */
  82677. export var depthBoxBlurPixelShader: {
  82678. name: string;
  82679. shader: string;
  82680. };
  82681. }
  82682. declare module BABYLON {
  82683. /**
  82684. * Class representing a ray with position and direction
  82685. */
  82686. export class Ray {
  82687. /** origin point */
  82688. origin: Vector3;
  82689. /** direction */
  82690. direction: Vector3;
  82691. /** length of the ray */
  82692. length: number;
  82693. private static readonly TmpVector3;
  82694. private _tmpRay;
  82695. /**
  82696. * Creates a new ray
  82697. * @param origin origin point
  82698. * @param direction direction
  82699. * @param length length of the ray
  82700. */
  82701. constructor(
  82702. /** origin point */
  82703. origin: Vector3,
  82704. /** direction */
  82705. direction: Vector3,
  82706. /** length of the ray */
  82707. length?: number);
  82708. /**
  82709. * Checks if the ray intersects a box
  82710. * @param minimum bound of the box
  82711. * @param maximum bound of the box
  82712. * @param intersectionTreshold extra extend to be added to the box in all direction
  82713. * @returns if the box was hit
  82714. */
  82715. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82716. /**
  82717. * Checks if the ray intersects a box
  82718. * @param box the bounding box to check
  82719. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82720. * @returns if the box was hit
  82721. */
  82722. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82723. /**
  82724. * If the ray hits a sphere
  82725. * @param sphere the bounding sphere to check
  82726. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82727. * @returns true if it hits the sphere
  82728. */
  82729. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82730. /**
  82731. * If the ray hits a triange
  82732. * @param vertex0 triangle vertex
  82733. * @param vertex1 triangle vertex
  82734. * @param vertex2 triangle vertex
  82735. * @returns intersection information if hit
  82736. */
  82737. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82738. /**
  82739. * Checks if ray intersects a plane
  82740. * @param plane the plane to check
  82741. * @returns the distance away it was hit
  82742. */
  82743. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82744. /**
  82745. * Calculate the intercept of a ray on a given axis
  82746. * @param axis to check 'x' | 'y' | 'z'
  82747. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82748. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82749. */
  82750. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82751. /**
  82752. * Checks if ray intersects a mesh
  82753. * @param mesh the mesh to check
  82754. * @param fastCheck if only the bounding box should checked
  82755. * @returns picking info of the intersecton
  82756. */
  82757. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82758. /**
  82759. * Checks if ray intersects a mesh
  82760. * @param meshes the meshes to check
  82761. * @param fastCheck if only the bounding box should checked
  82762. * @param results array to store result in
  82763. * @returns Array of picking infos
  82764. */
  82765. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82766. private _comparePickingInfo;
  82767. private static smallnum;
  82768. private static rayl;
  82769. /**
  82770. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82771. * @param sega the first point of the segment to test the intersection against
  82772. * @param segb the second point of the segment to test the intersection against
  82773. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82774. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82775. */
  82776. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82777. /**
  82778. * Update the ray from viewport position
  82779. * @param x position
  82780. * @param y y position
  82781. * @param viewportWidth viewport width
  82782. * @param viewportHeight viewport height
  82783. * @param world world matrix
  82784. * @param view view matrix
  82785. * @param projection projection matrix
  82786. * @returns this ray updated
  82787. */
  82788. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82789. /**
  82790. * Creates a ray with origin and direction of 0,0,0
  82791. * @returns the new ray
  82792. */
  82793. static Zero(): Ray;
  82794. /**
  82795. * Creates a new ray from screen space and viewport
  82796. * @param x position
  82797. * @param y y position
  82798. * @param viewportWidth viewport width
  82799. * @param viewportHeight viewport height
  82800. * @param world world matrix
  82801. * @param view view matrix
  82802. * @param projection projection matrix
  82803. * @returns new ray
  82804. */
  82805. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82806. /**
  82807. * 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
  82808. * transformed to the given world matrix.
  82809. * @param origin The origin point
  82810. * @param end The end point
  82811. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82812. * @returns the new ray
  82813. */
  82814. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82815. /**
  82816. * Transforms a ray by a matrix
  82817. * @param ray ray to transform
  82818. * @param matrix matrix to apply
  82819. * @returns the resulting new ray
  82820. */
  82821. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82822. /**
  82823. * Transforms a ray by a matrix
  82824. * @param ray ray to transform
  82825. * @param matrix matrix to apply
  82826. * @param result ray to store result in
  82827. */
  82828. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82829. /**
  82830. * Unproject a ray from screen space to object space
  82831. * @param sourceX defines the screen space x coordinate to use
  82832. * @param sourceY defines the screen space y coordinate to use
  82833. * @param viewportWidth defines the current width of the viewport
  82834. * @param viewportHeight defines the current height of the viewport
  82835. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82836. * @param view defines the view matrix to use
  82837. * @param projection defines the projection matrix to use
  82838. */
  82839. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82840. }
  82841. /**
  82842. * Type used to define predicate used to select faces when a mesh intersection is detected
  82843. */
  82844. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82845. interface Scene {
  82846. /** @hidden */
  82847. _tempPickingRay: Nullable<Ray>;
  82848. /** @hidden */
  82849. _cachedRayForTransform: Ray;
  82850. /** @hidden */
  82851. _pickWithRayInverseMatrix: Matrix;
  82852. /** @hidden */
  82853. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82854. /** @hidden */
  82855. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82856. }
  82857. }
  82858. declare module BABYLON {
  82859. /**
  82860. * Groups all the scene component constants in one place to ease maintenance.
  82861. * @hidden
  82862. */
  82863. export class SceneComponentConstants {
  82864. static readonly NAME_EFFECTLAYER: string;
  82865. static readonly NAME_LAYER: string;
  82866. static readonly NAME_LENSFLARESYSTEM: string;
  82867. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82868. static readonly NAME_PARTICLESYSTEM: string;
  82869. static readonly NAME_GAMEPAD: string;
  82870. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82871. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82872. static readonly NAME_DEPTHRENDERER: string;
  82873. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82874. static readonly NAME_SPRITE: string;
  82875. static readonly NAME_OUTLINERENDERER: string;
  82876. static readonly NAME_PROCEDURALTEXTURE: string;
  82877. static readonly NAME_SHADOWGENERATOR: string;
  82878. static readonly NAME_OCTREE: string;
  82879. static readonly NAME_PHYSICSENGINE: string;
  82880. static readonly NAME_AUDIO: string;
  82881. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82882. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82883. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82884. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82885. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82886. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82887. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82888. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82889. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82890. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82891. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82892. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82893. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82894. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82895. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82896. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82897. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82898. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82899. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82900. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82901. static readonly STEP_AFTERRENDER_AUDIO: number;
  82902. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82903. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82904. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82905. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82906. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82907. static readonly STEP_POINTERMOVE_SPRITE: number;
  82908. static readonly STEP_POINTERDOWN_SPRITE: number;
  82909. static readonly STEP_POINTERUP_SPRITE: number;
  82910. }
  82911. /**
  82912. * This represents a scene component.
  82913. *
  82914. * This is used to decouple the dependency the scene is having on the different workloads like
  82915. * layers, post processes...
  82916. */
  82917. export interface ISceneComponent {
  82918. /**
  82919. * The name of the component. Each component must have a unique name.
  82920. */
  82921. name: string;
  82922. /**
  82923. * The scene the component belongs to.
  82924. */
  82925. scene: Scene;
  82926. /**
  82927. * Register the component to one instance of a scene.
  82928. */
  82929. register(): void;
  82930. /**
  82931. * Rebuilds the elements related to this component in case of
  82932. * context lost for instance.
  82933. */
  82934. rebuild(): void;
  82935. /**
  82936. * Disposes the component and the associated ressources.
  82937. */
  82938. dispose(): void;
  82939. }
  82940. /**
  82941. * This represents a SERIALIZABLE scene component.
  82942. *
  82943. * This extends Scene Component to add Serialization methods on top.
  82944. */
  82945. export interface ISceneSerializableComponent extends ISceneComponent {
  82946. /**
  82947. * Adds all the elements from the container to the scene
  82948. * @param container the container holding the elements
  82949. */
  82950. addFromContainer(container: AbstractScene): void;
  82951. /**
  82952. * Removes all the elements in the container from the scene
  82953. * @param container contains the elements to remove
  82954. * @param dispose if the removed element should be disposed (default: false)
  82955. */
  82956. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82957. /**
  82958. * Serializes the component data to the specified json object
  82959. * @param serializationObject The object to serialize to
  82960. */
  82961. serialize(serializationObject: any): void;
  82962. }
  82963. /**
  82964. * Strong typing of a Mesh related stage step action
  82965. */
  82966. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82967. /**
  82968. * Strong typing of a Evaluate Sub Mesh related stage step action
  82969. */
  82970. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82971. /**
  82972. * Strong typing of a Active Mesh related stage step action
  82973. */
  82974. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82975. /**
  82976. * Strong typing of a Camera related stage step action
  82977. */
  82978. export type CameraStageAction = (camera: Camera) => void;
  82979. /**
  82980. * Strong typing of a Camera Frame buffer related stage step action
  82981. */
  82982. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82983. /**
  82984. * Strong typing of a Render Target related stage step action
  82985. */
  82986. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82987. /**
  82988. * Strong typing of a RenderingGroup related stage step action
  82989. */
  82990. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82991. /**
  82992. * Strong typing of a Mesh Render related stage step action
  82993. */
  82994. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82995. /**
  82996. * Strong typing of a simple stage step action
  82997. */
  82998. export type SimpleStageAction = () => void;
  82999. /**
  83000. * Strong typing of a render target action.
  83001. */
  83002. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83003. /**
  83004. * Strong typing of a pointer move action.
  83005. */
  83006. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83007. /**
  83008. * Strong typing of a pointer up/down action.
  83009. */
  83010. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83011. /**
  83012. * Representation of a stage in the scene (Basically a list of ordered steps)
  83013. * @hidden
  83014. */
  83015. export class Stage<T extends Function> extends Array<{
  83016. index: number;
  83017. component: ISceneComponent;
  83018. action: T;
  83019. }> {
  83020. /**
  83021. * Hide ctor from the rest of the world.
  83022. * @param items The items to add.
  83023. */
  83024. private constructor();
  83025. /**
  83026. * Creates a new Stage.
  83027. * @returns A new instance of a Stage
  83028. */
  83029. static Create<T extends Function>(): Stage<T>;
  83030. /**
  83031. * Registers a step in an ordered way in the targeted stage.
  83032. * @param index Defines the position to register the step in
  83033. * @param component Defines the component attached to the step
  83034. * @param action Defines the action to launch during the step
  83035. */
  83036. registerStep(index: number, component: ISceneComponent, action: T): void;
  83037. /**
  83038. * Clears all the steps from the stage.
  83039. */
  83040. clear(): void;
  83041. }
  83042. }
  83043. declare module BABYLON {
  83044. interface Scene {
  83045. /** @hidden */
  83046. _pointerOverSprite: Nullable<Sprite>;
  83047. /** @hidden */
  83048. _pickedDownSprite: Nullable<Sprite>;
  83049. /** @hidden */
  83050. _tempSpritePickingRay: Nullable<Ray>;
  83051. /**
  83052. * All of the sprite managers added to this scene
  83053. * @see http://doc.babylonjs.com/babylon101/sprites
  83054. */
  83055. spriteManagers: Array<ISpriteManager>;
  83056. /**
  83057. * An event triggered when sprites rendering is about to start
  83058. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83059. */
  83060. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83061. /**
  83062. * An event triggered when sprites rendering is done
  83063. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83064. */
  83065. onAfterSpritesRenderingObservable: Observable<Scene>;
  83066. /** @hidden */
  83067. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83068. /** Launch a ray to try to pick a sprite in the scene
  83069. * @param x position on screen
  83070. * @param y position on screen
  83071. * @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
  83072. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83073. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83074. * @returns a PickingInfo
  83075. */
  83076. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83077. /** Use the given ray to pick a sprite in the scene
  83078. * @param ray The ray (in world space) to use to pick meshes
  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 fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83081. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83082. * @returns a PickingInfo
  83083. */
  83084. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83085. /** @hidden */
  83086. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83087. /** Launch a ray to try to pick sprites in the scene
  83088. * @param x position on screen
  83089. * @param y position on screen
  83090. * @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
  83091. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83092. * @returns a PickingInfo array
  83093. */
  83094. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83095. /** Use the given ray to pick sprites in the scene
  83096. * @param ray The ray (in world space) to use to pick meshes
  83097. * @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
  83098. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83099. * @returns a PickingInfo array
  83100. */
  83101. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83102. /**
  83103. * Force the sprite under the pointer
  83104. * @param sprite defines the sprite to use
  83105. */
  83106. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83107. /**
  83108. * Gets the sprite under the pointer
  83109. * @returns a Sprite or null if no sprite is under the pointer
  83110. */
  83111. getPointerOverSprite(): Nullable<Sprite>;
  83112. }
  83113. /**
  83114. * Defines the sprite scene component responsible to manage sprites
  83115. * in a given scene.
  83116. */
  83117. export class SpriteSceneComponent implements ISceneComponent {
  83118. /**
  83119. * The component name helpfull to identify the component in the list of scene components.
  83120. */
  83121. readonly name: string;
  83122. /**
  83123. * The scene the component belongs to.
  83124. */
  83125. scene: Scene;
  83126. /** @hidden */
  83127. private _spritePredicate;
  83128. /**
  83129. * Creates a new instance of the component for the given scene
  83130. * @param scene Defines the scene to register the component in
  83131. */
  83132. constructor(scene: Scene);
  83133. /**
  83134. * Registers the component in a given scene
  83135. */
  83136. register(): void;
  83137. /**
  83138. * Rebuilds the elements related to this component in case of
  83139. * context lost for instance.
  83140. */
  83141. rebuild(): void;
  83142. /**
  83143. * Disposes the component and the associated ressources.
  83144. */
  83145. dispose(): void;
  83146. private _pickSpriteButKeepRay;
  83147. private _pointerMove;
  83148. private _pointerDown;
  83149. private _pointerUp;
  83150. }
  83151. }
  83152. declare module BABYLON {
  83153. /** @hidden */
  83154. export var fogFragmentDeclaration: {
  83155. name: string;
  83156. shader: string;
  83157. };
  83158. }
  83159. declare module BABYLON {
  83160. /** @hidden */
  83161. export var fogFragment: {
  83162. name: string;
  83163. shader: string;
  83164. };
  83165. }
  83166. declare module BABYLON {
  83167. /** @hidden */
  83168. export var spritesPixelShader: {
  83169. name: string;
  83170. shader: string;
  83171. };
  83172. }
  83173. declare module BABYLON {
  83174. /** @hidden */
  83175. export var fogVertexDeclaration: {
  83176. name: string;
  83177. shader: string;
  83178. };
  83179. }
  83180. declare module BABYLON {
  83181. /** @hidden */
  83182. export var spritesVertexShader: {
  83183. name: string;
  83184. shader: string;
  83185. };
  83186. }
  83187. declare module BABYLON {
  83188. /**
  83189. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83190. */
  83191. export interface ISpriteManager extends IDisposable {
  83192. /**
  83193. * Restricts the camera to viewing objects with the same layerMask.
  83194. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83195. */
  83196. layerMask: number;
  83197. /**
  83198. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83199. */
  83200. isPickable: boolean;
  83201. /**
  83202. * Specifies the rendering group id for this mesh (0 by default)
  83203. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83204. */
  83205. renderingGroupId: number;
  83206. /**
  83207. * Defines the list of sprites managed by the manager.
  83208. */
  83209. sprites: Array<Sprite>;
  83210. /**
  83211. * Tests the intersection of a sprite with a specific ray.
  83212. * @param ray The ray we are sending to test the collision
  83213. * @param camera The camera space we are sending rays in
  83214. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83215. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83216. * @returns picking info or null.
  83217. */
  83218. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83219. /**
  83220. * Intersects the sprites with a ray
  83221. * @param ray defines the ray to intersect with
  83222. * @param camera defines the current active camera
  83223. * @param predicate defines a predicate used to select candidate sprites
  83224. * @returns null if no hit or a PickingInfo array
  83225. */
  83226. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83227. /**
  83228. * Renders the list of sprites on screen.
  83229. */
  83230. render(): void;
  83231. }
  83232. /**
  83233. * Class used to manage multiple sprites on the same spritesheet
  83234. * @see http://doc.babylonjs.com/babylon101/sprites
  83235. */
  83236. export class SpriteManager implements ISpriteManager {
  83237. /** defines the manager's name */
  83238. name: string;
  83239. /** Gets the list of sprites */
  83240. sprites: Sprite[];
  83241. /** Gets or sets the rendering group id (0 by default) */
  83242. renderingGroupId: number;
  83243. /** Gets or sets camera layer mask */
  83244. layerMask: number;
  83245. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83246. fogEnabled: boolean;
  83247. /** Gets or sets a boolean indicating if the sprites are pickable */
  83248. isPickable: boolean;
  83249. /** Defines the default width of a cell in the spritesheet */
  83250. cellWidth: number;
  83251. /** Defines the default height of a cell in the spritesheet */
  83252. cellHeight: number;
  83253. /** Associative array from JSON sprite data file */
  83254. private _cellData;
  83255. /** Array of sprite names from JSON sprite data file */
  83256. private _spriteMap;
  83257. /** True when packed cell data from JSON file is ready*/
  83258. private _packedAndReady;
  83259. /**
  83260. * An event triggered when the manager is disposed.
  83261. */
  83262. onDisposeObservable: Observable<SpriteManager>;
  83263. private _onDisposeObserver;
  83264. /**
  83265. * Callback called when the manager is disposed
  83266. */
  83267. set onDispose(callback: () => void);
  83268. private _capacity;
  83269. private _fromPacked;
  83270. private _spriteTexture;
  83271. private _epsilon;
  83272. private _scene;
  83273. private _vertexData;
  83274. private _buffer;
  83275. private _vertexBuffers;
  83276. private _indexBuffer;
  83277. private _effectBase;
  83278. private _effectFog;
  83279. /**
  83280. * Gets or sets the spritesheet texture
  83281. */
  83282. get texture(): Texture;
  83283. set texture(value: Texture);
  83284. private _blendMode;
  83285. /**
  83286. * Blend mode use to render the particle, it can be any of
  83287. * the static Constants.ALPHA_x properties provided in this class.
  83288. * Default value is Constants.ALPHA_COMBINE
  83289. */
  83290. get blendMode(): number;
  83291. set blendMode(blendMode: number);
  83292. /** Disables writing to the depth buffer when rendering the sprites.
  83293. * It can be handy to disable depth writing when using textures without alpha channel
  83294. * and setting some specific blend modes.
  83295. */
  83296. disableDepthWrite: boolean;
  83297. /**
  83298. * Creates a new sprite manager
  83299. * @param name defines the manager's name
  83300. * @param imgUrl defines the sprite sheet url
  83301. * @param capacity defines the maximum allowed number of sprites
  83302. * @param cellSize defines the size of a sprite cell
  83303. * @param scene defines the hosting scene
  83304. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83305. * @param samplingMode defines the smapling mode to use with spritesheet
  83306. * @param fromPacked set to false; do not alter
  83307. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83308. */
  83309. constructor(
  83310. /** defines the manager's name */
  83311. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83312. private _makePacked;
  83313. private _appendSpriteVertex;
  83314. /**
  83315. * Intersects the sprites with a ray
  83316. * @param ray defines the ray to intersect with
  83317. * @param camera defines the current active camera
  83318. * @param predicate defines a predicate used to select candidate sprites
  83319. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83320. * @returns null if no hit or a PickingInfo
  83321. */
  83322. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83323. /**
  83324. * Intersects the sprites with a ray
  83325. * @param ray defines the ray to intersect with
  83326. * @param camera defines the current active camera
  83327. * @param predicate defines a predicate used to select candidate sprites
  83328. * @returns null if no hit or a PickingInfo array
  83329. */
  83330. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83331. /**
  83332. * Render all child sprites
  83333. */
  83334. render(): void;
  83335. /**
  83336. * Release associated resources
  83337. */
  83338. dispose(): void;
  83339. }
  83340. }
  83341. declare module BABYLON {
  83342. /** Interface used by value gradients (color, factor, ...) */
  83343. export interface IValueGradient {
  83344. /**
  83345. * Gets or sets the gradient value (between 0 and 1)
  83346. */
  83347. gradient: number;
  83348. }
  83349. /** Class used to store color4 gradient */
  83350. export class ColorGradient implements IValueGradient {
  83351. /**
  83352. * Gets or sets the gradient value (between 0 and 1)
  83353. */
  83354. gradient: number;
  83355. /**
  83356. * Gets or sets first associated color
  83357. */
  83358. color1: Color4;
  83359. /**
  83360. * Gets or sets second associated color
  83361. */
  83362. color2?: Color4;
  83363. /**
  83364. * Will get a color picked randomly between color1 and color2.
  83365. * If color2 is undefined then color1 will be used
  83366. * @param result defines the target Color4 to store the result in
  83367. */
  83368. getColorToRef(result: Color4): void;
  83369. }
  83370. /** Class used to store color 3 gradient */
  83371. export class Color3Gradient implements IValueGradient {
  83372. /**
  83373. * Gets or sets the gradient value (between 0 and 1)
  83374. */
  83375. gradient: number;
  83376. /**
  83377. * Gets or sets the associated color
  83378. */
  83379. color: Color3;
  83380. }
  83381. /** Class used to store factor gradient */
  83382. export class FactorGradient implements IValueGradient {
  83383. /**
  83384. * Gets or sets the gradient value (between 0 and 1)
  83385. */
  83386. gradient: number;
  83387. /**
  83388. * Gets or sets first associated factor
  83389. */
  83390. factor1: number;
  83391. /**
  83392. * Gets or sets second associated factor
  83393. */
  83394. factor2?: number;
  83395. /**
  83396. * Will get a number picked randomly between factor1 and factor2.
  83397. * If factor2 is undefined then factor1 will be used
  83398. * @returns the picked number
  83399. */
  83400. getFactor(): number;
  83401. }
  83402. /**
  83403. * Helper used to simplify some generic gradient tasks
  83404. */
  83405. export class GradientHelper {
  83406. /**
  83407. * Gets the current gradient from an array of IValueGradient
  83408. * @param ratio defines the current ratio to get
  83409. * @param gradients defines the array of IValueGradient
  83410. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83411. */
  83412. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83413. }
  83414. }
  83415. declare module BABYLON {
  83416. /**
  83417. * Interface for the size containing width and height
  83418. */
  83419. export interface ISize {
  83420. /**
  83421. * Width
  83422. */
  83423. width: number;
  83424. /**
  83425. * Heighht
  83426. */
  83427. height: number;
  83428. }
  83429. /**
  83430. * Size containing widht and height
  83431. */
  83432. export class Size implements ISize {
  83433. /**
  83434. * Width
  83435. */
  83436. width: number;
  83437. /**
  83438. * Height
  83439. */
  83440. height: number;
  83441. /**
  83442. * Creates a Size object from the given width and height (floats).
  83443. * @param width width of the new size
  83444. * @param height height of the new size
  83445. */
  83446. constructor(width: number, height: number);
  83447. /**
  83448. * Returns a string with the Size width and height
  83449. * @returns a string with the Size width and height
  83450. */
  83451. toString(): string;
  83452. /**
  83453. * "Size"
  83454. * @returns the string "Size"
  83455. */
  83456. getClassName(): string;
  83457. /**
  83458. * Returns the Size hash code.
  83459. * @returns a hash code for a unique width and height
  83460. */
  83461. getHashCode(): number;
  83462. /**
  83463. * Updates the current size from the given one.
  83464. * @param src the given size
  83465. */
  83466. copyFrom(src: Size): void;
  83467. /**
  83468. * Updates in place the current Size from the given floats.
  83469. * @param width width of the new size
  83470. * @param height height of the new size
  83471. * @returns the updated Size.
  83472. */
  83473. copyFromFloats(width: number, height: number): Size;
  83474. /**
  83475. * Updates in place the current Size from the given floats.
  83476. * @param width width to set
  83477. * @param height height to set
  83478. * @returns the updated Size.
  83479. */
  83480. set(width: number, height: number): Size;
  83481. /**
  83482. * Multiplies the width and height by numbers
  83483. * @param w factor to multiple the width by
  83484. * @param h factor to multiple the height by
  83485. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83486. */
  83487. multiplyByFloats(w: number, h: number): Size;
  83488. /**
  83489. * Clones the size
  83490. * @returns a new Size copied from the given one.
  83491. */
  83492. clone(): Size;
  83493. /**
  83494. * True if the current Size and the given one width and height are strictly equal.
  83495. * @param other the other size to compare against
  83496. * @returns True if the current Size and the given one width and height are strictly equal.
  83497. */
  83498. equals(other: Size): boolean;
  83499. /**
  83500. * The surface of the Size : width * height (float).
  83501. */
  83502. get surface(): number;
  83503. /**
  83504. * Create a new size of zero
  83505. * @returns a new Size set to (0.0, 0.0)
  83506. */
  83507. static Zero(): Size;
  83508. /**
  83509. * Sums the width and height of two sizes
  83510. * @param otherSize size to add to this size
  83511. * @returns a new Size set as the addition result of the current Size and the given one.
  83512. */
  83513. add(otherSize: Size): Size;
  83514. /**
  83515. * Subtracts the width and height of two
  83516. * @param otherSize size to subtract to this size
  83517. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83518. */
  83519. subtract(otherSize: Size): Size;
  83520. /**
  83521. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83522. * @param start starting size to lerp between
  83523. * @param end end size to lerp between
  83524. * @param amount amount to lerp between the start and end values
  83525. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83526. */
  83527. static Lerp(start: Size, end: Size, amount: number): Size;
  83528. }
  83529. }
  83530. declare module BABYLON {
  83531. interface ThinEngine {
  83532. /**
  83533. * Creates a dynamic texture
  83534. * @param width defines the width of the texture
  83535. * @param height defines the height of the texture
  83536. * @param generateMipMaps defines if the engine should generate the mip levels
  83537. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83538. * @returns the dynamic texture inside an InternalTexture
  83539. */
  83540. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83541. /**
  83542. * Update the content of a dynamic texture
  83543. * @param texture defines the texture to update
  83544. * @param canvas defines the canvas containing the source
  83545. * @param invertY defines if data must be stored with Y axis inverted
  83546. * @param premulAlpha defines if alpha is stored as premultiplied
  83547. * @param format defines the format of the data
  83548. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83549. */
  83550. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83551. }
  83552. }
  83553. declare module BABYLON {
  83554. /**
  83555. * Helper class used to generate a canvas to manipulate images
  83556. */
  83557. export class CanvasGenerator {
  83558. /**
  83559. * Create a new canvas (or offscreen canvas depending on the context)
  83560. * @param width defines the expected width
  83561. * @param height defines the expected height
  83562. * @return a new canvas or offscreen canvas
  83563. */
  83564. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83565. }
  83566. }
  83567. declare module BABYLON {
  83568. /**
  83569. * A class extending Texture allowing drawing on a texture
  83570. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83571. */
  83572. export class DynamicTexture extends Texture {
  83573. private _generateMipMaps;
  83574. private _canvas;
  83575. private _context;
  83576. private _engine;
  83577. /**
  83578. * Creates a DynamicTexture
  83579. * @param name defines the name of the texture
  83580. * @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
  83581. * @param scene defines the scene where you want the texture
  83582. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83583. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83584. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83585. */
  83586. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83587. /**
  83588. * Get the current class name of the texture useful for serialization or dynamic coding.
  83589. * @returns "DynamicTexture"
  83590. */
  83591. getClassName(): string;
  83592. /**
  83593. * Gets the current state of canRescale
  83594. */
  83595. get canRescale(): boolean;
  83596. private _recreate;
  83597. /**
  83598. * Scales the texture
  83599. * @param ratio the scale factor to apply to both width and height
  83600. */
  83601. scale(ratio: number): void;
  83602. /**
  83603. * Resizes the texture
  83604. * @param width the new width
  83605. * @param height the new height
  83606. */
  83607. scaleTo(width: number, height: number): void;
  83608. /**
  83609. * Gets the context of the canvas used by the texture
  83610. * @returns the canvas context of the dynamic texture
  83611. */
  83612. getContext(): CanvasRenderingContext2D;
  83613. /**
  83614. * Clears the texture
  83615. */
  83616. clear(): void;
  83617. /**
  83618. * Updates the texture
  83619. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83620. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83621. */
  83622. update(invertY?: boolean, premulAlpha?: boolean): void;
  83623. /**
  83624. * Draws text onto the texture
  83625. * @param text defines the text to be drawn
  83626. * @param x defines the placement of the text from the left
  83627. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83628. * @param font defines the font to be used with font-style, font-size, font-name
  83629. * @param color defines the color used for the text
  83630. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83631. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83632. * @param update defines whether texture is immediately update (default is true)
  83633. */
  83634. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83635. /**
  83636. * Clones the texture
  83637. * @returns the clone of the texture.
  83638. */
  83639. clone(): DynamicTexture;
  83640. /**
  83641. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83642. * @returns a serialized dynamic texture object
  83643. */
  83644. serialize(): any;
  83645. /** @hidden */
  83646. _rebuild(): void;
  83647. }
  83648. }
  83649. declare module BABYLON {
  83650. interface Engine {
  83651. /**
  83652. * Creates a raw texture
  83653. * @param data defines the data to store in the texture
  83654. * @param width defines the width of the texture
  83655. * @param height defines the height of the texture
  83656. * @param format defines the format of the data
  83657. * @param generateMipMaps defines if the engine should generate the mip levels
  83658. * @param invertY defines if data must be stored with Y axis inverted
  83659. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83660. * @param compression defines the compression used (null by default)
  83661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83662. * @returns the raw texture inside an InternalTexture
  83663. */
  83664. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83665. /**
  83666. * Update a raw texture
  83667. * @param texture defines the texture to update
  83668. * @param data defines the data to store in the texture
  83669. * @param format defines the format of the data
  83670. * @param invertY defines if data must be stored with Y axis inverted
  83671. */
  83672. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83673. /**
  83674. * Update a raw texture
  83675. * @param texture defines the texture to update
  83676. * @param data defines the data to store in the texture
  83677. * @param format defines the format of the data
  83678. * @param invertY defines if data must be stored with Y axis inverted
  83679. * @param compression defines the compression used (null by default)
  83680. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83681. */
  83682. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83683. /**
  83684. * Creates a new raw cube texture
  83685. * @param data defines the array of data to use to create each face
  83686. * @param size defines the size of the textures
  83687. * @param format defines the format of the data
  83688. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83689. * @param generateMipMaps defines if the engine should generate the mip levels
  83690. * @param invertY defines if data must be stored with Y axis inverted
  83691. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83692. * @param compression defines the compression used (null by default)
  83693. * @returns the cube texture as an InternalTexture
  83694. */
  83695. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83696. /**
  83697. * Update a raw cube texture
  83698. * @param texture defines the texture to udpdate
  83699. * @param data defines the data to store
  83700. * @param format defines the data format
  83701. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83702. * @param invertY defines if data must be stored with Y axis inverted
  83703. */
  83704. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83705. /**
  83706. * Update a raw cube texture
  83707. * @param texture defines the texture to udpdate
  83708. * @param data defines the data to store
  83709. * @param format defines the data format
  83710. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83711. * @param invertY defines if data must be stored with Y axis inverted
  83712. * @param compression defines the compression used (null by default)
  83713. */
  83714. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83715. /**
  83716. * Update a raw cube texture
  83717. * @param texture defines the texture to udpdate
  83718. * @param data defines the data to store
  83719. * @param format defines the data format
  83720. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83721. * @param invertY defines if data must be stored with Y axis inverted
  83722. * @param compression defines the compression used (null by default)
  83723. * @param level defines which level of the texture to update
  83724. */
  83725. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83726. /**
  83727. * Creates a new raw cube texture from a specified url
  83728. * @param url defines the url where the data is located
  83729. * @param scene defines the current scene
  83730. * @param size defines the size of the textures
  83731. * @param format defines the format of the data
  83732. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83733. * @param noMipmap defines if the engine should avoid generating the mip levels
  83734. * @param callback defines a callback used to extract texture data from loaded data
  83735. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83736. * @param onLoad defines a callback called when texture is loaded
  83737. * @param onError defines a callback called if there is an error
  83738. * @returns the cube texture as an InternalTexture
  83739. */
  83740. 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;
  83741. /**
  83742. * Creates a new raw cube texture from a specified url
  83743. * @param url defines the url where the data is located
  83744. * @param scene defines the current scene
  83745. * @param size defines the size of the textures
  83746. * @param format defines the format of the data
  83747. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83748. * @param noMipmap defines if the engine should avoid generating the mip levels
  83749. * @param callback defines a callback used to extract texture data from loaded data
  83750. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83751. * @param onLoad defines a callback called when texture is loaded
  83752. * @param onError defines a callback called if there is an error
  83753. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83754. * @param invertY defines if data must be stored with Y axis inverted
  83755. * @returns the cube texture as an InternalTexture
  83756. */
  83757. 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;
  83758. /**
  83759. * Creates a new raw 3D texture
  83760. * @param data defines the data used to create the texture
  83761. * @param width defines the width of the texture
  83762. * @param height defines the height of the texture
  83763. * @param depth defines the depth of the texture
  83764. * @param format defines the format of the texture
  83765. * @param generateMipMaps defines if the engine must generate mip levels
  83766. * @param invertY defines if data must be stored with Y axis inverted
  83767. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83768. * @param compression defines the compressed used (can be null)
  83769. * @param textureType defines the compressed used (can be null)
  83770. * @returns a new raw 3D texture (stored in an InternalTexture)
  83771. */
  83772. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83773. /**
  83774. * Update a raw 3D texture
  83775. * @param texture defines the texture to update
  83776. * @param data defines the data to store
  83777. * @param format defines the data format
  83778. * @param invertY defines if data must be stored with Y axis inverted
  83779. */
  83780. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83781. /**
  83782. * Update a raw 3D texture
  83783. * @param texture defines the texture to update
  83784. * @param data defines the data to store
  83785. * @param format defines the data format
  83786. * @param invertY defines if data must be stored with Y axis inverted
  83787. * @param compression defines the used compression (can be null)
  83788. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83789. */
  83790. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83791. /**
  83792. * Creates a new raw 2D array texture
  83793. * @param data defines the data used to create the texture
  83794. * @param width defines the width of the texture
  83795. * @param height defines the height of the texture
  83796. * @param depth defines the number of layers of the texture
  83797. * @param format defines the format of the texture
  83798. * @param generateMipMaps defines if the engine must generate mip levels
  83799. * @param invertY defines if data must be stored with Y axis inverted
  83800. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83801. * @param compression defines the compressed used (can be null)
  83802. * @param textureType defines the compressed used (can be null)
  83803. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83804. */
  83805. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83806. /**
  83807. * Update a raw 2D array texture
  83808. * @param texture defines the texture to update
  83809. * @param data defines the data to store
  83810. * @param format defines the data format
  83811. * @param invertY defines if data must be stored with Y axis inverted
  83812. */
  83813. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83814. /**
  83815. * Update a raw 2D array texture
  83816. * @param texture defines the texture to update
  83817. * @param data defines the data to store
  83818. * @param format defines the data format
  83819. * @param invertY defines if data must be stored with Y axis inverted
  83820. * @param compression defines the used compression (can be null)
  83821. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83822. */
  83823. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83824. }
  83825. }
  83826. declare module BABYLON {
  83827. /**
  83828. * Raw texture can help creating a texture directly from an array of data.
  83829. * This can be super useful if you either get the data from an uncompressed source or
  83830. * if you wish to create your texture pixel by pixel.
  83831. */
  83832. export class RawTexture extends Texture {
  83833. /**
  83834. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83835. */
  83836. format: number;
  83837. private _engine;
  83838. /**
  83839. * Instantiates a new RawTexture.
  83840. * Raw texture can help creating a texture directly from an array of data.
  83841. * This can be super useful if you either get the data from an uncompressed source or
  83842. * if you wish to create your texture pixel by pixel.
  83843. * @param data define the array of data to use to create the texture
  83844. * @param width define the width of the texture
  83845. * @param height define the height of the texture
  83846. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83847. * @param scene define the scene the texture belongs to
  83848. * @param generateMipMaps define whether mip maps should be generated or not
  83849. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83850. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83851. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83852. */
  83853. constructor(data: ArrayBufferView, width: number, height: number,
  83854. /**
  83855. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83856. */
  83857. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83858. /**
  83859. * Updates the texture underlying data.
  83860. * @param data Define the new data of the texture
  83861. */
  83862. update(data: ArrayBufferView): void;
  83863. /**
  83864. * Creates a luminance texture from some data.
  83865. * @param data Define the texture data
  83866. * @param width Define the width of the texture
  83867. * @param height Define the height of the texture
  83868. * @param scene Define the scene the texture belongs to
  83869. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83870. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83871. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83872. * @returns the luminance texture
  83873. */
  83874. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83875. /**
  83876. * Creates a luminance alpha texture from some data.
  83877. * @param data Define the texture data
  83878. * @param width Define the width of the texture
  83879. * @param height Define the height of the texture
  83880. * @param scene Define the scene the texture belongs to
  83881. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83882. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83883. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83884. * @returns the luminance alpha texture
  83885. */
  83886. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83887. /**
  83888. * Creates an alpha texture from some data.
  83889. * @param data Define the texture data
  83890. * @param width Define the width of the texture
  83891. * @param height Define the height of the texture
  83892. * @param scene Define the scene the texture belongs to
  83893. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83894. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83895. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83896. * @returns the alpha texture
  83897. */
  83898. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83899. /**
  83900. * Creates a RGB texture from some data.
  83901. * @param data Define the texture data
  83902. * @param width Define the width of the texture
  83903. * @param height Define the height of the texture
  83904. * @param scene Define the scene the texture belongs to
  83905. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83906. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83907. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83908. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83909. * @returns the RGB alpha texture
  83910. */
  83911. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83912. /**
  83913. * Creates a RGBA texture from some data.
  83914. * @param data Define the texture data
  83915. * @param width Define the width of the texture
  83916. * @param height Define the height of the texture
  83917. * @param scene Define the scene the texture belongs to
  83918. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83919. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83920. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83921. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83922. * @returns the RGBA texture
  83923. */
  83924. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83925. /**
  83926. * Creates a R texture from some data.
  83927. * @param data Define the texture data
  83928. * @param width Define the width of the texture
  83929. * @param height Define the height of the texture
  83930. * @param scene Define the scene the texture belongs to
  83931. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83932. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83933. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83934. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83935. * @returns the R texture
  83936. */
  83937. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83938. }
  83939. }
  83940. declare module BABYLON {
  83941. interface AbstractScene {
  83942. /**
  83943. * The list of procedural textures added to the scene
  83944. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83945. */
  83946. proceduralTextures: Array<ProceduralTexture>;
  83947. }
  83948. /**
  83949. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83950. * in a given scene.
  83951. */
  83952. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83953. /**
  83954. * The component name helpfull to identify the component in the list of scene components.
  83955. */
  83956. readonly name: string;
  83957. /**
  83958. * The scene the component belongs to.
  83959. */
  83960. scene: Scene;
  83961. /**
  83962. * Creates a new instance of the component for the given scene
  83963. * @param scene Defines the scene to register the component in
  83964. */
  83965. constructor(scene: Scene);
  83966. /**
  83967. * Registers the component in a given scene
  83968. */
  83969. register(): void;
  83970. /**
  83971. * Rebuilds the elements related to this component in case of
  83972. * context lost for instance.
  83973. */
  83974. rebuild(): void;
  83975. /**
  83976. * Disposes the component and the associated ressources.
  83977. */
  83978. dispose(): void;
  83979. private _beforeClear;
  83980. }
  83981. }
  83982. declare module BABYLON {
  83983. interface ThinEngine {
  83984. /**
  83985. * Creates a new render target cube texture
  83986. * @param size defines the size of the texture
  83987. * @param options defines the options used to create the texture
  83988. * @returns a new render target cube texture stored in an InternalTexture
  83989. */
  83990. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83991. }
  83992. }
  83993. declare module BABYLON {
  83994. /** @hidden */
  83995. export var proceduralVertexShader: {
  83996. name: string;
  83997. shader: string;
  83998. };
  83999. }
  84000. declare module BABYLON {
  84001. /**
  84002. * 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.
  84003. * This is the base class of any Procedural texture and contains most of the shareable code.
  84004. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84005. */
  84006. export class ProceduralTexture extends Texture {
  84007. isCube: boolean;
  84008. /**
  84009. * Define if the texture is enabled or not (disabled texture will not render)
  84010. */
  84011. isEnabled: boolean;
  84012. /**
  84013. * Define if the texture must be cleared before rendering (default is true)
  84014. */
  84015. autoClear: boolean;
  84016. /**
  84017. * Callback called when the texture is generated
  84018. */
  84019. onGenerated: () => void;
  84020. /**
  84021. * Event raised when the texture is generated
  84022. */
  84023. onGeneratedObservable: Observable<ProceduralTexture>;
  84024. /** @hidden */
  84025. _generateMipMaps: boolean;
  84026. /** @hidden **/
  84027. _effect: Effect;
  84028. /** @hidden */
  84029. _textures: {
  84030. [key: string]: Texture;
  84031. };
  84032. private _size;
  84033. private _currentRefreshId;
  84034. private _frameId;
  84035. private _refreshRate;
  84036. private _vertexBuffers;
  84037. private _indexBuffer;
  84038. private _uniforms;
  84039. private _samplers;
  84040. private _fragment;
  84041. private _floats;
  84042. private _ints;
  84043. private _floatsArrays;
  84044. private _colors3;
  84045. private _colors4;
  84046. private _vectors2;
  84047. private _vectors3;
  84048. private _matrices;
  84049. private _fallbackTexture;
  84050. private _fallbackTextureUsed;
  84051. private _engine;
  84052. private _cachedDefines;
  84053. private _contentUpdateId;
  84054. private _contentData;
  84055. /**
  84056. * Instantiates a new procedural texture.
  84057. * 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.
  84058. * This is the base class of any Procedural texture and contains most of the shareable code.
  84059. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84060. * @param name Define the name of the texture
  84061. * @param size Define the size of the texture to create
  84062. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84063. * @param scene Define the scene the texture belongs to
  84064. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84065. * @param generateMipMaps Define if the texture should creates mip maps or not
  84066. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84067. */
  84068. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84069. /**
  84070. * The effect that is created when initializing the post process.
  84071. * @returns The created effect corresponding the the postprocess.
  84072. */
  84073. getEffect(): Effect;
  84074. /**
  84075. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84076. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84077. */
  84078. getContent(): Nullable<ArrayBufferView>;
  84079. private _createIndexBuffer;
  84080. /** @hidden */
  84081. _rebuild(): void;
  84082. /**
  84083. * Resets the texture in order to recreate its associated resources.
  84084. * This can be called in case of context loss
  84085. */
  84086. reset(): void;
  84087. protected _getDefines(): string;
  84088. /**
  84089. * Is the texture ready to be used ? (rendered at least once)
  84090. * @returns true if ready, otherwise, false.
  84091. */
  84092. isReady(): boolean;
  84093. /**
  84094. * Resets the refresh counter of the texture and start bak from scratch.
  84095. * Could be useful to regenerate the texture if it is setup to render only once.
  84096. */
  84097. resetRefreshCounter(): void;
  84098. /**
  84099. * Set the fragment shader to use in order to render the texture.
  84100. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84101. */
  84102. setFragment(fragment: any): void;
  84103. /**
  84104. * Define the refresh rate of the texture or the rendering frequency.
  84105. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84106. */
  84107. get refreshRate(): number;
  84108. set refreshRate(value: number);
  84109. /** @hidden */
  84110. _shouldRender(): boolean;
  84111. /**
  84112. * Get the size the texture is rendering at.
  84113. * @returns the size (texture is always squared)
  84114. */
  84115. getRenderSize(): number;
  84116. /**
  84117. * Resize the texture to new value.
  84118. * @param size Define the new size the texture should have
  84119. * @param generateMipMaps Define whether the new texture should create mip maps
  84120. */
  84121. resize(size: number, generateMipMaps: boolean): void;
  84122. private _checkUniform;
  84123. /**
  84124. * Set a texture in the shader program used to render.
  84125. * @param name Define the name of the uniform samplers as defined in the shader
  84126. * @param texture Define the texture to bind to this sampler
  84127. * @return the texture itself allowing "fluent" like uniform updates
  84128. */
  84129. setTexture(name: string, texture: Texture): ProceduralTexture;
  84130. /**
  84131. * Set a float in the shader.
  84132. * @param name Define the name of the uniform as defined in the shader
  84133. * @param value Define the value to give to the uniform
  84134. * @return the texture itself allowing "fluent" like uniform updates
  84135. */
  84136. setFloat(name: string, value: number): ProceduralTexture;
  84137. /**
  84138. * Set a int in the shader.
  84139. * @param name Define the name of the uniform as defined in the shader
  84140. * @param value Define the value to give to the uniform
  84141. * @return the texture itself allowing "fluent" like uniform updates
  84142. */
  84143. setInt(name: string, value: number): ProceduralTexture;
  84144. /**
  84145. * Set an array of floats in the shader.
  84146. * @param name Define the name of the uniform as defined in the shader
  84147. * @param value Define the value to give to the uniform
  84148. * @return the texture itself allowing "fluent" like uniform updates
  84149. */
  84150. setFloats(name: string, value: number[]): ProceduralTexture;
  84151. /**
  84152. * Set a vec3 in the shader from a Color3.
  84153. * @param name Define the name of the uniform as defined in the shader
  84154. * @param value Define the value to give to the uniform
  84155. * @return the texture itself allowing "fluent" like uniform updates
  84156. */
  84157. setColor3(name: string, value: Color3): ProceduralTexture;
  84158. /**
  84159. * Set a vec4 in the shader from a Color4.
  84160. * @param name Define the name of the uniform as defined in the shader
  84161. * @param value Define the value to give to the uniform
  84162. * @return the texture itself allowing "fluent" like uniform updates
  84163. */
  84164. setColor4(name: string, value: Color4): ProceduralTexture;
  84165. /**
  84166. * Set a vec2 in the shader from a Vector2.
  84167. * @param name Define the name of the uniform as defined in the shader
  84168. * @param value Define the value to give to the uniform
  84169. * @return the texture itself allowing "fluent" like uniform updates
  84170. */
  84171. setVector2(name: string, value: Vector2): ProceduralTexture;
  84172. /**
  84173. * Set a vec3 in the shader from a Vector3.
  84174. * @param name Define the name of the uniform as defined in the shader
  84175. * @param value Define the value to give to the uniform
  84176. * @return the texture itself allowing "fluent" like uniform updates
  84177. */
  84178. setVector3(name: string, value: Vector3): ProceduralTexture;
  84179. /**
  84180. * Set a mat4 in the shader from a MAtrix.
  84181. * @param name Define the name of the uniform as defined in the shader
  84182. * @param value Define the value to give to the uniform
  84183. * @return the texture itself allowing "fluent" like uniform updates
  84184. */
  84185. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84186. /**
  84187. * Render the texture to its associated render target.
  84188. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84189. */
  84190. render(useCameraPostProcess?: boolean): void;
  84191. /**
  84192. * Clone the texture.
  84193. * @returns the cloned texture
  84194. */
  84195. clone(): ProceduralTexture;
  84196. /**
  84197. * Dispose the texture and release its asoociated resources.
  84198. */
  84199. dispose(): void;
  84200. }
  84201. }
  84202. declare module BABYLON {
  84203. /**
  84204. * This represents the base class for particle system in Babylon.
  84205. * 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.
  84206. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84207. * @example https://doc.babylonjs.com/babylon101/particles
  84208. */
  84209. export class BaseParticleSystem {
  84210. /**
  84211. * Source color is added to the destination color without alpha affecting the result
  84212. */
  84213. static BLENDMODE_ONEONE: number;
  84214. /**
  84215. * Blend current color and particle color using particle’s alpha
  84216. */
  84217. static BLENDMODE_STANDARD: number;
  84218. /**
  84219. * Add current color and particle color multiplied by particle’s alpha
  84220. */
  84221. static BLENDMODE_ADD: number;
  84222. /**
  84223. * Multiply current color with particle color
  84224. */
  84225. static BLENDMODE_MULTIPLY: number;
  84226. /**
  84227. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84228. */
  84229. static BLENDMODE_MULTIPLYADD: number;
  84230. /**
  84231. * List of animations used by the particle system.
  84232. */
  84233. animations: Animation[];
  84234. /**
  84235. * The id of the Particle system.
  84236. */
  84237. id: string;
  84238. /**
  84239. * The friendly name of the Particle system.
  84240. */
  84241. name: string;
  84242. /**
  84243. * The rendering group used by the Particle system to chose when to render.
  84244. */
  84245. renderingGroupId: number;
  84246. /**
  84247. * The emitter represents the Mesh or position we are attaching the particle system to.
  84248. */
  84249. emitter: Nullable<AbstractMesh | Vector3>;
  84250. /**
  84251. * The maximum number of particles to emit per frame
  84252. */
  84253. emitRate: number;
  84254. /**
  84255. * If you want to launch only a few particles at once, that can be done, as well.
  84256. */
  84257. manualEmitCount: number;
  84258. /**
  84259. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84260. */
  84261. updateSpeed: number;
  84262. /**
  84263. * The amount of time the particle system is running (depends of the overall update speed).
  84264. */
  84265. targetStopDuration: number;
  84266. /**
  84267. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84268. */
  84269. disposeOnStop: boolean;
  84270. /**
  84271. * Minimum power of emitting particles.
  84272. */
  84273. minEmitPower: number;
  84274. /**
  84275. * Maximum power of emitting particles.
  84276. */
  84277. maxEmitPower: number;
  84278. /**
  84279. * Minimum life time of emitting particles.
  84280. */
  84281. minLifeTime: number;
  84282. /**
  84283. * Maximum life time of emitting particles.
  84284. */
  84285. maxLifeTime: number;
  84286. /**
  84287. * Minimum Size of emitting particles.
  84288. */
  84289. minSize: number;
  84290. /**
  84291. * Maximum Size of emitting particles.
  84292. */
  84293. maxSize: number;
  84294. /**
  84295. * Minimum scale of emitting particles on X axis.
  84296. */
  84297. minScaleX: number;
  84298. /**
  84299. * Maximum scale of emitting particles on X axis.
  84300. */
  84301. maxScaleX: number;
  84302. /**
  84303. * Minimum scale of emitting particles on Y axis.
  84304. */
  84305. minScaleY: number;
  84306. /**
  84307. * Maximum scale of emitting particles on Y axis.
  84308. */
  84309. maxScaleY: number;
  84310. /**
  84311. * Gets or sets the minimal initial rotation in radians.
  84312. */
  84313. minInitialRotation: number;
  84314. /**
  84315. * Gets or sets the maximal initial rotation in radians.
  84316. */
  84317. maxInitialRotation: number;
  84318. /**
  84319. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84320. */
  84321. minAngularSpeed: number;
  84322. /**
  84323. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84324. */
  84325. maxAngularSpeed: number;
  84326. /**
  84327. * The texture used to render each particle. (this can be a spritesheet)
  84328. */
  84329. particleTexture: Nullable<Texture>;
  84330. /**
  84331. * The layer mask we are rendering the particles through.
  84332. */
  84333. layerMask: number;
  84334. /**
  84335. * This can help using your own shader to render the particle system.
  84336. * The according effect will be created
  84337. */
  84338. customShader: any;
  84339. /**
  84340. * By default particle system starts as soon as they are created. This prevents the
  84341. * automatic start to happen and let you decide when to start emitting particles.
  84342. */
  84343. preventAutoStart: boolean;
  84344. private _noiseTexture;
  84345. /**
  84346. * Gets or sets a texture used to add random noise to particle positions
  84347. */
  84348. get noiseTexture(): Nullable<ProceduralTexture>;
  84349. set noiseTexture(value: Nullable<ProceduralTexture>);
  84350. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84351. noiseStrength: Vector3;
  84352. /**
  84353. * Callback triggered when the particle animation is ending.
  84354. */
  84355. onAnimationEnd: Nullable<() => void>;
  84356. /**
  84357. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84358. */
  84359. blendMode: number;
  84360. /**
  84361. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84362. * to override the particles.
  84363. */
  84364. forceDepthWrite: boolean;
  84365. /** 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 */
  84366. preWarmCycles: number;
  84367. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84368. preWarmStepOffset: number;
  84369. /**
  84370. * 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)
  84371. */
  84372. spriteCellChangeSpeed: number;
  84373. /**
  84374. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84375. */
  84376. startSpriteCellID: number;
  84377. /**
  84378. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84379. */
  84380. endSpriteCellID: number;
  84381. /**
  84382. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84383. */
  84384. spriteCellWidth: number;
  84385. /**
  84386. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84387. */
  84388. spriteCellHeight: number;
  84389. /**
  84390. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84391. */
  84392. spriteRandomStartCell: boolean;
  84393. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84394. translationPivot: Vector2;
  84395. /** @hidden */
  84396. protected _isAnimationSheetEnabled: boolean;
  84397. /**
  84398. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84399. */
  84400. beginAnimationOnStart: boolean;
  84401. /**
  84402. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84403. */
  84404. beginAnimationFrom: number;
  84405. /**
  84406. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84407. */
  84408. beginAnimationTo: number;
  84409. /**
  84410. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84411. */
  84412. beginAnimationLoop: boolean;
  84413. /**
  84414. * Gets or sets a world offset applied to all particles
  84415. */
  84416. worldOffset: Vector3;
  84417. /**
  84418. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84419. */
  84420. get isAnimationSheetEnabled(): boolean;
  84421. set isAnimationSheetEnabled(value: boolean);
  84422. /**
  84423. * Get hosting scene
  84424. * @returns the scene
  84425. */
  84426. getScene(): Scene;
  84427. /**
  84428. * You can use gravity if you want to give an orientation to your particles.
  84429. */
  84430. gravity: Vector3;
  84431. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84432. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84433. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84434. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84435. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84436. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84437. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84438. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84439. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84440. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84441. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84442. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84443. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84444. /**
  84445. * Defines the delay in milliseconds before starting the system (0 by default)
  84446. */
  84447. startDelay: number;
  84448. /**
  84449. * Gets the current list of drag gradients.
  84450. * You must use addDragGradient and removeDragGradient to udpate this list
  84451. * @returns the list of drag gradients
  84452. */
  84453. getDragGradients(): Nullable<Array<FactorGradient>>;
  84454. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84455. limitVelocityDamping: number;
  84456. /**
  84457. * Gets the current list of limit velocity gradients.
  84458. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84459. * @returns the list of limit velocity gradients
  84460. */
  84461. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84462. /**
  84463. * Gets the current list of color gradients.
  84464. * You must use addColorGradient and removeColorGradient to udpate this list
  84465. * @returns the list of color gradients
  84466. */
  84467. getColorGradients(): Nullable<Array<ColorGradient>>;
  84468. /**
  84469. * Gets the current list of size gradients.
  84470. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84471. * @returns the list of size gradients
  84472. */
  84473. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84474. /**
  84475. * Gets the current list of color remap gradients.
  84476. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84477. * @returns the list of color remap gradients
  84478. */
  84479. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84480. /**
  84481. * Gets the current list of alpha remap gradients.
  84482. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84483. * @returns the list of alpha remap gradients
  84484. */
  84485. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84486. /**
  84487. * Gets the current list of life time gradients.
  84488. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84489. * @returns the list of life time gradients
  84490. */
  84491. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84492. /**
  84493. * Gets the current list of angular speed gradients.
  84494. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84495. * @returns the list of angular speed gradients
  84496. */
  84497. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84498. /**
  84499. * Gets the current list of velocity gradients.
  84500. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84501. * @returns the list of velocity gradients
  84502. */
  84503. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84504. /**
  84505. * Gets the current list of start size gradients.
  84506. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84507. * @returns the list of start size gradients
  84508. */
  84509. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84510. /**
  84511. * Gets the current list of emit rate gradients.
  84512. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84513. * @returns the list of emit rate gradients
  84514. */
  84515. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84516. /**
  84517. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84518. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84519. */
  84520. get direction1(): Vector3;
  84521. set direction1(value: Vector3);
  84522. /**
  84523. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84524. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84525. */
  84526. get direction2(): Vector3;
  84527. set direction2(value: Vector3);
  84528. /**
  84529. * 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.
  84530. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84531. */
  84532. get minEmitBox(): Vector3;
  84533. set minEmitBox(value: Vector3);
  84534. /**
  84535. * 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.
  84536. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84537. */
  84538. get maxEmitBox(): Vector3;
  84539. set maxEmitBox(value: Vector3);
  84540. /**
  84541. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84542. */
  84543. color1: Color4;
  84544. /**
  84545. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84546. */
  84547. color2: Color4;
  84548. /**
  84549. * Color the particle will have at the end of its lifetime
  84550. */
  84551. colorDead: Color4;
  84552. /**
  84553. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84554. */
  84555. textureMask: Color4;
  84556. /**
  84557. * The particle emitter type defines the emitter used by the particle system.
  84558. * It can be for example box, sphere, or cone...
  84559. */
  84560. particleEmitterType: IParticleEmitterType;
  84561. /** @hidden */
  84562. _isSubEmitter: boolean;
  84563. /**
  84564. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84565. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84566. */
  84567. billboardMode: number;
  84568. protected _isBillboardBased: boolean;
  84569. /**
  84570. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84571. */
  84572. get isBillboardBased(): boolean;
  84573. set isBillboardBased(value: boolean);
  84574. /**
  84575. * The scene the particle system belongs to.
  84576. */
  84577. protected _scene: Scene;
  84578. /**
  84579. * Local cache of defines for image processing.
  84580. */
  84581. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84582. /**
  84583. * Default configuration related to image processing available in the standard Material.
  84584. */
  84585. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84586. /**
  84587. * Gets the image processing configuration used either in this material.
  84588. */
  84589. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84590. /**
  84591. * Sets the Default image processing configuration used either in the this material.
  84592. *
  84593. * If sets to null, the scene one is in use.
  84594. */
  84595. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84596. /**
  84597. * Attaches a new image processing configuration to the Standard Material.
  84598. * @param configuration
  84599. */
  84600. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84601. /** @hidden */
  84602. protected _reset(): void;
  84603. /** @hidden */
  84604. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84605. /**
  84606. * Instantiates a particle system.
  84607. * 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.
  84608. * @param name The name of the particle system
  84609. */
  84610. constructor(name: string);
  84611. /**
  84612. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84613. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84614. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84615. * @returns the emitter
  84616. */
  84617. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84618. /**
  84619. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84620. * @param radius The radius of the hemisphere to emit from
  84621. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84622. * @returns the emitter
  84623. */
  84624. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84625. /**
  84626. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84627. * @param radius The radius of the sphere to emit from
  84628. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84629. * @returns the emitter
  84630. */
  84631. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84632. /**
  84633. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84634. * @param radius The radius of the sphere to emit from
  84635. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84636. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84637. * @returns the emitter
  84638. */
  84639. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84640. /**
  84641. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84642. * @param radius The radius of the emission cylinder
  84643. * @param height The height of the emission cylinder
  84644. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84645. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84646. * @returns the emitter
  84647. */
  84648. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84649. /**
  84650. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84651. * @param radius The radius of the cylinder to emit from
  84652. * @param height The height of the emission cylinder
  84653. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84656. * @returns the emitter
  84657. */
  84658. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84659. /**
  84660. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84661. * @param radius The radius of the cone to emit from
  84662. * @param angle The base angle of the cone
  84663. * @returns the emitter
  84664. */
  84665. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84666. /**
  84667. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84670. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84671. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84672. * @returns the emitter
  84673. */
  84674. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84675. }
  84676. }
  84677. declare module BABYLON {
  84678. /**
  84679. * Type of sub emitter
  84680. */
  84681. export enum SubEmitterType {
  84682. /**
  84683. * Attached to the particle over it's lifetime
  84684. */
  84685. ATTACHED = 0,
  84686. /**
  84687. * Created when the particle dies
  84688. */
  84689. END = 1
  84690. }
  84691. /**
  84692. * Sub emitter class used to emit particles from an existing particle
  84693. */
  84694. export class SubEmitter {
  84695. /**
  84696. * the particle system to be used by the sub emitter
  84697. */
  84698. particleSystem: ParticleSystem;
  84699. /**
  84700. * Type of the submitter (Default: END)
  84701. */
  84702. type: SubEmitterType;
  84703. /**
  84704. * 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)
  84705. * Note: This only is supported when using an emitter of type Mesh
  84706. */
  84707. inheritDirection: boolean;
  84708. /**
  84709. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84710. */
  84711. inheritedVelocityAmount: number;
  84712. /**
  84713. * Creates a sub emitter
  84714. * @param particleSystem the particle system to be used by the sub emitter
  84715. */
  84716. constructor(
  84717. /**
  84718. * the particle system to be used by the sub emitter
  84719. */
  84720. particleSystem: ParticleSystem);
  84721. /**
  84722. * Clones the sub emitter
  84723. * @returns the cloned sub emitter
  84724. */
  84725. clone(): SubEmitter;
  84726. /**
  84727. * Serialize current object to a JSON object
  84728. * @returns the serialized object
  84729. */
  84730. serialize(): any;
  84731. /** @hidden */
  84732. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84733. /**
  84734. * Creates a new SubEmitter from a serialized JSON version
  84735. * @param serializationObject defines the JSON object to read from
  84736. * @param scene defines the hosting scene
  84737. * @param rootUrl defines the rootUrl for data loading
  84738. * @returns a new SubEmitter
  84739. */
  84740. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84741. /** Release associated resources */
  84742. dispose(): void;
  84743. }
  84744. }
  84745. declare module BABYLON {
  84746. /** @hidden */
  84747. export var imageProcessingDeclaration: {
  84748. name: string;
  84749. shader: string;
  84750. };
  84751. }
  84752. declare module BABYLON {
  84753. /** @hidden */
  84754. export var imageProcessingFunctions: {
  84755. name: string;
  84756. shader: string;
  84757. };
  84758. }
  84759. declare module BABYLON {
  84760. /** @hidden */
  84761. export var particlesPixelShader: {
  84762. name: string;
  84763. shader: string;
  84764. };
  84765. }
  84766. declare module BABYLON {
  84767. /** @hidden */
  84768. export var particlesVertexShader: {
  84769. name: string;
  84770. shader: string;
  84771. };
  84772. }
  84773. declare module BABYLON {
  84774. /**
  84775. * This represents a particle system in Babylon.
  84776. * 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.
  84777. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84778. * @example https://doc.babylonjs.com/babylon101/particles
  84779. */
  84780. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84781. /**
  84782. * Billboard mode will only apply to Y axis
  84783. */
  84784. static readonly BILLBOARDMODE_Y: number;
  84785. /**
  84786. * Billboard mode will apply to all axes
  84787. */
  84788. static readonly BILLBOARDMODE_ALL: number;
  84789. /**
  84790. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84791. */
  84792. static readonly BILLBOARDMODE_STRETCHED: number;
  84793. /**
  84794. * This function can be defined to provide custom update for active particles.
  84795. * This function will be called instead of regular update (age, position, color, etc.).
  84796. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84797. */
  84798. updateFunction: (particles: Particle[]) => void;
  84799. private _emitterWorldMatrix;
  84800. /**
  84801. * This function can be defined to specify initial direction for every new particle.
  84802. * It by default use the emitterType defined function
  84803. */
  84804. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  84805. /**
  84806. * This function can be defined to specify initial position for every new particle.
  84807. * It by default use the emitterType defined function
  84808. */
  84809. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  84810. /**
  84811. * @hidden
  84812. */
  84813. _inheritedVelocityOffset: Vector3;
  84814. /**
  84815. * An event triggered when the system is disposed
  84816. */
  84817. onDisposeObservable: Observable<ParticleSystem>;
  84818. private _onDisposeObserver;
  84819. /**
  84820. * Sets a callback that will be triggered when the system is disposed
  84821. */
  84822. set onDispose(callback: () => void);
  84823. private _particles;
  84824. private _epsilon;
  84825. private _capacity;
  84826. private _stockParticles;
  84827. private _newPartsExcess;
  84828. private _vertexData;
  84829. private _vertexBuffer;
  84830. private _vertexBuffers;
  84831. private _spriteBuffer;
  84832. private _indexBuffer;
  84833. private _effect;
  84834. private _customEffect;
  84835. private _cachedDefines;
  84836. private _scaledColorStep;
  84837. private _colorDiff;
  84838. private _scaledDirection;
  84839. private _scaledGravity;
  84840. private _currentRenderId;
  84841. private _alive;
  84842. private _useInstancing;
  84843. private _started;
  84844. private _stopped;
  84845. private _actualFrame;
  84846. private _scaledUpdateSpeed;
  84847. private _vertexBufferSize;
  84848. /** @hidden */
  84849. _currentEmitRateGradient: Nullable<FactorGradient>;
  84850. /** @hidden */
  84851. _currentEmitRate1: number;
  84852. /** @hidden */
  84853. _currentEmitRate2: number;
  84854. /** @hidden */
  84855. _currentStartSizeGradient: Nullable<FactorGradient>;
  84856. /** @hidden */
  84857. _currentStartSize1: number;
  84858. /** @hidden */
  84859. _currentStartSize2: number;
  84860. private readonly _rawTextureWidth;
  84861. private _rampGradientsTexture;
  84862. private _useRampGradients;
  84863. /** Gets or sets a boolean indicating that ramp gradients must be used
  84864. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84865. */
  84866. get useRampGradients(): boolean;
  84867. set useRampGradients(value: boolean);
  84868. /**
  84869. * 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.
  84870. * 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: [])
  84871. */
  84872. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84873. private _subEmitters;
  84874. /**
  84875. * @hidden
  84876. * If the particle systems emitter should be disposed when the particle system is disposed
  84877. */
  84878. _disposeEmitterOnDispose: boolean;
  84879. /**
  84880. * The current active Sub-systems, this property is used by the root particle system only.
  84881. */
  84882. activeSubSystems: Array<ParticleSystem>;
  84883. /**
  84884. * Specifies if the particles are updated in emitter local space or world space
  84885. */
  84886. isLocal: boolean;
  84887. private _rootParticleSystem;
  84888. /**
  84889. * Gets the current list of active particles
  84890. */
  84891. get particles(): Particle[];
  84892. /**
  84893. * Returns the string "ParticleSystem"
  84894. * @returns a string containing the class name
  84895. */
  84896. getClassName(): string;
  84897. /**
  84898. * Instantiates a particle system.
  84899. * 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.
  84900. * @param name The name of the particle system
  84901. * @param capacity The max number of particles alive at the same time
  84902. * @param scene The scene the particle system belongs to
  84903. * @param customEffect a custom effect used to change the way particles are rendered by default
  84904. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84905. * @param epsilon Offset used to render the particles
  84906. */
  84907. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84908. private _addFactorGradient;
  84909. private _removeFactorGradient;
  84910. /**
  84911. * Adds a new life time gradient
  84912. * @param gradient defines the gradient to use (between 0 and 1)
  84913. * @param factor defines the life time factor to affect to the specified gradient
  84914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84915. * @returns the current particle system
  84916. */
  84917. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84918. /**
  84919. * Remove a specific life time gradient
  84920. * @param gradient defines the gradient to remove
  84921. * @returns the current particle system
  84922. */
  84923. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84924. /**
  84925. * Adds a new size gradient
  84926. * @param gradient defines the gradient to use (between 0 and 1)
  84927. * @param factor defines the size factor to affect to the specified gradient
  84928. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84929. * @returns the current particle system
  84930. */
  84931. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84932. /**
  84933. * Remove a specific size gradient
  84934. * @param gradient defines the gradient to remove
  84935. * @returns the current particle system
  84936. */
  84937. removeSizeGradient(gradient: number): IParticleSystem;
  84938. /**
  84939. * Adds a new color remap gradient
  84940. * @param gradient defines the gradient to use (between 0 and 1)
  84941. * @param min defines the color remap minimal range
  84942. * @param max defines the color remap maximal range
  84943. * @returns the current particle system
  84944. */
  84945. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84946. /**
  84947. * Remove a specific color remap gradient
  84948. * @param gradient defines the gradient to remove
  84949. * @returns the current particle system
  84950. */
  84951. removeColorRemapGradient(gradient: number): IParticleSystem;
  84952. /**
  84953. * Adds a new alpha remap gradient
  84954. * @param gradient defines the gradient to use (between 0 and 1)
  84955. * @param min defines the alpha remap minimal range
  84956. * @param max defines the alpha remap maximal range
  84957. * @returns the current particle system
  84958. */
  84959. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84960. /**
  84961. * Remove a specific alpha remap gradient
  84962. * @param gradient defines the gradient to remove
  84963. * @returns the current particle system
  84964. */
  84965. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84966. /**
  84967. * Adds a new angular speed gradient
  84968. * @param gradient defines the gradient to use (between 0 and 1)
  84969. * @param factor defines the angular speed to affect to the specified gradient
  84970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84971. * @returns the current particle system
  84972. */
  84973. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84974. /**
  84975. * Remove a specific angular speed gradient
  84976. * @param gradient defines the gradient to remove
  84977. * @returns the current particle system
  84978. */
  84979. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84980. /**
  84981. * Adds a new velocity gradient
  84982. * @param gradient defines the gradient to use (between 0 and 1)
  84983. * @param factor defines the velocity to affect to the specified gradient
  84984. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84985. * @returns the current particle system
  84986. */
  84987. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84988. /**
  84989. * Remove a specific velocity gradient
  84990. * @param gradient defines the gradient to remove
  84991. * @returns the current particle system
  84992. */
  84993. removeVelocityGradient(gradient: number): IParticleSystem;
  84994. /**
  84995. * Adds a new limit velocity gradient
  84996. * @param gradient defines the gradient to use (between 0 and 1)
  84997. * @param factor defines the limit velocity value to affect to the specified gradient
  84998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84999. * @returns the current particle system
  85000. */
  85001. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85002. /**
  85003. * Remove a specific limit velocity gradient
  85004. * @param gradient defines the gradient to remove
  85005. * @returns the current particle system
  85006. */
  85007. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85008. /**
  85009. * Adds a new drag gradient
  85010. * @param gradient defines the gradient to use (between 0 and 1)
  85011. * @param factor defines the drag value to affect to the specified gradient
  85012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85013. * @returns the current particle system
  85014. */
  85015. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85016. /**
  85017. * Remove a specific drag gradient
  85018. * @param gradient defines the gradient to remove
  85019. * @returns the current particle system
  85020. */
  85021. removeDragGradient(gradient: number): IParticleSystem;
  85022. /**
  85023. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85024. * @param gradient defines the gradient to use (between 0 and 1)
  85025. * @param factor defines the emit rate value to affect to the specified gradient
  85026. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85027. * @returns the current particle system
  85028. */
  85029. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85030. /**
  85031. * Remove a specific emit rate gradient
  85032. * @param gradient defines the gradient to remove
  85033. * @returns the current particle system
  85034. */
  85035. removeEmitRateGradient(gradient: number): IParticleSystem;
  85036. /**
  85037. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85038. * @param gradient defines the gradient to use (between 0 and 1)
  85039. * @param factor defines the start size value to affect to the specified gradient
  85040. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85041. * @returns the current particle system
  85042. */
  85043. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85044. /**
  85045. * Remove a specific start size gradient
  85046. * @param gradient defines the gradient to remove
  85047. * @returns the current particle system
  85048. */
  85049. removeStartSizeGradient(gradient: number): IParticleSystem;
  85050. private _createRampGradientTexture;
  85051. /**
  85052. * Gets the current list of ramp gradients.
  85053. * You must use addRampGradient and removeRampGradient to udpate this list
  85054. * @returns the list of ramp gradients
  85055. */
  85056. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85057. /**
  85058. * Adds a new ramp gradient used to remap particle colors
  85059. * @param gradient defines the gradient to use (between 0 and 1)
  85060. * @param color defines the color to affect to the specified gradient
  85061. * @returns the current particle system
  85062. */
  85063. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85064. /**
  85065. * Remove a specific ramp gradient
  85066. * @param gradient defines the gradient to remove
  85067. * @returns the current particle system
  85068. */
  85069. removeRampGradient(gradient: number): ParticleSystem;
  85070. /**
  85071. * Adds a new color gradient
  85072. * @param gradient defines the gradient to use (between 0 and 1)
  85073. * @param color1 defines the color to affect to the specified gradient
  85074. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85075. * @returns this particle system
  85076. */
  85077. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85078. /**
  85079. * Remove a specific color gradient
  85080. * @param gradient defines the gradient to remove
  85081. * @returns this particle system
  85082. */
  85083. removeColorGradient(gradient: number): IParticleSystem;
  85084. private _fetchR;
  85085. protected _reset(): void;
  85086. private _resetEffect;
  85087. private _createVertexBuffers;
  85088. private _createIndexBuffer;
  85089. /**
  85090. * Gets the maximum number of particles active at the same time.
  85091. * @returns The max number of active particles.
  85092. */
  85093. getCapacity(): number;
  85094. /**
  85095. * Gets whether there are still active particles in the system.
  85096. * @returns True if it is alive, otherwise false.
  85097. */
  85098. isAlive(): boolean;
  85099. /**
  85100. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85101. * @returns True if it has been started, otherwise false.
  85102. */
  85103. isStarted(): boolean;
  85104. private _prepareSubEmitterInternalArray;
  85105. /**
  85106. * Starts the particle system and begins to emit
  85107. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85108. */
  85109. start(delay?: number): void;
  85110. /**
  85111. * Stops the particle system.
  85112. * @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.
  85113. */
  85114. stop(stopSubEmitters?: boolean): void;
  85115. /**
  85116. * Remove all active particles
  85117. */
  85118. reset(): void;
  85119. /**
  85120. * @hidden (for internal use only)
  85121. */
  85122. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85123. /**
  85124. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85125. * Its lifetime will start back at 0.
  85126. */
  85127. recycleParticle: (particle: Particle) => void;
  85128. private _stopSubEmitters;
  85129. private _createParticle;
  85130. private _removeFromRoot;
  85131. private _emitFromParticle;
  85132. private _update;
  85133. /** @hidden */
  85134. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85135. /** @hidden */
  85136. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85137. /** @hidden */
  85138. private _getEffect;
  85139. /**
  85140. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85141. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85142. */
  85143. animate(preWarmOnly?: boolean): void;
  85144. private _appendParticleVertices;
  85145. /**
  85146. * Rebuilds the particle system.
  85147. */
  85148. rebuild(): void;
  85149. /**
  85150. * Is this system ready to be used/rendered
  85151. * @return true if the system is ready
  85152. */
  85153. isReady(): boolean;
  85154. private _render;
  85155. /**
  85156. * Renders the particle system in its current state.
  85157. * @returns the current number of particles
  85158. */
  85159. render(): number;
  85160. /**
  85161. * Disposes the particle system and free the associated resources
  85162. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85163. */
  85164. dispose(disposeTexture?: boolean): void;
  85165. /**
  85166. * Clones the particle system.
  85167. * @param name The name of the cloned object
  85168. * @param newEmitter The new emitter to use
  85169. * @returns the cloned particle system
  85170. */
  85171. clone(name: string, newEmitter: any): ParticleSystem;
  85172. /**
  85173. * Serializes the particle system to a JSON object.
  85174. * @returns the JSON object
  85175. */
  85176. serialize(): any;
  85177. /** @hidden */
  85178. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85179. /** @hidden */
  85180. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85181. /**
  85182. * Parses a JSON object to create a particle system.
  85183. * @param parsedParticleSystem The JSON object to parse
  85184. * @param scene The scene to create the particle system in
  85185. * @param rootUrl The root url to use to load external dependencies like texture
  85186. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85187. * @returns the Parsed particle system
  85188. */
  85189. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85190. }
  85191. }
  85192. declare module BABYLON {
  85193. /**
  85194. * A particle represents one of the element emitted by a particle system.
  85195. * This is mainly define by its coordinates, direction, velocity and age.
  85196. */
  85197. export class Particle {
  85198. /**
  85199. * The particle system the particle belongs to.
  85200. */
  85201. particleSystem: ParticleSystem;
  85202. private static _Count;
  85203. /**
  85204. * Unique ID of the particle
  85205. */
  85206. id: number;
  85207. /**
  85208. * The world position of the particle in the scene.
  85209. */
  85210. position: Vector3;
  85211. /**
  85212. * The world direction of the particle in the scene.
  85213. */
  85214. direction: Vector3;
  85215. /**
  85216. * The color of the particle.
  85217. */
  85218. color: Color4;
  85219. /**
  85220. * The color change of the particle per step.
  85221. */
  85222. colorStep: Color4;
  85223. /**
  85224. * Defines how long will the life of the particle be.
  85225. */
  85226. lifeTime: number;
  85227. /**
  85228. * The current age of the particle.
  85229. */
  85230. age: number;
  85231. /**
  85232. * The current size of the particle.
  85233. */
  85234. size: number;
  85235. /**
  85236. * The current scale of the particle.
  85237. */
  85238. scale: Vector2;
  85239. /**
  85240. * The current angle of the particle.
  85241. */
  85242. angle: number;
  85243. /**
  85244. * Defines how fast is the angle changing.
  85245. */
  85246. angularSpeed: number;
  85247. /**
  85248. * Defines the cell index used by the particle to be rendered from a sprite.
  85249. */
  85250. cellIndex: number;
  85251. /**
  85252. * The information required to support color remapping
  85253. */
  85254. remapData: Vector4;
  85255. /** @hidden */
  85256. _randomCellOffset?: number;
  85257. /** @hidden */
  85258. _initialDirection: Nullable<Vector3>;
  85259. /** @hidden */
  85260. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85261. /** @hidden */
  85262. _initialStartSpriteCellID: number;
  85263. /** @hidden */
  85264. _initialEndSpriteCellID: number;
  85265. /** @hidden */
  85266. _currentColorGradient: Nullable<ColorGradient>;
  85267. /** @hidden */
  85268. _currentColor1: Color4;
  85269. /** @hidden */
  85270. _currentColor2: Color4;
  85271. /** @hidden */
  85272. _currentSizeGradient: Nullable<FactorGradient>;
  85273. /** @hidden */
  85274. _currentSize1: number;
  85275. /** @hidden */
  85276. _currentSize2: number;
  85277. /** @hidden */
  85278. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85279. /** @hidden */
  85280. _currentAngularSpeed1: number;
  85281. /** @hidden */
  85282. _currentAngularSpeed2: number;
  85283. /** @hidden */
  85284. _currentVelocityGradient: Nullable<FactorGradient>;
  85285. /** @hidden */
  85286. _currentVelocity1: number;
  85287. /** @hidden */
  85288. _currentVelocity2: number;
  85289. /** @hidden */
  85290. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85291. /** @hidden */
  85292. _currentLimitVelocity1: number;
  85293. /** @hidden */
  85294. _currentLimitVelocity2: number;
  85295. /** @hidden */
  85296. _currentDragGradient: Nullable<FactorGradient>;
  85297. /** @hidden */
  85298. _currentDrag1: number;
  85299. /** @hidden */
  85300. _currentDrag2: number;
  85301. /** @hidden */
  85302. _randomNoiseCoordinates1: Vector3;
  85303. /** @hidden */
  85304. _randomNoiseCoordinates2: Vector3;
  85305. /** @hidden */
  85306. _localPosition?: Vector3;
  85307. /**
  85308. * Creates a new instance Particle
  85309. * @param particleSystem the particle system the particle belongs to
  85310. */
  85311. constructor(
  85312. /**
  85313. * The particle system the particle belongs to.
  85314. */
  85315. particleSystem: ParticleSystem);
  85316. private updateCellInfoFromSystem;
  85317. /**
  85318. * Defines how the sprite cell index is updated for the particle
  85319. */
  85320. updateCellIndex(): void;
  85321. /** @hidden */
  85322. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85323. /** @hidden */
  85324. _inheritParticleInfoToSubEmitters(): void;
  85325. /** @hidden */
  85326. _reset(): void;
  85327. /**
  85328. * Copy the properties of particle to another one.
  85329. * @param other the particle to copy the information to.
  85330. */
  85331. copyTo(other: Particle): void;
  85332. }
  85333. }
  85334. declare module BABYLON {
  85335. /**
  85336. * Particle emitter represents a volume emitting particles.
  85337. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85338. */
  85339. export interface IParticleEmitterType {
  85340. /**
  85341. * Called by the particle System when the direction is computed for the created particle.
  85342. * @param worldMatrix is the world matrix of the particle system
  85343. * @param directionToUpdate is the direction vector to update with the result
  85344. * @param particle is the particle we are computed the direction for
  85345. * @param isLocal defines if the direction should be set in local space
  85346. */
  85347. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85348. /**
  85349. * Called by the particle System when the position is computed for the created particle.
  85350. * @param worldMatrix is the world matrix of the particle system
  85351. * @param positionToUpdate is the position vector to update with the result
  85352. * @param particle is the particle we are computed the position for
  85353. * @param isLocal defines if the position should be set in local space
  85354. */
  85355. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85356. /**
  85357. * Clones the current emitter and returns a copy of it
  85358. * @returns the new emitter
  85359. */
  85360. clone(): IParticleEmitterType;
  85361. /**
  85362. * Called by the GPUParticleSystem to setup the update shader
  85363. * @param effect defines the update shader
  85364. */
  85365. applyToShader(effect: Effect): void;
  85366. /**
  85367. * Returns a string to use to update the GPU particles update shader
  85368. * @returns the effect defines string
  85369. */
  85370. getEffectDefines(): string;
  85371. /**
  85372. * Returns a string representing the class name
  85373. * @returns a string containing the class name
  85374. */
  85375. getClassName(): string;
  85376. /**
  85377. * Serializes the particle system to a JSON object.
  85378. * @returns the JSON object
  85379. */
  85380. serialize(): any;
  85381. /**
  85382. * Parse properties from a JSON object
  85383. * @param serializationObject defines the JSON object
  85384. * @param scene defines the hosting scene
  85385. */
  85386. parse(serializationObject: any, scene: Scene): void;
  85387. }
  85388. }
  85389. declare module BABYLON {
  85390. /**
  85391. * Particle emitter emitting particles from the inside of a box.
  85392. * It emits the particles randomly between 2 given directions.
  85393. */
  85394. export class BoxParticleEmitter implements IParticleEmitterType {
  85395. /**
  85396. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85397. */
  85398. direction1: Vector3;
  85399. /**
  85400. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85401. */
  85402. direction2: Vector3;
  85403. /**
  85404. * 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.
  85405. */
  85406. minEmitBox: Vector3;
  85407. /**
  85408. * 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.
  85409. */
  85410. maxEmitBox: Vector3;
  85411. /**
  85412. * Creates a new instance BoxParticleEmitter
  85413. */
  85414. constructor();
  85415. /**
  85416. * Called by the particle System when the direction is computed for the created particle.
  85417. * @param worldMatrix is the world matrix of the particle system
  85418. * @param directionToUpdate is the direction vector to update with the result
  85419. * @param particle is the particle we are computed the direction for
  85420. * @param isLocal defines if the direction should be set in local space
  85421. */
  85422. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85423. /**
  85424. * Called by the particle System when the position is computed for the created particle.
  85425. * @param worldMatrix is the world matrix of the particle system
  85426. * @param positionToUpdate is the position vector to update with the result
  85427. * @param particle is the particle we are computed the position for
  85428. * @param isLocal defines if the position should be set in local space
  85429. */
  85430. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85431. /**
  85432. * Clones the current emitter and returns a copy of it
  85433. * @returns the new emitter
  85434. */
  85435. clone(): BoxParticleEmitter;
  85436. /**
  85437. * Called by the GPUParticleSystem to setup the update shader
  85438. * @param effect defines the update shader
  85439. */
  85440. applyToShader(effect: Effect): void;
  85441. /**
  85442. * Returns a string to use to update the GPU particles update shader
  85443. * @returns a string containng the defines string
  85444. */
  85445. getEffectDefines(): string;
  85446. /**
  85447. * Returns the string "BoxParticleEmitter"
  85448. * @returns a string containing the class name
  85449. */
  85450. getClassName(): string;
  85451. /**
  85452. * Serializes the particle system to a JSON object.
  85453. * @returns the JSON object
  85454. */
  85455. serialize(): any;
  85456. /**
  85457. * Parse properties from a JSON object
  85458. * @param serializationObject defines the JSON object
  85459. */
  85460. parse(serializationObject: any): void;
  85461. }
  85462. }
  85463. declare module BABYLON {
  85464. /**
  85465. * Particle emitter emitting particles from the inside of a cone.
  85466. * It emits the particles alongside the cone volume from the base to the particle.
  85467. * The emission direction might be randomized.
  85468. */
  85469. export class ConeParticleEmitter implements IParticleEmitterType {
  85470. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85471. directionRandomizer: number;
  85472. private _radius;
  85473. private _angle;
  85474. private _height;
  85475. /**
  85476. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85477. */
  85478. radiusRange: number;
  85479. /**
  85480. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85481. */
  85482. heightRange: number;
  85483. /**
  85484. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85485. */
  85486. emitFromSpawnPointOnly: boolean;
  85487. /**
  85488. * Gets or sets the radius of the emission cone
  85489. */
  85490. get radius(): number;
  85491. set radius(value: number);
  85492. /**
  85493. * Gets or sets the angle of the emission cone
  85494. */
  85495. get angle(): number;
  85496. set angle(value: number);
  85497. private _buildHeight;
  85498. /**
  85499. * Creates a new instance ConeParticleEmitter
  85500. * @param radius the radius of the emission cone (1 by default)
  85501. * @param angle the cone base angle (PI by default)
  85502. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85503. */
  85504. constructor(radius?: number, angle?: number,
  85505. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85506. directionRandomizer?: number);
  85507. /**
  85508. * Called by the particle System when the direction is computed for the created particle.
  85509. * @param worldMatrix is the world matrix of the particle system
  85510. * @param directionToUpdate is the direction vector to update with the result
  85511. * @param particle is the particle we are computed the direction for
  85512. * @param isLocal defines if the direction should be set in local space
  85513. */
  85514. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85515. /**
  85516. * Called by the particle System when the position is computed for the created particle.
  85517. * @param worldMatrix is the world matrix of the particle system
  85518. * @param positionToUpdate is the position vector to update with the result
  85519. * @param particle is the particle we are computed the position for
  85520. * @param isLocal defines if the position should be set in local space
  85521. */
  85522. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85523. /**
  85524. * Clones the current emitter and returns a copy of it
  85525. * @returns the new emitter
  85526. */
  85527. clone(): ConeParticleEmitter;
  85528. /**
  85529. * Called by the GPUParticleSystem to setup the update shader
  85530. * @param effect defines the update shader
  85531. */
  85532. applyToShader(effect: Effect): void;
  85533. /**
  85534. * Returns a string to use to update the GPU particles update shader
  85535. * @returns a string containng the defines string
  85536. */
  85537. getEffectDefines(): string;
  85538. /**
  85539. * Returns the string "ConeParticleEmitter"
  85540. * @returns a string containing the class name
  85541. */
  85542. getClassName(): string;
  85543. /**
  85544. * Serializes the particle system to a JSON object.
  85545. * @returns the JSON object
  85546. */
  85547. serialize(): any;
  85548. /**
  85549. * Parse properties from a JSON object
  85550. * @param serializationObject defines the JSON object
  85551. */
  85552. parse(serializationObject: any): void;
  85553. }
  85554. }
  85555. declare module BABYLON {
  85556. /**
  85557. * Particle emitter emitting particles from the inside of a cylinder.
  85558. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85559. */
  85560. export class CylinderParticleEmitter implements IParticleEmitterType {
  85561. /**
  85562. * The radius of the emission cylinder.
  85563. */
  85564. radius: number;
  85565. /**
  85566. * The height of the emission cylinder.
  85567. */
  85568. height: number;
  85569. /**
  85570. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85571. */
  85572. radiusRange: number;
  85573. /**
  85574. * How much to randomize the particle direction [0-1].
  85575. */
  85576. directionRandomizer: number;
  85577. /**
  85578. * Creates a new instance CylinderParticleEmitter
  85579. * @param radius the radius of the emission cylinder (1 by default)
  85580. * @param height the height of the emission cylinder (1 by default)
  85581. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85582. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85583. */
  85584. constructor(
  85585. /**
  85586. * The radius of the emission cylinder.
  85587. */
  85588. radius?: number,
  85589. /**
  85590. * The height of the emission cylinder.
  85591. */
  85592. height?: number,
  85593. /**
  85594. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85595. */
  85596. radiusRange?: number,
  85597. /**
  85598. * How much to randomize the particle direction [0-1].
  85599. */
  85600. directionRandomizer?: number);
  85601. /**
  85602. * Called by the particle System when the direction is computed for the created particle.
  85603. * @param worldMatrix is the world matrix of the particle system
  85604. * @param directionToUpdate is the direction vector to update with the result
  85605. * @param particle is the particle we are computed the direction for
  85606. * @param isLocal defines if the direction should be set in local space
  85607. */
  85608. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85609. /**
  85610. * Called by the particle System when the position is computed for the created particle.
  85611. * @param worldMatrix is the world matrix of the particle system
  85612. * @param positionToUpdate is the position vector to update with the result
  85613. * @param particle is the particle we are computed the position for
  85614. * @param isLocal defines if the position should be set in local space
  85615. */
  85616. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85617. /**
  85618. * Clones the current emitter and returns a copy of it
  85619. * @returns the new emitter
  85620. */
  85621. clone(): CylinderParticleEmitter;
  85622. /**
  85623. * Called by the GPUParticleSystem to setup the update shader
  85624. * @param effect defines the update shader
  85625. */
  85626. applyToShader(effect: Effect): void;
  85627. /**
  85628. * Returns a string to use to update the GPU particles update shader
  85629. * @returns a string containng the defines string
  85630. */
  85631. getEffectDefines(): string;
  85632. /**
  85633. * Returns the string "CylinderParticleEmitter"
  85634. * @returns a string containing the class name
  85635. */
  85636. getClassName(): string;
  85637. /**
  85638. * Serializes the particle system to a JSON object.
  85639. * @returns the JSON object
  85640. */
  85641. serialize(): any;
  85642. /**
  85643. * Parse properties from a JSON object
  85644. * @param serializationObject defines the JSON object
  85645. */
  85646. parse(serializationObject: any): void;
  85647. }
  85648. /**
  85649. * Particle emitter emitting particles from the inside of a cylinder.
  85650. * It emits the particles randomly between two vectors.
  85651. */
  85652. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85653. /**
  85654. * The min limit of the emission direction.
  85655. */
  85656. direction1: Vector3;
  85657. /**
  85658. * The max limit of the emission direction.
  85659. */
  85660. direction2: Vector3;
  85661. /**
  85662. * Creates a new instance CylinderDirectedParticleEmitter
  85663. * @param radius the radius of the emission cylinder (1 by default)
  85664. * @param height the height of the emission cylinder (1 by default)
  85665. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85666. * @param direction1 the min limit of the emission direction (up vector by default)
  85667. * @param direction2 the max limit of the emission direction (up vector by default)
  85668. */
  85669. constructor(radius?: number, height?: number, radiusRange?: number,
  85670. /**
  85671. * The min limit of the emission direction.
  85672. */
  85673. direction1?: Vector3,
  85674. /**
  85675. * The max limit of the emission direction.
  85676. */
  85677. direction2?: Vector3);
  85678. /**
  85679. * Called by the particle System when the direction is computed for the created particle.
  85680. * @param worldMatrix is the world matrix of the particle system
  85681. * @param directionToUpdate is the direction vector to update with the result
  85682. * @param particle is the particle we are computed the direction for
  85683. */
  85684. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85685. /**
  85686. * Clones the current emitter and returns a copy of it
  85687. * @returns the new emitter
  85688. */
  85689. clone(): CylinderDirectedParticleEmitter;
  85690. /**
  85691. * Called by the GPUParticleSystem to setup the update shader
  85692. * @param effect defines the update shader
  85693. */
  85694. applyToShader(effect: Effect): void;
  85695. /**
  85696. * Returns a string to use to update the GPU particles update shader
  85697. * @returns a string containng the defines string
  85698. */
  85699. getEffectDefines(): string;
  85700. /**
  85701. * Returns the string "CylinderDirectedParticleEmitter"
  85702. * @returns a string containing the class name
  85703. */
  85704. getClassName(): string;
  85705. /**
  85706. * Serializes the particle system to a JSON object.
  85707. * @returns the JSON object
  85708. */
  85709. serialize(): any;
  85710. /**
  85711. * Parse properties from a JSON object
  85712. * @param serializationObject defines the JSON object
  85713. */
  85714. parse(serializationObject: any): void;
  85715. }
  85716. }
  85717. declare module BABYLON {
  85718. /**
  85719. * Particle emitter emitting particles from the inside of a hemisphere.
  85720. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85721. */
  85722. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85723. /**
  85724. * The radius of the emission hemisphere.
  85725. */
  85726. radius: number;
  85727. /**
  85728. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85729. */
  85730. radiusRange: number;
  85731. /**
  85732. * How much to randomize the particle direction [0-1].
  85733. */
  85734. directionRandomizer: number;
  85735. /**
  85736. * Creates a new instance HemisphericParticleEmitter
  85737. * @param radius the radius of the emission hemisphere (1 by default)
  85738. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85739. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85740. */
  85741. constructor(
  85742. /**
  85743. * The radius of the emission hemisphere.
  85744. */
  85745. radius?: number,
  85746. /**
  85747. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85748. */
  85749. radiusRange?: number,
  85750. /**
  85751. * How much to randomize the particle direction [0-1].
  85752. */
  85753. directionRandomizer?: number);
  85754. /**
  85755. * Called by the particle System when the direction is computed for the created particle.
  85756. * @param worldMatrix is the world matrix of the particle system
  85757. * @param directionToUpdate is the direction vector to update with the result
  85758. * @param particle is the particle we are computed the direction for
  85759. * @param isLocal defines if the direction should be set in local space
  85760. */
  85761. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85762. /**
  85763. * Called by the particle System when the position is computed for the created particle.
  85764. * @param worldMatrix is the world matrix of the particle system
  85765. * @param positionToUpdate is the position vector to update with the result
  85766. * @param particle is the particle we are computed the position for
  85767. * @param isLocal defines if the position should be set in local space
  85768. */
  85769. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85770. /**
  85771. * Clones the current emitter and returns a copy of it
  85772. * @returns the new emitter
  85773. */
  85774. clone(): HemisphericParticleEmitter;
  85775. /**
  85776. * Called by the GPUParticleSystem to setup the update shader
  85777. * @param effect defines the update shader
  85778. */
  85779. applyToShader(effect: Effect): void;
  85780. /**
  85781. * Returns a string to use to update the GPU particles update shader
  85782. * @returns a string containng the defines string
  85783. */
  85784. getEffectDefines(): string;
  85785. /**
  85786. * Returns the string "HemisphericParticleEmitter"
  85787. * @returns a string containing the class name
  85788. */
  85789. getClassName(): string;
  85790. /**
  85791. * Serializes the particle system to a JSON object.
  85792. * @returns the JSON object
  85793. */
  85794. serialize(): any;
  85795. /**
  85796. * Parse properties from a JSON object
  85797. * @param serializationObject defines the JSON object
  85798. */
  85799. parse(serializationObject: any): void;
  85800. }
  85801. }
  85802. declare module BABYLON {
  85803. /**
  85804. * Particle emitter emitting particles from a point.
  85805. * It emits the particles randomly between 2 given directions.
  85806. */
  85807. export class PointParticleEmitter implements IParticleEmitterType {
  85808. /**
  85809. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85810. */
  85811. direction1: Vector3;
  85812. /**
  85813. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85814. */
  85815. direction2: Vector3;
  85816. /**
  85817. * Creates a new instance PointParticleEmitter
  85818. */
  85819. constructor();
  85820. /**
  85821. * Called by the particle System when the direction is computed for the created particle.
  85822. * @param worldMatrix is the world matrix of the particle system
  85823. * @param directionToUpdate is the direction vector to update with the result
  85824. * @param particle is the particle we are computed the direction for
  85825. * @param isLocal defines if the direction should be set in local space
  85826. */
  85827. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85828. /**
  85829. * Called by the particle System when the position is computed for the created particle.
  85830. * @param worldMatrix is the world matrix of the particle system
  85831. * @param positionToUpdate is the position vector to update with the result
  85832. * @param particle is the particle we are computed the position for
  85833. * @param isLocal defines if the position should be set in local space
  85834. */
  85835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85836. /**
  85837. * Clones the current emitter and returns a copy of it
  85838. * @returns the new emitter
  85839. */
  85840. clone(): PointParticleEmitter;
  85841. /**
  85842. * Called by the GPUParticleSystem to setup the update shader
  85843. * @param effect defines the update shader
  85844. */
  85845. applyToShader(effect: Effect): void;
  85846. /**
  85847. * Returns a string to use to update the GPU particles update shader
  85848. * @returns a string containng the defines string
  85849. */
  85850. getEffectDefines(): string;
  85851. /**
  85852. * Returns the string "PointParticleEmitter"
  85853. * @returns a string containing the class name
  85854. */
  85855. getClassName(): string;
  85856. /**
  85857. * Serializes the particle system to a JSON object.
  85858. * @returns the JSON object
  85859. */
  85860. serialize(): any;
  85861. /**
  85862. * Parse properties from a JSON object
  85863. * @param serializationObject defines the JSON object
  85864. */
  85865. parse(serializationObject: any): void;
  85866. }
  85867. }
  85868. declare module BABYLON {
  85869. /**
  85870. * Particle emitter emitting particles from the inside of a sphere.
  85871. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85872. */
  85873. export class SphereParticleEmitter implements IParticleEmitterType {
  85874. /**
  85875. * The radius of the emission sphere.
  85876. */
  85877. radius: number;
  85878. /**
  85879. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85880. */
  85881. radiusRange: number;
  85882. /**
  85883. * How much to randomize the particle direction [0-1].
  85884. */
  85885. directionRandomizer: number;
  85886. /**
  85887. * Creates a new instance SphereParticleEmitter
  85888. * @param radius the radius of the emission sphere (1 by default)
  85889. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85890. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85891. */
  85892. constructor(
  85893. /**
  85894. * The radius of the emission sphere.
  85895. */
  85896. radius?: number,
  85897. /**
  85898. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85899. */
  85900. radiusRange?: number,
  85901. /**
  85902. * How much to randomize the particle direction [0-1].
  85903. */
  85904. directionRandomizer?: number);
  85905. /**
  85906. * Called by the particle System when the direction is computed for the created particle.
  85907. * @param worldMatrix is the world matrix of the particle system
  85908. * @param directionToUpdate is the direction vector to update with the result
  85909. * @param particle is the particle we are computed the direction for
  85910. * @param isLocal defines if the direction should be set in local space
  85911. */
  85912. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85913. /**
  85914. * Called by the particle System when the position is computed for the created particle.
  85915. * @param worldMatrix is the world matrix of the particle system
  85916. * @param positionToUpdate is the position vector to update with the result
  85917. * @param particle is the particle we are computed the position for
  85918. * @param isLocal defines if the position should be set in local space
  85919. */
  85920. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85921. /**
  85922. * Clones the current emitter and returns a copy of it
  85923. * @returns the new emitter
  85924. */
  85925. clone(): SphereParticleEmitter;
  85926. /**
  85927. * Called by the GPUParticleSystem to setup the update shader
  85928. * @param effect defines the update shader
  85929. */
  85930. applyToShader(effect: Effect): void;
  85931. /**
  85932. * Returns a string to use to update the GPU particles update shader
  85933. * @returns a string containng the defines string
  85934. */
  85935. getEffectDefines(): string;
  85936. /**
  85937. * Returns the string "SphereParticleEmitter"
  85938. * @returns a string containing the class name
  85939. */
  85940. getClassName(): string;
  85941. /**
  85942. * Serializes the particle system to a JSON object.
  85943. * @returns the JSON object
  85944. */
  85945. serialize(): any;
  85946. /**
  85947. * Parse properties from a JSON object
  85948. * @param serializationObject defines the JSON object
  85949. */
  85950. parse(serializationObject: any): void;
  85951. }
  85952. /**
  85953. * Particle emitter emitting particles from the inside of a sphere.
  85954. * It emits the particles randomly between two vectors.
  85955. */
  85956. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85957. /**
  85958. * The min limit of the emission direction.
  85959. */
  85960. direction1: Vector3;
  85961. /**
  85962. * The max limit of the emission direction.
  85963. */
  85964. direction2: Vector3;
  85965. /**
  85966. * Creates a new instance SphereDirectedParticleEmitter
  85967. * @param radius the radius of the emission sphere (1 by default)
  85968. * @param direction1 the min limit of the emission direction (up vector by default)
  85969. * @param direction2 the max limit of the emission direction (up vector by default)
  85970. */
  85971. constructor(radius?: number,
  85972. /**
  85973. * The min limit of the emission direction.
  85974. */
  85975. direction1?: Vector3,
  85976. /**
  85977. * The max limit of the emission direction.
  85978. */
  85979. direction2?: Vector3);
  85980. /**
  85981. * Called by the particle System when the direction is computed for the created particle.
  85982. * @param worldMatrix is the world matrix of the particle system
  85983. * @param directionToUpdate is the direction vector to update with the result
  85984. * @param particle is the particle we are computed the direction for
  85985. */
  85986. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85987. /**
  85988. * Clones the current emitter and returns a copy of it
  85989. * @returns the new emitter
  85990. */
  85991. clone(): SphereDirectedParticleEmitter;
  85992. /**
  85993. * Called by the GPUParticleSystem to setup the update shader
  85994. * @param effect defines the update shader
  85995. */
  85996. applyToShader(effect: Effect): void;
  85997. /**
  85998. * Returns a string to use to update the GPU particles update shader
  85999. * @returns a string containng the defines string
  86000. */
  86001. getEffectDefines(): string;
  86002. /**
  86003. * Returns the string "SphereDirectedParticleEmitter"
  86004. * @returns a string containing the class name
  86005. */
  86006. getClassName(): string;
  86007. /**
  86008. * Serializes the particle system to a JSON object.
  86009. * @returns the JSON object
  86010. */
  86011. serialize(): any;
  86012. /**
  86013. * Parse properties from a JSON object
  86014. * @param serializationObject defines the JSON object
  86015. */
  86016. parse(serializationObject: any): void;
  86017. }
  86018. }
  86019. declare module BABYLON {
  86020. /**
  86021. * Particle emitter emitting particles from a custom list of positions.
  86022. */
  86023. export class CustomParticleEmitter implements IParticleEmitterType {
  86024. /**
  86025. * Gets or sets the position generator that will create the inital position of each particle.
  86026. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86027. */
  86028. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86029. /**
  86030. * Gets or sets the destination generator that will create the final destination of each particle.
  86031. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86032. */
  86033. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86034. /**
  86035. * Creates a new instance CustomParticleEmitter
  86036. */
  86037. constructor();
  86038. /**
  86039. * Called by the particle System when the direction is computed for the created particle.
  86040. * @param worldMatrix is the world matrix of the particle system
  86041. * @param directionToUpdate is the direction vector to update with the result
  86042. * @param particle is the particle we are computed the direction for
  86043. * @param isLocal defines if the direction should be set in local space
  86044. */
  86045. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86046. /**
  86047. * Called by the particle System when the position is computed for the created particle.
  86048. * @param worldMatrix is the world matrix of the particle system
  86049. * @param positionToUpdate is the position vector to update with the result
  86050. * @param particle is the particle we are computed the position for
  86051. * @param isLocal defines if the position should be set in local space
  86052. */
  86053. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86054. /**
  86055. * Clones the current emitter and returns a copy of it
  86056. * @returns the new emitter
  86057. */
  86058. clone(): CustomParticleEmitter;
  86059. /**
  86060. * Called by the GPUParticleSystem to setup the update shader
  86061. * @param effect defines the update shader
  86062. */
  86063. applyToShader(effect: Effect): void;
  86064. /**
  86065. * Returns a string to use to update the GPU particles update shader
  86066. * @returns a string containng the defines string
  86067. */
  86068. getEffectDefines(): string;
  86069. /**
  86070. * Returns the string "PointParticleEmitter"
  86071. * @returns a string containing the class name
  86072. */
  86073. getClassName(): string;
  86074. /**
  86075. * Serializes the particle system to a JSON object.
  86076. * @returns the JSON object
  86077. */
  86078. serialize(): any;
  86079. /**
  86080. * Parse properties from a JSON object
  86081. * @param serializationObject defines the JSON object
  86082. */
  86083. parse(serializationObject: any): void;
  86084. }
  86085. }
  86086. declare module BABYLON {
  86087. /**
  86088. * Particle emitter emitting particles from the inside of a box.
  86089. * It emits the particles randomly between 2 given directions.
  86090. */
  86091. export class MeshParticleEmitter implements IParticleEmitterType {
  86092. /** Defines the mesh to use as source */
  86093. mesh?: AbstractMesh | undefined;
  86094. private _indices;
  86095. private _positions;
  86096. private _normals;
  86097. private _storedNormal;
  86098. /**
  86099. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86100. */
  86101. direction1: Vector3;
  86102. /**
  86103. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86104. */
  86105. direction2: Vector3;
  86106. /**
  86107. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86108. */
  86109. useMeshNormalsForDirection: boolean;
  86110. /**
  86111. * Creates a new instance MeshParticleEmitter
  86112. * @param mesh defines the mesh to use as source
  86113. */
  86114. constructor(
  86115. /** Defines the mesh to use as source */
  86116. mesh?: AbstractMesh | undefined);
  86117. /**
  86118. * Called by the particle System when the direction is computed for the created particle.
  86119. * @param worldMatrix is the world matrix of the particle system
  86120. * @param directionToUpdate is the direction vector to update with the result
  86121. * @param particle is the particle we are computed the direction for
  86122. * @param isLocal defines if the direction should be set in local space
  86123. */
  86124. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86125. /**
  86126. * Called by the particle System when the position is computed for the created particle.
  86127. * @param worldMatrix is the world matrix of the particle system
  86128. * @param positionToUpdate is the position vector to update with the result
  86129. * @param particle is the particle we are computed the position for
  86130. * @param isLocal defines if the position should be set in local space
  86131. */
  86132. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86133. /**
  86134. * Clones the current emitter and returns a copy of it
  86135. * @returns the new emitter
  86136. */
  86137. clone(): MeshParticleEmitter;
  86138. /**
  86139. * Called by the GPUParticleSystem to setup the update shader
  86140. * @param effect defines the update shader
  86141. */
  86142. applyToShader(effect: Effect): void;
  86143. /**
  86144. * Returns a string to use to update the GPU particles update shader
  86145. * @returns a string containng the defines string
  86146. */
  86147. getEffectDefines(): string;
  86148. /**
  86149. * Returns the string "BoxParticleEmitter"
  86150. * @returns a string containing the class name
  86151. */
  86152. getClassName(): string;
  86153. /**
  86154. * Serializes the particle system to a JSON object.
  86155. * @returns the JSON object
  86156. */
  86157. serialize(): any;
  86158. /**
  86159. * Parse properties from a JSON object
  86160. * @param serializationObject defines the JSON object
  86161. * @param scene defines the hosting scene
  86162. */
  86163. parse(serializationObject: any, scene: Scene): void;
  86164. }
  86165. }
  86166. declare module BABYLON {
  86167. /**
  86168. * Interface representing a particle system in Babylon.js.
  86169. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86170. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86171. */
  86172. export interface IParticleSystem {
  86173. /**
  86174. * List of animations used by the particle system.
  86175. */
  86176. animations: Animation[];
  86177. /**
  86178. * The id of the Particle system.
  86179. */
  86180. id: string;
  86181. /**
  86182. * The name of the Particle system.
  86183. */
  86184. name: string;
  86185. /**
  86186. * The emitter represents the Mesh or position we are attaching the particle system to.
  86187. */
  86188. emitter: Nullable<AbstractMesh | Vector3>;
  86189. /**
  86190. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86191. */
  86192. isBillboardBased: boolean;
  86193. /**
  86194. * The rendering group used by the Particle system to chose when to render.
  86195. */
  86196. renderingGroupId: number;
  86197. /**
  86198. * The layer mask we are rendering the particles through.
  86199. */
  86200. layerMask: number;
  86201. /**
  86202. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86203. */
  86204. updateSpeed: number;
  86205. /**
  86206. * The amount of time the particle system is running (depends of the overall update speed).
  86207. */
  86208. targetStopDuration: number;
  86209. /**
  86210. * The texture used to render each particle. (this can be a spritesheet)
  86211. */
  86212. particleTexture: Nullable<Texture>;
  86213. /**
  86214. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86215. */
  86216. blendMode: number;
  86217. /**
  86218. * Minimum life time of emitting particles.
  86219. */
  86220. minLifeTime: number;
  86221. /**
  86222. * Maximum life time of emitting particles.
  86223. */
  86224. maxLifeTime: number;
  86225. /**
  86226. * Minimum Size of emitting particles.
  86227. */
  86228. minSize: number;
  86229. /**
  86230. * Maximum Size of emitting particles.
  86231. */
  86232. maxSize: number;
  86233. /**
  86234. * Minimum scale of emitting particles on X axis.
  86235. */
  86236. minScaleX: number;
  86237. /**
  86238. * Maximum scale of emitting particles on X axis.
  86239. */
  86240. maxScaleX: number;
  86241. /**
  86242. * Minimum scale of emitting particles on Y axis.
  86243. */
  86244. minScaleY: number;
  86245. /**
  86246. * Maximum scale of emitting particles on Y axis.
  86247. */
  86248. maxScaleY: number;
  86249. /**
  86250. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86251. */
  86252. color1: Color4;
  86253. /**
  86254. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86255. */
  86256. color2: Color4;
  86257. /**
  86258. * Color the particle will have at the end of its lifetime.
  86259. */
  86260. colorDead: Color4;
  86261. /**
  86262. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86263. */
  86264. emitRate: number;
  86265. /**
  86266. * You can use gravity if you want to give an orientation to your particles.
  86267. */
  86268. gravity: Vector3;
  86269. /**
  86270. * Minimum power of emitting particles.
  86271. */
  86272. minEmitPower: number;
  86273. /**
  86274. * Maximum power of emitting particles.
  86275. */
  86276. maxEmitPower: number;
  86277. /**
  86278. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86279. */
  86280. minAngularSpeed: number;
  86281. /**
  86282. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86283. */
  86284. maxAngularSpeed: number;
  86285. /**
  86286. * Gets or sets the minimal initial rotation in radians.
  86287. */
  86288. minInitialRotation: number;
  86289. /**
  86290. * Gets or sets the maximal initial rotation in radians.
  86291. */
  86292. maxInitialRotation: number;
  86293. /**
  86294. * The particle emitter type defines the emitter used by the particle system.
  86295. * It can be for example box, sphere, or cone...
  86296. */
  86297. particleEmitterType: Nullable<IParticleEmitterType>;
  86298. /**
  86299. * Defines the delay in milliseconds before starting the system (0 by default)
  86300. */
  86301. startDelay: number;
  86302. /**
  86303. * 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
  86304. */
  86305. preWarmCycles: number;
  86306. /**
  86307. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86308. */
  86309. preWarmStepOffset: number;
  86310. /**
  86311. * 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)
  86312. */
  86313. spriteCellChangeSpeed: number;
  86314. /**
  86315. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86316. */
  86317. startSpriteCellID: number;
  86318. /**
  86319. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86320. */
  86321. endSpriteCellID: number;
  86322. /**
  86323. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86324. */
  86325. spriteCellWidth: number;
  86326. /**
  86327. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86328. */
  86329. spriteCellHeight: number;
  86330. /**
  86331. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86332. */
  86333. spriteRandomStartCell: boolean;
  86334. /**
  86335. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86336. */
  86337. isAnimationSheetEnabled: boolean;
  86338. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86339. translationPivot: Vector2;
  86340. /**
  86341. * Gets or sets a texture used to add random noise to particle positions
  86342. */
  86343. noiseTexture: Nullable<BaseTexture>;
  86344. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86345. noiseStrength: Vector3;
  86346. /**
  86347. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86348. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86349. */
  86350. billboardMode: number;
  86351. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86352. limitVelocityDamping: number;
  86353. /**
  86354. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86355. */
  86356. beginAnimationOnStart: boolean;
  86357. /**
  86358. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86359. */
  86360. beginAnimationFrom: number;
  86361. /**
  86362. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86363. */
  86364. beginAnimationTo: number;
  86365. /**
  86366. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86367. */
  86368. beginAnimationLoop: boolean;
  86369. /**
  86370. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86371. */
  86372. disposeOnStop: boolean;
  86373. /**
  86374. * Specifies if the particles are updated in emitter local space or world space
  86375. */
  86376. isLocal: boolean;
  86377. /**
  86378. * Gets the maximum number of particles active at the same time.
  86379. * @returns The max number of active particles.
  86380. */
  86381. getCapacity(): number;
  86382. /**
  86383. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86384. * @returns True if it has been started, otherwise false.
  86385. */
  86386. isStarted(): boolean;
  86387. /**
  86388. * Animates the particle system for this frame.
  86389. */
  86390. animate(): void;
  86391. /**
  86392. * Renders the particle system in its current state.
  86393. * @returns the current number of particles
  86394. */
  86395. render(): number;
  86396. /**
  86397. * Dispose the particle system and frees its associated resources.
  86398. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86399. */
  86400. dispose(disposeTexture?: boolean): void;
  86401. /**
  86402. * Clones the particle system.
  86403. * @param name The name of the cloned object
  86404. * @param newEmitter The new emitter to use
  86405. * @returns the cloned particle system
  86406. */
  86407. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86408. /**
  86409. * Serializes the particle system to a JSON object.
  86410. * @returns the JSON object
  86411. */
  86412. serialize(): any;
  86413. /**
  86414. * Rebuild the particle system
  86415. */
  86416. rebuild(): void;
  86417. /**
  86418. * Starts the particle system and begins to emit
  86419. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86420. */
  86421. start(delay?: number): void;
  86422. /**
  86423. * Stops the particle system.
  86424. */
  86425. stop(): void;
  86426. /**
  86427. * Remove all active particles
  86428. */
  86429. reset(): void;
  86430. /**
  86431. * Is this system ready to be used/rendered
  86432. * @return true if the system is ready
  86433. */
  86434. isReady(): boolean;
  86435. /**
  86436. * Adds a new color gradient
  86437. * @param gradient defines the gradient to use (between 0 and 1)
  86438. * @param color1 defines the color to affect to the specified gradient
  86439. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86440. * @returns the current particle system
  86441. */
  86442. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86443. /**
  86444. * Remove a specific color gradient
  86445. * @param gradient defines the gradient to remove
  86446. * @returns the current particle system
  86447. */
  86448. removeColorGradient(gradient: number): IParticleSystem;
  86449. /**
  86450. * Adds a new size gradient
  86451. * @param gradient defines the gradient to use (between 0 and 1)
  86452. * @param factor defines the size factor to affect to the specified gradient
  86453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86454. * @returns the current particle system
  86455. */
  86456. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86457. /**
  86458. * Remove a specific size gradient
  86459. * @param gradient defines the gradient to remove
  86460. * @returns the current particle system
  86461. */
  86462. removeSizeGradient(gradient: number): IParticleSystem;
  86463. /**
  86464. * Gets the current list of color gradients.
  86465. * You must use addColorGradient and removeColorGradient to udpate this list
  86466. * @returns the list of color gradients
  86467. */
  86468. getColorGradients(): Nullable<Array<ColorGradient>>;
  86469. /**
  86470. * Gets the current list of size gradients.
  86471. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86472. * @returns the list of size gradients
  86473. */
  86474. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86475. /**
  86476. * Gets the current list of angular speed gradients.
  86477. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86478. * @returns the list of angular speed gradients
  86479. */
  86480. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86481. /**
  86482. * Adds a new angular speed gradient
  86483. * @param gradient defines the gradient to use (between 0 and 1)
  86484. * @param factor defines the angular speed to affect to the specified gradient
  86485. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86486. * @returns the current particle system
  86487. */
  86488. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86489. /**
  86490. * Remove a specific angular speed gradient
  86491. * @param gradient defines the gradient to remove
  86492. * @returns the current particle system
  86493. */
  86494. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86495. /**
  86496. * Gets the current list of velocity gradients.
  86497. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86498. * @returns the list of velocity gradients
  86499. */
  86500. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86501. /**
  86502. * Adds a new velocity gradient
  86503. * @param gradient defines the gradient to use (between 0 and 1)
  86504. * @param factor defines the velocity to affect to the specified gradient
  86505. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86506. * @returns the current particle system
  86507. */
  86508. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86509. /**
  86510. * Remove a specific velocity gradient
  86511. * @param gradient defines the gradient to remove
  86512. * @returns the current particle system
  86513. */
  86514. removeVelocityGradient(gradient: number): IParticleSystem;
  86515. /**
  86516. * Gets the current list of limit velocity gradients.
  86517. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86518. * @returns the list of limit velocity gradients
  86519. */
  86520. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86521. /**
  86522. * Adds a new limit velocity gradient
  86523. * @param gradient defines the gradient to use (between 0 and 1)
  86524. * @param factor defines the limit velocity to affect to the specified gradient
  86525. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86526. * @returns the current particle system
  86527. */
  86528. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86529. /**
  86530. * Remove a specific limit velocity gradient
  86531. * @param gradient defines the gradient to remove
  86532. * @returns the current particle system
  86533. */
  86534. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86535. /**
  86536. * Adds a new drag gradient
  86537. * @param gradient defines the gradient to use (between 0 and 1)
  86538. * @param factor defines the drag to affect to the specified gradient
  86539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86540. * @returns the current particle system
  86541. */
  86542. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86543. /**
  86544. * Remove a specific drag gradient
  86545. * @param gradient defines the gradient to remove
  86546. * @returns the current particle system
  86547. */
  86548. removeDragGradient(gradient: number): IParticleSystem;
  86549. /**
  86550. * Gets the current list of drag gradients.
  86551. * You must use addDragGradient and removeDragGradient to udpate this list
  86552. * @returns the list of drag gradients
  86553. */
  86554. getDragGradients(): Nullable<Array<FactorGradient>>;
  86555. /**
  86556. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86557. * @param gradient defines the gradient to use (between 0 and 1)
  86558. * @param factor defines the emit rate to affect to the specified gradient
  86559. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86560. * @returns the current particle system
  86561. */
  86562. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86563. /**
  86564. * Remove a specific emit rate gradient
  86565. * @param gradient defines the gradient to remove
  86566. * @returns the current particle system
  86567. */
  86568. removeEmitRateGradient(gradient: number): IParticleSystem;
  86569. /**
  86570. * Gets the current list of emit rate gradients.
  86571. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86572. * @returns the list of emit rate gradients
  86573. */
  86574. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86575. /**
  86576. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86577. * @param gradient defines the gradient to use (between 0 and 1)
  86578. * @param factor defines the start size to affect to the specified gradient
  86579. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86580. * @returns the current particle system
  86581. */
  86582. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86583. /**
  86584. * Remove a specific start size gradient
  86585. * @param gradient defines the gradient to remove
  86586. * @returns the current particle system
  86587. */
  86588. removeStartSizeGradient(gradient: number): IParticleSystem;
  86589. /**
  86590. * Gets the current list of start size gradients.
  86591. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86592. * @returns the list of start size gradients
  86593. */
  86594. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86595. /**
  86596. * Adds a new life time gradient
  86597. * @param gradient defines the gradient to use (between 0 and 1)
  86598. * @param factor defines the life time factor to affect to the specified gradient
  86599. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86600. * @returns the current particle system
  86601. */
  86602. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86603. /**
  86604. * Remove a specific life time gradient
  86605. * @param gradient defines the gradient to remove
  86606. * @returns the current particle system
  86607. */
  86608. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86609. /**
  86610. * Gets the current list of life time gradients.
  86611. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86612. * @returns the list of life time gradients
  86613. */
  86614. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86615. /**
  86616. * Gets the current list of color gradients.
  86617. * You must use addColorGradient and removeColorGradient to udpate this list
  86618. * @returns the list of color gradients
  86619. */
  86620. getColorGradients(): Nullable<Array<ColorGradient>>;
  86621. /**
  86622. * Adds a new ramp gradient used to remap particle colors
  86623. * @param gradient defines the gradient to use (between 0 and 1)
  86624. * @param color defines the color to affect to the specified gradient
  86625. * @returns the current particle system
  86626. */
  86627. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86628. /**
  86629. * Gets the current list of ramp gradients.
  86630. * You must use addRampGradient and removeRampGradient to udpate this list
  86631. * @returns the list of ramp gradients
  86632. */
  86633. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86634. /** Gets or sets a boolean indicating that ramp gradients must be used
  86635. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86636. */
  86637. useRampGradients: boolean;
  86638. /**
  86639. * Adds a new color remap gradient
  86640. * @param gradient defines the gradient to use (between 0 and 1)
  86641. * @param min defines the color remap minimal range
  86642. * @param max defines the color remap maximal range
  86643. * @returns the current particle system
  86644. */
  86645. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86646. /**
  86647. * Gets the current list of color remap gradients.
  86648. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86649. * @returns the list of color remap gradients
  86650. */
  86651. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86652. /**
  86653. * Adds a new alpha remap gradient
  86654. * @param gradient defines the gradient to use (between 0 and 1)
  86655. * @param min defines the alpha remap minimal range
  86656. * @param max defines the alpha remap maximal range
  86657. * @returns the current particle system
  86658. */
  86659. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86660. /**
  86661. * Gets the current list of alpha remap gradients.
  86662. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86663. * @returns the list of alpha remap gradients
  86664. */
  86665. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86666. /**
  86667. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86670. * @returns the emitter
  86671. */
  86672. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86673. /**
  86674. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86675. * @param radius The radius of the hemisphere to emit from
  86676. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86677. * @returns the emitter
  86678. */
  86679. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86680. /**
  86681. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86682. * @param radius The radius of the sphere to emit from
  86683. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86684. * @returns the emitter
  86685. */
  86686. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86687. /**
  86688. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86689. * @param radius The radius of the sphere to emit from
  86690. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86691. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86692. * @returns the emitter
  86693. */
  86694. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86695. /**
  86696. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86697. * @param radius The radius of the emission cylinder
  86698. * @param height The height of the emission cylinder
  86699. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86700. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86701. * @returns the emitter
  86702. */
  86703. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86704. /**
  86705. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86706. * @param radius The radius of the cylinder to emit from
  86707. * @param height The height of the emission cylinder
  86708. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86709. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86710. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86711. * @returns the emitter
  86712. */
  86713. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86714. /**
  86715. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86716. * @param radius The radius of the cone to emit from
  86717. * @param angle The base angle of the cone
  86718. * @returns the emitter
  86719. */
  86720. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86721. /**
  86722. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86723. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86724. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86725. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86726. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86727. * @returns the emitter
  86728. */
  86729. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86730. /**
  86731. * Get hosting scene
  86732. * @returns the scene
  86733. */
  86734. getScene(): Scene;
  86735. }
  86736. }
  86737. declare module BABYLON {
  86738. /**
  86739. * 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.
  86740. * @see https://doc.babylonjs.com/how_to/transformnode
  86741. */
  86742. export class TransformNode extends Node {
  86743. /**
  86744. * Object will not rotate to face the camera
  86745. */
  86746. static BILLBOARDMODE_NONE: number;
  86747. /**
  86748. * Object will rotate to face the camera but only on the x axis
  86749. */
  86750. static BILLBOARDMODE_X: number;
  86751. /**
  86752. * Object will rotate to face the camera but only on the y axis
  86753. */
  86754. static BILLBOARDMODE_Y: number;
  86755. /**
  86756. * Object will rotate to face the camera but only on the z axis
  86757. */
  86758. static BILLBOARDMODE_Z: number;
  86759. /**
  86760. * Object will rotate to face the camera
  86761. */
  86762. static BILLBOARDMODE_ALL: number;
  86763. /**
  86764. * Object will rotate to face the camera's position instead of orientation
  86765. */
  86766. static BILLBOARDMODE_USE_POSITION: number;
  86767. private _forward;
  86768. private _forwardInverted;
  86769. private _up;
  86770. private _right;
  86771. private _rightInverted;
  86772. private _position;
  86773. private _rotation;
  86774. private _rotationQuaternion;
  86775. protected _scaling: Vector3;
  86776. protected _isDirty: boolean;
  86777. private _transformToBoneReferal;
  86778. private _isAbsoluteSynced;
  86779. private _billboardMode;
  86780. /**
  86781. * Gets or sets the billboard mode. Default is 0.
  86782. *
  86783. * | Value | Type | Description |
  86784. * | --- | --- | --- |
  86785. * | 0 | BILLBOARDMODE_NONE | |
  86786. * | 1 | BILLBOARDMODE_X | |
  86787. * | 2 | BILLBOARDMODE_Y | |
  86788. * | 4 | BILLBOARDMODE_Z | |
  86789. * | 7 | BILLBOARDMODE_ALL | |
  86790. *
  86791. */
  86792. get billboardMode(): number;
  86793. set billboardMode(value: number);
  86794. private _preserveParentRotationForBillboard;
  86795. /**
  86796. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86797. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86798. */
  86799. get preserveParentRotationForBillboard(): boolean;
  86800. set preserveParentRotationForBillboard(value: boolean);
  86801. /**
  86802. * 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
  86803. */
  86804. scalingDeterminant: number;
  86805. private _infiniteDistance;
  86806. /**
  86807. * Gets or sets the distance of the object to max, often used by skybox
  86808. */
  86809. get infiniteDistance(): boolean;
  86810. set infiniteDistance(value: boolean);
  86811. /**
  86812. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86813. * By default the system will update normals to compensate
  86814. */
  86815. ignoreNonUniformScaling: boolean;
  86816. /**
  86817. * 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
  86818. */
  86819. reIntegrateRotationIntoRotationQuaternion: boolean;
  86820. /** @hidden */
  86821. _poseMatrix: Nullable<Matrix>;
  86822. /** @hidden */
  86823. _localMatrix: Matrix;
  86824. private _usePivotMatrix;
  86825. private _absolutePosition;
  86826. private _absoluteScaling;
  86827. private _absoluteRotationQuaternion;
  86828. private _pivotMatrix;
  86829. private _pivotMatrixInverse;
  86830. protected _postMultiplyPivotMatrix: boolean;
  86831. protected _isWorldMatrixFrozen: boolean;
  86832. /** @hidden */
  86833. _indexInSceneTransformNodesArray: number;
  86834. /**
  86835. * An event triggered after the world matrix is updated
  86836. */
  86837. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86838. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86839. /**
  86840. * Gets a string identifying the name of the class
  86841. * @returns "TransformNode" string
  86842. */
  86843. getClassName(): string;
  86844. /**
  86845. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86846. */
  86847. get position(): Vector3;
  86848. set position(newPosition: Vector3);
  86849. /**
  86850. * 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)).
  86851. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86852. */
  86853. get rotation(): Vector3;
  86854. set rotation(newRotation: Vector3);
  86855. /**
  86856. * 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)).
  86857. */
  86858. get scaling(): Vector3;
  86859. set scaling(newScaling: Vector3);
  86860. /**
  86861. * 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).
  86862. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86863. */
  86864. get rotationQuaternion(): Nullable<Quaternion>;
  86865. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86866. /**
  86867. * The forward direction of that transform in world space.
  86868. */
  86869. get forward(): Vector3;
  86870. /**
  86871. * The up direction of that transform in world space.
  86872. */
  86873. get up(): Vector3;
  86874. /**
  86875. * The right direction of that transform in world space.
  86876. */
  86877. get right(): Vector3;
  86878. /**
  86879. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86880. * @param matrix the matrix to copy the pose from
  86881. * @returns this TransformNode.
  86882. */
  86883. updatePoseMatrix(matrix: Matrix): TransformNode;
  86884. /**
  86885. * Returns the mesh Pose matrix.
  86886. * @returns the pose matrix
  86887. */
  86888. getPoseMatrix(): Matrix;
  86889. /** @hidden */
  86890. _isSynchronized(): boolean;
  86891. /** @hidden */
  86892. _initCache(): void;
  86893. /**
  86894. * Flag the transform node as dirty (Forcing it to update everything)
  86895. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86896. * @returns this transform node
  86897. */
  86898. markAsDirty(property: string): TransformNode;
  86899. /**
  86900. * Returns the current mesh absolute position.
  86901. * Returns a Vector3.
  86902. */
  86903. get absolutePosition(): Vector3;
  86904. /**
  86905. * Returns the current mesh absolute scaling.
  86906. * Returns a Vector3.
  86907. */
  86908. get absoluteScaling(): Vector3;
  86909. /**
  86910. * Returns the current mesh absolute rotation.
  86911. * Returns a Quaternion.
  86912. */
  86913. get absoluteRotationQuaternion(): Quaternion;
  86914. /**
  86915. * Sets a new matrix to apply before all other transformation
  86916. * @param matrix defines the transform matrix
  86917. * @returns the current TransformNode
  86918. */
  86919. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86920. /**
  86921. * Sets a new pivot matrix to the current node
  86922. * @param matrix defines the new pivot matrix to use
  86923. * @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
  86924. * @returns the current TransformNode
  86925. */
  86926. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86927. /**
  86928. * Returns the mesh pivot matrix.
  86929. * Default : Identity.
  86930. * @returns the matrix
  86931. */
  86932. getPivotMatrix(): Matrix;
  86933. /**
  86934. * Instantiate (when possible) or clone that node with its hierarchy
  86935. * @param newParent defines the new parent to use for the instance (or clone)
  86936. * @param options defines options to configure how copy is done
  86937. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86938. * @returns an instance (or a clone) of the current node with its hiearchy
  86939. */
  86940. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86941. doNotInstantiate: boolean;
  86942. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86943. /**
  86944. * Prevents the World matrix to be computed any longer
  86945. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86946. * @returns the TransformNode.
  86947. */
  86948. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86949. /**
  86950. * Allows back the World matrix computation.
  86951. * @returns the TransformNode.
  86952. */
  86953. unfreezeWorldMatrix(): this;
  86954. /**
  86955. * True if the World matrix has been frozen.
  86956. */
  86957. get isWorldMatrixFrozen(): boolean;
  86958. /**
  86959. * Retuns the mesh absolute position in the World.
  86960. * @returns a Vector3.
  86961. */
  86962. getAbsolutePosition(): Vector3;
  86963. /**
  86964. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86965. * @param absolutePosition the absolute position to set
  86966. * @returns the TransformNode.
  86967. */
  86968. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86969. /**
  86970. * Sets the mesh position in its local space.
  86971. * @param vector3 the position to set in localspace
  86972. * @returns the TransformNode.
  86973. */
  86974. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86975. /**
  86976. * Returns the mesh position in the local space from the current World matrix values.
  86977. * @returns a new Vector3.
  86978. */
  86979. getPositionExpressedInLocalSpace(): Vector3;
  86980. /**
  86981. * Translates the mesh along the passed Vector3 in its local space.
  86982. * @param vector3 the distance to translate in localspace
  86983. * @returns the TransformNode.
  86984. */
  86985. locallyTranslate(vector3: Vector3): TransformNode;
  86986. private static _lookAtVectorCache;
  86987. /**
  86988. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86989. * @param targetPoint the position (must be in same space as current mesh) to look at
  86990. * @param yawCor optional yaw (y-axis) correction in radians
  86991. * @param pitchCor optional pitch (x-axis) correction in radians
  86992. * @param rollCor optional roll (z-axis) correction in radians
  86993. * @param space the choosen space of the target
  86994. * @returns the TransformNode.
  86995. */
  86996. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  86997. /**
  86998. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86999. * This Vector3 is expressed in the World space.
  87000. * @param localAxis axis to rotate
  87001. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87002. */
  87003. getDirection(localAxis: Vector3): Vector3;
  87004. /**
  87005. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87006. * localAxis is expressed in the mesh local space.
  87007. * result is computed in the Wordl space from the mesh World matrix.
  87008. * @param localAxis axis to rotate
  87009. * @param result the resulting transformnode
  87010. * @returns this TransformNode.
  87011. */
  87012. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87013. /**
  87014. * Sets this transform node rotation to the given local axis.
  87015. * @param localAxis the axis in local space
  87016. * @param yawCor optional yaw (y-axis) correction in radians
  87017. * @param pitchCor optional pitch (x-axis) correction in radians
  87018. * @param rollCor optional roll (z-axis) correction in radians
  87019. * @returns this TransformNode
  87020. */
  87021. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87022. /**
  87023. * Sets a new pivot point to the current node
  87024. * @param point defines the new pivot point to use
  87025. * @param space defines if the point is in world or local space (local by default)
  87026. * @returns the current TransformNode
  87027. */
  87028. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87029. /**
  87030. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87031. * @returns the pivot point
  87032. */
  87033. getPivotPoint(): Vector3;
  87034. /**
  87035. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87036. * @param result the vector3 to store the result
  87037. * @returns this TransformNode.
  87038. */
  87039. getPivotPointToRef(result: Vector3): TransformNode;
  87040. /**
  87041. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87042. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87043. */
  87044. getAbsolutePivotPoint(): Vector3;
  87045. /**
  87046. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87047. * @param result vector3 to store the result
  87048. * @returns this TransformNode.
  87049. */
  87050. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87051. /**
  87052. * Defines the passed node as the parent of the current node.
  87053. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87054. * @see https://doc.babylonjs.com/how_to/parenting
  87055. * @param node the node ot set as the parent
  87056. * @returns this TransformNode.
  87057. */
  87058. setParent(node: Nullable<Node>): TransformNode;
  87059. private _nonUniformScaling;
  87060. /**
  87061. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87062. */
  87063. get nonUniformScaling(): boolean;
  87064. /** @hidden */
  87065. _updateNonUniformScalingState(value: boolean): boolean;
  87066. /**
  87067. * Attach the current TransformNode to another TransformNode associated with a bone
  87068. * @param bone Bone affecting the TransformNode
  87069. * @param affectedTransformNode TransformNode associated with the bone
  87070. * @returns this object
  87071. */
  87072. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87073. /**
  87074. * Detach the transform node if its associated with a bone
  87075. * @returns this object
  87076. */
  87077. detachFromBone(): TransformNode;
  87078. private static _rotationAxisCache;
  87079. /**
  87080. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87081. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87082. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87083. * The passed axis is also normalized.
  87084. * @param axis the axis to rotate around
  87085. * @param amount the amount to rotate in radians
  87086. * @param space Space to rotate in (Default: local)
  87087. * @returns the TransformNode.
  87088. */
  87089. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87090. /**
  87091. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87092. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87093. * The passed axis is also normalized. .
  87094. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87095. * @param point the point to rotate around
  87096. * @param axis the axis to rotate around
  87097. * @param amount the amount to rotate in radians
  87098. * @returns the TransformNode
  87099. */
  87100. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87101. /**
  87102. * Translates the mesh along the axis vector for the passed distance in the given space.
  87103. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87104. * @param axis the axis to translate in
  87105. * @param distance the distance to translate
  87106. * @param space Space to rotate in (Default: local)
  87107. * @returns the TransformNode.
  87108. */
  87109. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87110. /**
  87111. * Adds a rotation step to the mesh current rotation.
  87112. * x, y, z are Euler angles expressed in radians.
  87113. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87114. * This means this rotation is made in the mesh local space only.
  87115. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87116. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87117. * ```javascript
  87118. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87119. * ```
  87120. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87121. * 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.
  87122. * @param x Rotation to add
  87123. * @param y Rotation to add
  87124. * @param z Rotation to add
  87125. * @returns the TransformNode.
  87126. */
  87127. addRotation(x: number, y: number, z: number): TransformNode;
  87128. /**
  87129. * @hidden
  87130. */
  87131. protected _getEffectiveParent(): Nullable<Node>;
  87132. /**
  87133. * Computes the world matrix of the node
  87134. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87135. * @returns the world matrix
  87136. */
  87137. computeWorldMatrix(force?: boolean): Matrix;
  87138. /**
  87139. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87140. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87141. */
  87142. resetLocalMatrix(independentOfChildren?: boolean): void;
  87143. protected _afterComputeWorldMatrix(): void;
  87144. /**
  87145. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87146. * @param func callback function to add
  87147. *
  87148. * @returns the TransformNode.
  87149. */
  87150. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87151. /**
  87152. * Removes a registered callback function.
  87153. * @param func callback function to remove
  87154. * @returns the TransformNode.
  87155. */
  87156. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87157. /**
  87158. * Gets the position of the current mesh in camera space
  87159. * @param camera defines the camera to use
  87160. * @returns a position
  87161. */
  87162. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87163. /**
  87164. * Returns the distance from the mesh to the active camera
  87165. * @param camera defines the camera to use
  87166. * @returns the distance
  87167. */
  87168. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87169. /**
  87170. * Clone the current transform node
  87171. * @param name Name of the new clone
  87172. * @param newParent New parent for the clone
  87173. * @param doNotCloneChildren Do not clone children hierarchy
  87174. * @returns the new transform node
  87175. */
  87176. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87177. /**
  87178. * Serializes the objects information.
  87179. * @param currentSerializationObject defines the object to serialize in
  87180. * @returns the serialized object
  87181. */
  87182. serialize(currentSerializationObject?: any): any;
  87183. /**
  87184. * Returns a new TransformNode object parsed from the source provided.
  87185. * @param parsedTransformNode is the source.
  87186. * @param scene the scne the object belongs to
  87187. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87188. * @returns a new TransformNode object parsed from the source provided.
  87189. */
  87190. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87191. /**
  87192. * Get all child-transformNodes of this node
  87193. * @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
  87194. * @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
  87195. * @returns an array of TransformNode
  87196. */
  87197. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87198. /**
  87199. * Releases resources associated with this transform node.
  87200. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87201. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87202. */
  87203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87204. /**
  87205. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87206. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87207. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87208. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87209. * @returns the current mesh
  87210. */
  87211. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87212. private _syncAbsoluteScalingAndRotation;
  87213. }
  87214. }
  87215. declare module BABYLON {
  87216. /**
  87217. * Class used to override all child animations of a given target
  87218. */
  87219. export class AnimationPropertiesOverride {
  87220. /**
  87221. * Gets or sets a value indicating if animation blending must be used
  87222. */
  87223. enableBlending: boolean;
  87224. /**
  87225. * Gets or sets the blending speed to use when enableBlending is true
  87226. */
  87227. blendingSpeed: number;
  87228. /**
  87229. * Gets or sets the default loop mode to use
  87230. */
  87231. loopMode: number;
  87232. }
  87233. }
  87234. declare module BABYLON {
  87235. /**
  87236. * Class used to store bone information
  87237. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87238. */
  87239. export class Bone extends Node {
  87240. /**
  87241. * defines the bone name
  87242. */
  87243. name: string;
  87244. private static _tmpVecs;
  87245. private static _tmpQuat;
  87246. private static _tmpMats;
  87247. /**
  87248. * Gets the list of child bones
  87249. */
  87250. children: Bone[];
  87251. /** Gets the animations associated with this bone */
  87252. animations: Animation[];
  87253. /**
  87254. * Gets or sets bone length
  87255. */
  87256. length: number;
  87257. /**
  87258. * @hidden Internal only
  87259. * Set this value to map this bone to a different index in the transform matrices
  87260. * Set this value to -1 to exclude the bone from the transform matrices
  87261. */
  87262. _index: Nullable<number>;
  87263. private _skeleton;
  87264. private _localMatrix;
  87265. private _restPose;
  87266. private _baseMatrix;
  87267. private _absoluteTransform;
  87268. private _invertedAbsoluteTransform;
  87269. private _parent;
  87270. private _scalingDeterminant;
  87271. private _worldTransform;
  87272. private _localScaling;
  87273. private _localRotation;
  87274. private _localPosition;
  87275. private _needToDecompose;
  87276. private _needToCompose;
  87277. /** @hidden */
  87278. _linkedTransformNode: Nullable<TransformNode>;
  87279. /** @hidden */
  87280. _waitingTransformNodeId: Nullable<string>;
  87281. /** @hidden */
  87282. get _matrix(): Matrix;
  87283. /** @hidden */
  87284. set _matrix(value: Matrix);
  87285. /**
  87286. * Create a new bone
  87287. * @param name defines the bone name
  87288. * @param skeleton defines the parent skeleton
  87289. * @param parentBone defines the parent (can be null if the bone is the root)
  87290. * @param localMatrix defines the local matrix
  87291. * @param restPose defines the rest pose matrix
  87292. * @param baseMatrix defines the base matrix
  87293. * @param index defines index of the bone in the hiearchy
  87294. */
  87295. constructor(
  87296. /**
  87297. * defines the bone name
  87298. */
  87299. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87300. /**
  87301. * Gets the current object class name.
  87302. * @return the class name
  87303. */
  87304. getClassName(): string;
  87305. /**
  87306. * Gets the parent skeleton
  87307. * @returns a skeleton
  87308. */
  87309. getSkeleton(): Skeleton;
  87310. /**
  87311. * Gets parent bone
  87312. * @returns a bone or null if the bone is the root of the bone hierarchy
  87313. */
  87314. getParent(): Nullable<Bone>;
  87315. /**
  87316. * Returns an array containing the root bones
  87317. * @returns an array containing the root bones
  87318. */
  87319. getChildren(): Array<Bone>;
  87320. /**
  87321. * Gets the node index in matrix array generated for rendering
  87322. * @returns the node index
  87323. */
  87324. getIndex(): number;
  87325. /**
  87326. * Sets the parent bone
  87327. * @param parent defines the parent (can be null if the bone is the root)
  87328. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87329. */
  87330. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87331. /**
  87332. * Gets the local matrix
  87333. * @returns a matrix
  87334. */
  87335. getLocalMatrix(): Matrix;
  87336. /**
  87337. * Gets the base matrix (initial matrix which remains unchanged)
  87338. * @returns a matrix
  87339. */
  87340. getBaseMatrix(): Matrix;
  87341. /**
  87342. * Gets the rest pose matrix
  87343. * @returns a matrix
  87344. */
  87345. getRestPose(): Matrix;
  87346. /**
  87347. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87348. */
  87349. getWorldMatrix(): Matrix;
  87350. /**
  87351. * Sets the local matrix to rest pose matrix
  87352. */
  87353. returnToRest(): void;
  87354. /**
  87355. * Gets the inverse of the absolute transform matrix.
  87356. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87357. * @returns a matrix
  87358. */
  87359. getInvertedAbsoluteTransform(): Matrix;
  87360. /**
  87361. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87362. * @returns a matrix
  87363. */
  87364. getAbsoluteTransform(): Matrix;
  87365. /**
  87366. * Links with the given transform node.
  87367. * The local matrix of this bone is copied from the transform node every frame.
  87368. * @param transformNode defines the transform node to link to
  87369. */
  87370. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87371. /**
  87372. * Gets the node used to drive the bone's transformation
  87373. * @returns a transform node or null
  87374. */
  87375. getTransformNode(): Nullable<TransformNode>;
  87376. /** Gets or sets current position (in local space) */
  87377. get position(): Vector3;
  87378. set position(newPosition: Vector3);
  87379. /** Gets or sets current rotation (in local space) */
  87380. get rotation(): Vector3;
  87381. set rotation(newRotation: Vector3);
  87382. /** Gets or sets current rotation quaternion (in local space) */
  87383. get rotationQuaternion(): Quaternion;
  87384. set rotationQuaternion(newRotation: Quaternion);
  87385. /** Gets or sets current scaling (in local space) */
  87386. get scaling(): Vector3;
  87387. set scaling(newScaling: Vector3);
  87388. /**
  87389. * Gets the animation properties override
  87390. */
  87391. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87392. private _decompose;
  87393. private _compose;
  87394. /**
  87395. * Update the base and local matrices
  87396. * @param matrix defines the new base or local matrix
  87397. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87398. * @param updateLocalMatrix defines if the local matrix should be updated
  87399. */
  87400. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87401. /** @hidden */
  87402. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87403. /**
  87404. * Flag the bone as dirty (Forcing it to update everything)
  87405. */
  87406. markAsDirty(): void;
  87407. /** @hidden */
  87408. _markAsDirtyAndCompose(): void;
  87409. private _markAsDirtyAndDecompose;
  87410. /**
  87411. * Translate the bone in local or world space
  87412. * @param vec The amount to translate the bone
  87413. * @param space The space that the translation is in
  87414. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87415. */
  87416. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87417. /**
  87418. * Set the postion of the bone in local or world space
  87419. * @param position The position to set the bone
  87420. * @param space The space that the position is in
  87421. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87422. */
  87423. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87424. /**
  87425. * Set the absolute position of the bone (world space)
  87426. * @param position The position to set the bone
  87427. * @param mesh The mesh that this bone is attached to
  87428. */
  87429. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87430. /**
  87431. * Scale the bone on the x, y and z axes (in local space)
  87432. * @param x The amount to scale the bone on the x axis
  87433. * @param y The amount to scale the bone on the y axis
  87434. * @param z The amount to scale the bone on the z axis
  87435. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87436. */
  87437. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87438. /**
  87439. * Set the bone scaling in local space
  87440. * @param scale defines the scaling vector
  87441. */
  87442. setScale(scale: Vector3): void;
  87443. /**
  87444. * Gets the current scaling in local space
  87445. * @returns the current scaling vector
  87446. */
  87447. getScale(): Vector3;
  87448. /**
  87449. * Gets the current scaling in local space and stores it in a target vector
  87450. * @param result defines the target vector
  87451. */
  87452. getScaleToRef(result: Vector3): void;
  87453. /**
  87454. * Set the yaw, pitch, and roll of the bone in local or world space
  87455. * @param yaw The rotation of the bone on the y axis
  87456. * @param pitch The rotation of the bone on the x axis
  87457. * @param roll The rotation of the bone on the z axis
  87458. * @param space The space that the axes of rotation are in
  87459. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87460. */
  87461. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87462. /**
  87463. * Add a rotation to the bone on an axis in local or world space
  87464. * @param axis The axis to rotate the bone on
  87465. * @param amount The amount to rotate the bone
  87466. * @param space The space that the axis is in
  87467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87468. */
  87469. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87470. /**
  87471. * Set the rotation of the bone to a particular axis angle in local or world space
  87472. * @param axis The axis to rotate the bone on
  87473. * @param angle The angle that the bone should be rotated to
  87474. * @param space The space that the axis is in
  87475. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87476. */
  87477. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87478. /**
  87479. * Set the euler rotation of the bone in local of world space
  87480. * @param rotation The euler rotation that the bone should be set to
  87481. * @param space The space that the rotation is in
  87482. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87483. */
  87484. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87485. /**
  87486. * Set the quaternion rotation of the bone in local of world space
  87487. * @param quat The quaternion rotation that the bone should be set to
  87488. * @param space The space that the rotation is in
  87489. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87490. */
  87491. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87492. /**
  87493. * Set the rotation matrix of the bone in local of world space
  87494. * @param rotMat The rotation matrix that the bone should be set to
  87495. * @param space The space that the rotation is in
  87496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87497. */
  87498. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87499. private _rotateWithMatrix;
  87500. private _getNegativeRotationToRef;
  87501. /**
  87502. * Get the position of the bone in local or world space
  87503. * @param space The space that the returned position is in
  87504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87505. * @returns The position of the bone
  87506. */
  87507. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87508. /**
  87509. * Copy the position of the bone to a vector3 in local or world space
  87510. * @param space The space that the returned position is in
  87511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87512. * @param result The vector3 to copy the position to
  87513. */
  87514. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87515. /**
  87516. * Get the absolute position of the bone (world space)
  87517. * @param mesh The mesh that this bone is attached to
  87518. * @returns The absolute position of the bone
  87519. */
  87520. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87521. /**
  87522. * Copy the absolute position of the bone (world space) to the result param
  87523. * @param mesh The mesh that this bone is attached to
  87524. * @param result The vector3 to copy the absolute position to
  87525. */
  87526. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87527. /**
  87528. * Compute the absolute transforms of this bone and its children
  87529. */
  87530. computeAbsoluteTransforms(): void;
  87531. /**
  87532. * Get the world direction from an axis that is in the local space of the bone
  87533. * @param localAxis The local direction that is used to compute the world direction
  87534. * @param mesh The mesh that this bone is attached to
  87535. * @returns The world direction
  87536. */
  87537. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87538. /**
  87539. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87540. * @param localAxis The local direction that is used to compute the world direction
  87541. * @param mesh The mesh that this bone is attached to
  87542. * @param result The vector3 that the world direction will be copied to
  87543. */
  87544. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87545. /**
  87546. * Get the euler rotation of the bone in local or world space
  87547. * @param space The space that the rotation should be in
  87548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87549. * @returns The euler rotation
  87550. */
  87551. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87552. /**
  87553. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87554. * @param space The space that the rotation should be in
  87555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87556. * @param result The vector3 that the rotation should be copied to
  87557. */
  87558. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87559. /**
  87560. * Get the quaternion rotation of the bone in either local or world space
  87561. * @param space The space that the rotation should be in
  87562. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87563. * @returns The quaternion rotation
  87564. */
  87565. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87566. /**
  87567. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87568. * @param space The space that the rotation should be in
  87569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87570. * @param result The quaternion that the rotation should be copied to
  87571. */
  87572. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87573. /**
  87574. * Get the rotation matrix of the bone in local or world space
  87575. * @param space The space that the rotation should be in
  87576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87577. * @returns The rotation matrix
  87578. */
  87579. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87580. /**
  87581. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87582. * @param space The space that the rotation should be in
  87583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87584. * @param result The quaternion that the rotation should be copied to
  87585. */
  87586. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87587. /**
  87588. * Get the world position of a point that is in the local space of the bone
  87589. * @param position The local position
  87590. * @param mesh The mesh that this bone is attached to
  87591. * @returns The world position
  87592. */
  87593. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87594. /**
  87595. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87596. * @param position The local position
  87597. * @param mesh The mesh that this bone is attached to
  87598. * @param result The vector3 that the world position should be copied to
  87599. */
  87600. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87601. /**
  87602. * Get the local position of a point that is in world space
  87603. * @param position The world position
  87604. * @param mesh The mesh that this bone is attached to
  87605. * @returns The local position
  87606. */
  87607. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87608. /**
  87609. * Get the local position of a point that is in world space and copy it to the result param
  87610. * @param position The world position
  87611. * @param mesh The mesh that this bone is attached to
  87612. * @param result The vector3 that the local position should be copied to
  87613. */
  87614. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87615. }
  87616. }
  87617. declare module BABYLON {
  87618. /**
  87619. * Defines a runtime animation
  87620. */
  87621. export class RuntimeAnimation {
  87622. private _events;
  87623. /**
  87624. * The current frame of the runtime animation
  87625. */
  87626. private _currentFrame;
  87627. /**
  87628. * The animation used by the runtime animation
  87629. */
  87630. private _animation;
  87631. /**
  87632. * The target of the runtime animation
  87633. */
  87634. private _target;
  87635. /**
  87636. * The initiating animatable
  87637. */
  87638. private _host;
  87639. /**
  87640. * The original value of the runtime animation
  87641. */
  87642. private _originalValue;
  87643. /**
  87644. * The original blend value of the runtime animation
  87645. */
  87646. private _originalBlendValue;
  87647. /**
  87648. * The offsets cache of the runtime animation
  87649. */
  87650. private _offsetsCache;
  87651. /**
  87652. * The high limits cache of the runtime animation
  87653. */
  87654. private _highLimitsCache;
  87655. /**
  87656. * Specifies if the runtime animation has been stopped
  87657. */
  87658. private _stopped;
  87659. /**
  87660. * The blending factor of the runtime animation
  87661. */
  87662. private _blendingFactor;
  87663. /**
  87664. * The BabylonJS scene
  87665. */
  87666. private _scene;
  87667. /**
  87668. * The current value of the runtime animation
  87669. */
  87670. private _currentValue;
  87671. /** @hidden */
  87672. _animationState: _IAnimationState;
  87673. /**
  87674. * The active target of the runtime animation
  87675. */
  87676. private _activeTargets;
  87677. private _currentActiveTarget;
  87678. private _directTarget;
  87679. /**
  87680. * The target path of the runtime animation
  87681. */
  87682. private _targetPath;
  87683. /**
  87684. * The weight of the runtime animation
  87685. */
  87686. private _weight;
  87687. /**
  87688. * The ratio offset of the runtime animation
  87689. */
  87690. private _ratioOffset;
  87691. /**
  87692. * The previous delay of the runtime animation
  87693. */
  87694. private _previousDelay;
  87695. /**
  87696. * The previous ratio of the runtime animation
  87697. */
  87698. private _previousRatio;
  87699. private _enableBlending;
  87700. private _keys;
  87701. private _minFrame;
  87702. private _maxFrame;
  87703. private _minValue;
  87704. private _maxValue;
  87705. private _targetIsArray;
  87706. /**
  87707. * Gets the current frame of the runtime animation
  87708. */
  87709. get currentFrame(): number;
  87710. /**
  87711. * Gets the weight of the runtime animation
  87712. */
  87713. get weight(): number;
  87714. /**
  87715. * Gets the current value of the runtime animation
  87716. */
  87717. get currentValue(): any;
  87718. /**
  87719. * Gets the target path of the runtime animation
  87720. */
  87721. get targetPath(): string;
  87722. /**
  87723. * Gets the actual target of the runtime animation
  87724. */
  87725. get target(): any;
  87726. /** @hidden */
  87727. _onLoop: () => void;
  87728. /**
  87729. * Create a new RuntimeAnimation object
  87730. * @param target defines the target of the animation
  87731. * @param animation defines the source animation object
  87732. * @param scene defines the hosting scene
  87733. * @param host defines the initiating Animatable
  87734. */
  87735. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87736. private _preparePath;
  87737. /**
  87738. * Gets the animation from the runtime animation
  87739. */
  87740. get animation(): Animation;
  87741. /**
  87742. * Resets the runtime animation to the beginning
  87743. * @param restoreOriginal defines whether to restore the target property to the original value
  87744. */
  87745. reset(restoreOriginal?: boolean): void;
  87746. /**
  87747. * Specifies if the runtime animation is stopped
  87748. * @returns Boolean specifying if the runtime animation is stopped
  87749. */
  87750. isStopped(): boolean;
  87751. /**
  87752. * Disposes of the runtime animation
  87753. */
  87754. dispose(): void;
  87755. /**
  87756. * Apply the interpolated value to the target
  87757. * @param currentValue defines the value computed by the animation
  87758. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87759. */
  87760. setValue(currentValue: any, weight: number): void;
  87761. private _getOriginalValues;
  87762. private _setValue;
  87763. /**
  87764. * Gets the loop pmode of the runtime animation
  87765. * @returns Loop Mode
  87766. */
  87767. private _getCorrectLoopMode;
  87768. /**
  87769. * Move the current animation to a given frame
  87770. * @param frame defines the frame to move to
  87771. */
  87772. goToFrame(frame: number): void;
  87773. /**
  87774. * @hidden Internal use only
  87775. */
  87776. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87777. /**
  87778. * Execute the current animation
  87779. * @param delay defines the delay to add to the current frame
  87780. * @param from defines the lower bound of the animation range
  87781. * @param to defines the upper bound of the animation range
  87782. * @param loop defines if the current animation must loop
  87783. * @param speedRatio defines the current speed ratio
  87784. * @param weight defines the weight of the animation (default is -1 so no weight)
  87785. * @param onLoop optional callback called when animation loops
  87786. * @returns a boolean indicating if the animation is running
  87787. */
  87788. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87789. }
  87790. }
  87791. declare module BABYLON {
  87792. /**
  87793. * Class used to store an actual running animation
  87794. */
  87795. export class Animatable {
  87796. /** defines the target object */
  87797. target: any;
  87798. /** defines the starting frame number (default is 0) */
  87799. fromFrame: number;
  87800. /** defines the ending frame number (default is 100) */
  87801. toFrame: number;
  87802. /** defines if the animation must loop (default is false) */
  87803. loopAnimation: boolean;
  87804. /** defines a callback to call when animation ends if it is not looping */
  87805. onAnimationEnd?: (() => void) | null | undefined;
  87806. /** defines a callback to call when animation loops */
  87807. onAnimationLoop?: (() => void) | null | undefined;
  87808. private _localDelayOffset;
  87809. private _pausedDelay;
  87810. private _runtimeAnimations;
  87811. private _paused;
  87812. private _scene;
  87813. private _speedRatio;
  87814. private _weight;
  87815. private _syncRoot;
  87816. /**
  87817. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87818. * This will only apply for non looping animation (default is true)
  87819. */
  87820. disposeOnEnd: boolean;
  87821. /**
  87822. * Gets a boolean indicating if the animation has started
  87823. */
  87824. animationStarted: boolean;
  87825. /**
  87826. * Observer raised when the animation ends
  87827. */
  87828. onAnimationEndObservable: Observable<Animatable>;
  87829. /**
  87830. * Observer raised when the animation loops
  87831. */
  87832. onAnimationLoopObservable: Observable<Animatable>;
  87833. /**
  87834. * Gets the root Animatable used to synchronize and normalize animations
  87835. */
  87836. get syncRoot(): Nullable<Animatable>;
  87837. /**
  87838. * Gets the current frame of the first RuntimeAnimation
  87839. * Used to synchronize Animatables
  87840. */
  87841. get masterFrame(): number;
  87842. /**
  87843. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87844. */
  87845. get weight(): number;
  87846. set weight(value: number);
  87847. /**
  87848. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87849. */
  87850. get speedRatio(): number;
  87851. set speedRatio(value: number);
  87852. /**
  87853. * Creates a new Animatable
  87854. * @param scene defines the hosting scene
  87855. * @param target defines the target object
  87856. * @param fromFrame defines the starting frame number (default is 0)
  87857. * @param toFrame defines the ending frame number (default is 100)
  87858. * @param loopAnimation defines if the animation must loop (default is false)
  87859. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87860. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87861. * @param animations defines a group of animation to add to the new Animatable
  87862. * @param onAnimationLoop defines a callback to call when animation loops
  87863. */
  87864. constructor(scene: Scene,
  87865. /** defines the target object */
  87866. target: any,
  87867. /** defines the starting frame number (default is 0) */
  87868. fromFrame?: number,
  87869. /** defines the ending frame number (default is 100) */
  87870. toFrame?: number,
  87871. /** defines if the animation must loop (default is false) */
  87872. loopAnimation?: boolean, speedRatio?: number,
  87873. /** defines a callback to call when animation ends if it is not looping */
  87874. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  87875. /** defines a callback to call when animation loops */
  87876. onAnimationLoop?: (() => void) | null | undefined);
  87877. /**
  87878. * Synchronize and normalize current Animatable with a source Animatable
  87879. * This is useful when using animation weights and when animations are not of the same length
  87880. * @param root defines the root Animatable to synchronize with
  87881. * @returns the current Animatable
  87882. */
  87883. syncWith(root: Animatable): Animatable;
  87884. /**
  87885. * Gets the list of runtime animations
  87886. * @returns an array of RuntimeAnimation
  87887. */
  87888. getAnimations(): RuntimeAnimation[];
  87889. /**
  87890. * Adds more animations to the current animatable
  87891. * @param target defines the target of the animations
  87892. * @param animations defines the new animations to add
  87893. */
  87894. appendAnimations(target: any, animations: Animation[]): void;
  87895. /**
  87896. * Gets the source animation for a specific property
  87897. * @param property defines the propertyu to look for
  87898. * @returns null or the source animation for the given property
  87899. */
  87900. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  87901. /**
  87902. * Gets the runtime animation for a specific property
  87903. * @param property defines the propertyu to look for
  87904. * @returns null or the runtime animation for the given property
  87905. */
  87906. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  87907. /**
  87908. * Resets the animatable to its original state
  87909. */
  87910. reset(): void;
  87911. /**
  87912. * Allows the animatable to blend with current running animations
  87913. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87914. * @param blendingSpeed defines the blending speed to use
  87915. */
  87916. enableBlending(blendingSpeed: number): void;
  87917. /**
  87918. * Disable animation blending
  87919. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87920. */
  87921. disableBlending(): void;
  87922. /**
  87923. * Jump directly to a given frame
  87924. * @param frame defines the frame to jump to
  87925. */
  87926. goToFrame(frame: number): void;
  87927. /**
  87928. * Pause the animation
  87929. */
  87930. pause(): void;
  87931. /**
  87932. * Restart the animation
  87933. */
  87934. restart(): void;
  87935. private _raiseOnAnimationEnd;
  87936. /**
  87937. * Stop and delete the current animation
  87938. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  87939. * @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)
  87940. */
  87941. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  87942. /**
  87943. * Wait asynchronously for the animation to end
  87944. * @returns a promise which will be fullfilled when the animation ends
  87945. */
  87946. waitAsync(): Promise<Animatable>;
  87947. /** @hidden */
  87948. _animate(delay: number): boolean;
  87949. }
  87950. interface Scene {
  87951. /** @hidden */
  87952. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  87953. /** @hidden */
  87954. _processLateAnimationBindingsForMatrices(holder: {
  87955. totalWeight: number;
  87956. animations: RuntimeAnimation[];
  87957. originalValue: Matrix;
  87958. }): any;
  87959. /** @hidden */
  87960. _processLateAnimationBindingsForQuaternions(holder: {
  87961. totalWeight: number;
  87962. animations: RuntimeAnimation[];
  87963. originalValue: Quaternion;
  87964. }, refQuaternion: Quaternion): Quaternion;
  87965. /** @hidden */
  87966. _processLateAnimationBindings(): void;
  87967. /**
  87968. * Will start the animation sequence of a given target
  87969. * @param target defines the target
  87970. * @param from defines from which frame should animation start
  87971. * @param to defines until which frame should animation run.
  87972. * @param weight defines the weight to apply to the animation (1.0 by default)
  87973. * @param loop defines if the animation loops
  87974. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87975. * @param onAnimationEnd defines the function to be executed when the animation ends
  87976. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87977. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87978. * @param onAnimationLoop defines the callback to call when an animation loops
  87979. * @returns the animatable object created for this animation
  87980. */
  87981. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87982. /**
  87983. * Will start the animation sequence of a given target
  87984. * @param target defines the target
  87985. * @param from defines from which frame should animation start
  87986. * @param to defines until which frame should animation run.
  87987. * @param loop defines if the animation loops
  87988. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87989. * @param onAnimationEnd defines the function to be executed when the animation ends
  87990. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87991. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87992. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  87993. * @param onAnimationLoop defines the callback to call when an animation loops
  87994. * @returns the animatable object created for this animation
  87995. */
  87996. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87997. /**
  87998. * Will start the animation sequence of a given target and its hierarchy
  87999. * @param target defines the target
  88000. * @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.
  88001. * @param from defines from which frame should animation start
  88002. * @param to defines until which frame should animation run.
  88003. * @param loop defines if the animation loops
  88004. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88005. * @param onAnimationEnd defines the function to be executed when the animation ends
  88006. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88007. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88008. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88009. * @param onAnimationLoop defines the callback to call when an animation loops
  88010. * @returns the list of created animatables
  88011. */
  88012. 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[];
  88013. /**
  88014. * Begin a new animation on a given node
  88015. * @param target defines the target where the animation will take place
  88016. * @param animations defines the list of animations to start
  88017. * @param from defines the initial value
  88018. * @param to defines the final value
  88019. * @param loop defines if you want animation to loop (off by default)
  88020. * @param speedRatio defines the speed ratio to apply to all animations
  88021. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88022. * @param onAnimationLoop defines the callback to call when an animation loops
  88023. * @returns the list of created animatables
  88024. */
  88025. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88026. /**
  88027. * Begin a new animation on a given node and its hierarchy
  88028. * @param target defines the root node where the animation will take place
  88029. * @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.
  88030. * @param animations defines the list of animations to start
  88031. * @param from defines the initial value
  88032. * @param to defines the final value
  88033. * @param loop defines if you want animation to loop (off by default)
  88034. * @param speedRatio defines the speed ratio to apply to all animations
  88035. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88036. * @param onAnimationLoop defines the callback to call when an animation loops
  88037. * @returns the list of animatables created for all nodes
  88038. */
  88039. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88040. /**
  88041. * Gets the animatable associated with a specific target
  88042. * @param target defines the target of the animatable
  88043. * @returns the required animatable if found
  88044. */
  88045. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88046. /**
  88047. * Gets all animatables associated with a given target
  88048. * @param target defines the target to look animatables for
  88049. * @returns an array of Animatables
  88050. */
  88051. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88052. /**
  88053. * Stops and removes all animations that have been applied to the scene
  88054. */
  88055. stopAllAnimations(): void;
  88056. /**
  88057. * Gets the current delta time used by animation engine
  88058. */
  88059. deltaTime: number;
  88060. }
  88061. interface Bone {
  88062. /**
  88063. * Copy an animation range from another bone
  88064. * @param source defines the source bone
  88065. * @param rangeName defines the range name to copy
  88066. * @param frameOffset defines the frame offset
  88067. * @param rescaleAsRequired defines if rescaling must be applied if required
  88068. * @param skelDimensionsRatio defines the scaling ratio
  88069. * @returns true if operation was successful
  88070. */
  88071. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88072. }
  88073. }
  88074. declare module BABYLON {
  88075. /**
  88076. * Class used to handle skinning animations
  88077. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88078. */
  88079. export class Skeleton implements IAnimatable {
  88080. /** defines the skeleton name */
  88081. name: string;
  88082. /** defines the skeleton Id */
  88083. id: string;
  88084. /**
  88085. * Defines the list of child bones
  88086. */
  88087. bones: Bone[];
  88088. /**
  88089. * Defines an estimate of the dimension of the skeleton at rest
  88090. */
  88091. dimensionsAtRest: Vector3;
  88092. /**
  88093. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88094. */
  88095. needInitialSkinMatrix: boolean;
  88096. /**
  88097. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88098. */
  88099. overrideMesh: Nullable<AbstractMesh>;
  88100. /**
  88101. * Gets the list of animations attached to this skeleton
  88102. */
  88103. animations: Array<Animation>;
  88104. private _scene;
  88105. private _isDirty;
  88106. private _transformMatrices;
  88107. private _transformMatrixTexture;
  88108. private _meshesWithPoseMatrix;
  88109. private _animatables;
  88110. private _identity;
  88111. private _synchronizedWithMesh;
  88112. private _ranges;
  88113. private _lastAbsoluteTransformsUpdateId;
  88114. private _canUseTextureForBones;
  88115. private _uniqueId;
  88116. /** @hidden */
  88117. _numBonesWithLinkedTransformNode: number;
  88118. /** @hidden */
  88119. _hasWaitingData: Nullable<boolean>;
  88120. /**
  88121. * Specifies if the skeleton should be serialized
  88122. */
  88123. doNotSerialize: boolean;
  88124. private _useTextureToStoreBoneMatrices;
  88125. /**
  88126. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88127. * Please note that this option is not available if the hardware does not support it
  88128. */
  88129. get useTextureToStoreBoneMatrices(): boolean;
  88130. set useTextureToStoreBoneMatrices(value: boolean);
  88131. private _animationPropertiesOverride;
  88132. /**
  88133. * Gets or sets the animation properties override
  88134. */
  88135. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88136. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88137. /**
  88138. * List of inspectable custom properties (used by the Inspector)
  88139. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88140. */
  88141. inspectableCustomProperties: IInspectable[];
  88142. /**
  88143. * An observable triggered before computing the skeleton's matrices
  88144. */
  88145. onBeforeComputeObservable: Observable<Skeleton>;
  88146. /**
  88147. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88148. */
  88149. get isUsingTextureForMatrices(): boolean;
  88150. /**
  88151. * Gets the unique ID of this skeleton
  88152. */
  88153. get uniqueId(): number;
  88154. /**
  88155. * Creates a new skeleton
  88156. * @param name defines the skeleton name
  88157. * @param id defines the skeleton Id
  88158. * @param scene defines the hosting scene
  88159. */
  88160. constructor(
  88161. /** defines the skeleton name */
  88162. name: string,
  88163. /** defines the skeleton Id */
  88164. id: string, scene: Scene);
  88165. /**
  88166. * Gets the current object class name.
  88167. * @return the class name
  88168. */
  88169. getClassName(): string;
  88170. /**
  88171. * Returns an array containing the root bones
  88172. * @returns an array containing the root bones
  88173. */
  88174. getChildren(): Array<Bone>;
  88175. /**
  88176. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88177. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88178. * @returns a Float32Array containing matrices data
  88179. */
  88180. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88181. /**
  88182. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88183. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88184. * @returns a raw texture containing the data
  88185. */
  88186. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88187. /**
  88188. * Gets the current hosting scene
  88189. * @returns a scene object
  88190. */
  88191. getScene(): Scene;
  88192. /**
  88193. * Gets a string representing the current skeleton data
  88194. * @param fullDetails defines a boolean indicating if we want a verbose version
  88195. * @returns a string representing the current skeleton data
  88196. */
  88197. toString(fullDetails?: boolean): string;
  88198. /**
  88199. * Get bone's index searching by name
  88200. * @param name defines bone's name to search for
  88201. * @return the indice of the bone. Returns -1 if not found
  88202. */
  88203. getBoneIndexByName(name: string): number;
  88204. /**
  88205. * Creater a new animation range
  88206. * @param name defines the name of the range
  88207. * @param from defines the start key
  88208. * @param to defines the end key
  88209. */
  88210. createAnimationRange(name: string, from: number, to: number): void;
  88211. /**
  88212. * Delete a specific animation range
  88213. * @param name defines the name of the range
  88214. * @param deleteFrames defines if frames must be removed as well
  88215. */
  88216. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88217. /**
  88218. * Gets a specific animation range
  88219. * @param name defines the name of the range to look for
  88220. * @returns the requested animation range or null if not found
  88221. */
  88222. getAnimationRange(name: string): Nullable<AnimationRange>;
  88223. /**
  88224. * Gets the list of all animation ranges defined on this skeleton
  88225. * @returns an array
  88226. */
  88227. getAnimationRanges(): Nullable<AnimationRange>[];
  88228. /**
  88229. * Copy animation range from a source skeleton.
  88230. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88231. * @param source defines the source skeleton
  88232. * @param name defines the name of the range to copy
  88233. * @param rescaleAsRequired defines if rescaling must be applied if required
  88234. * @returns true if operation was successful
  88235. */
  88236. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88237. /**
  88238. * Forces the skeleton to go to rest pose
  88239. */
  88240. returnToRest(): void;
  88241. private _getHighestAnimationFrame;
  88242. /**
  88243. * Begin a specific animation range
  88244. * @param name defines the name of the range to start
  88245. * @param loop defines if looping must be turned on (false by default)
  88246. * @param speedRatio defines the speed ratio to apply (1 by default)
  88247. * @param onAnimationEnd defines a callback which will be called when animation will end
  88248. * @returns a new animatable
  88249. */
  88250. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88251. /** @hidden */
  88252. _markAsDirty(): void;
  88253. /** @hidden */
  88254. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88255. /** @hidden */
  88256. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88257. private _computeTransformMatrices;
  88258. /**
  88259. * Build all resources required to render a skeleton
  88260. */
  88261. prepare(): void;
  88262. /**
  88263. * Gets the list of animatables currently running for this skeleton
  88264. * @returns an array of animatables
  88265. */
  88266. getAnimatables(): IAnimatable[];
  88267. /**
  88268. * Clone the current skeleton
  88269. * @param name defines the name of the new skeleton
  88270. * @param id defines the id of the new skeleton
  88271. * @returns the new skeleton
  88272. */
  88273. clone(name: string, id?: string): Skeleton;
  88274. /**
  88275. * Enable animation blending for this skeleton
  88276. * @param blendingSpeed defines the blending speed to apply
  88277. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88278. */
  88279. enableBlending(blendingSpeed?: number): void;
  88280. /**
  88281. * Releases all resources associated with the current skeleton
  88282. */
  88283. dispose(): void;
  88284. /**
  88285. * Serialize the skeleton in a JSON object
  88286. * @returns a JSON object
  88287. */
  88288. serialize(): any;
  88289. /**
  88290. * Creates a new skeleton from serialized data
  88291. * @param parsedSkeleton defines the serialized data
  88292. * @param scene defines the hosting scene
  88293. * @returns a new skeleton
  88294. */
  88295. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88296. /**
  88297. * Compute all node absolute transforms
  88298. * @param forceUpdate defines if computation must be done even if cache is up to date
  88299. */
  88300. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88301. /**
  88302. * Gets the root pose matrix
  88303. * @returns a matrix
  88304. */
  88305. getPoseMatrix(): Nullable<Matrix>;
  88306. /**
  88307. * Sorts bones per internal index
  88308. */
  88309. sortBones(): void;
  88310. private _sortBones;
  88311. }
  88312. }
  88313. declare module BABYLON {
  88314. /**
  88315. * Creates an instance based on a source mesh.
  88316. */
  88317. export class InstancedMesh extends AbstractMesh {
  88318. private _sourceMesh;
  88319. private _currentLOD;
  88320. /** @hidden */
  88321. _indexInSourceMeshInstanceArray: number;
  88322. constructor(name: string, source: Mesh);
  88323. /**
  88324. * Returns the string "InstancedMesh".
  88325. */
  88326. getClassName(): string;
  88327. /** Gets the list of lights affecting that mesh */
  88328. get lightSources(): Light[];
  88329. _resyncLightSources(): void;
  88330. _resyncLightSource(light: Light): void;
  88331. _removeLightSource(light: Light, dispose: boolean): void;
  88332. /**
  88333. * If the source mesh receives shadows
  88334. */
  88335. get receiveShadows(): boolean;
  88336. /**
  88337. * The material of the source mesh
  88338. */
  88339. get material(): Nullable<Material>;
  88340. /**
  88341. * Visibility of the source mesh
  88342. */
  88343. get visibility(): number;
  88344. /**
  88345. * Skeleton of the source mesh
  88346. */
  88347. get skeleton(): Nullable<Skeleton>;
  88348. /**
  88349. * Rendering ground id of the source mesh
  88350. */
  88351. get renderingGroupId(): number;
  88352. set renderingGroupId(value: number);
  88353. /**
  88354. * Returns the total number of vertices (integer).
  88355. */
  88356. getTotalVertices(): number;
  88357. /**
  88358. * Returns a positive integer : the total number of indices in this mesh geometry.
  88359. * @returns the numner of indices or zero if the mesh has no geometry.
  88360. */
  88361. getTotalIndices(): number;
  88362. /**
  88363. * The source mesh of the instance
  88364. */
  88365. get sourceMesh(): Mesh;
  88366. /**
  88367. * Is this node ready to be used/rendered
  88368. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88369. * @return {boolean} is it ready
  88370. */
  88371. isReady(completeCheck?: boolean): boolean;
  88372. /**
  88373. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88374. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88375. * @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.
  88376. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88377. */
  88378. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88379. /**
  88380. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88381. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88382. * The `data` are either a numeric array either a Float32Array.
  88383. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88384. * 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).
  88385. * Note that a new underlying VertexBuffer object is created each call.
  88386. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88387. *
  88388. * Possible `kind` values :
  88389. * - VertexBuffer.PositionKind
  88390. * - VertexBuffer.UVKind
  88391. * - VertexBuffer.UV2Kind
  88392. * - VertexBuffer.UV3Kind
  88393. * - VertexBuffer.UV4Kind
  88394. * - VertexBuffer.UV5Kind
  88395. * - VertexBuffer.UV6Kind
  88396. * - VertexBuffer.ColorKind
  88397. * - VertexBuffer.MatricesIndicesKind
  88398. * - VertexBuffer.MatricesIndicesExtraKind
  88399. * - VertexBuffer.MatricesWeightsKind
  88400. * - VertexBuffer.MatricesWeightsExtraKind
  88401. *
  88402. * Returns the Mesh.
  88403. */
  88404. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88405. /**
  88406. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88407. * If the mesh has no geometry, it is simply returned as it is.
  88408. * The `data` are either a numeric array either a Float32Array.
  88409. * No new underlying VertexBuffer object is created.
  88410. * 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.
  88411. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88412. *
  88413. * Possible `kind` values :
  88414. * - VertexBuffer.PositionKind
  88415. * - VertexBuffer.UVKind
  88416. * - VertexBuffer.UV2Kind
  88417. * - VertexBuffer.UV3Kind
  88418. * - VertexBuffer.UV4Kind
  88419. * - VertexBuffer.UV5Kind
  88420. * - VertexBuffer.UV6Kind
  88421. * - VertexBuffer.ColorKind
  88422. * - VertexBuffer.MatricesIndicesKind
  88423. * - VertexBuffer.MatricesIndicesExtraKind
  88424. * - VertexBuffer.MatricesWeightsKind
  88425. * - VertexBuffer.MatricesWeightsExtraKind
  88426. *
  88427. * Returns the Mesh.
  88428. */
  88429. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88430. /**
  88431. * Sets the mesh indices.
  88432. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88433. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88434. * This method creates a new index buffer each call.
  88435. * Returns the Mesh.
  88436. */
  88437. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88438. /**
  88439. * Boolean : True if the mesh owns the requested kind of data.
  88440. */
  88441. isVerticesDataPresent(kind: string): boolean;
  88442. /**
  88443. * Returns an array of indices (IndicesArray).
  88444. */
  88445. getIndices(): Nullable<IndicesArray>;
  88446. get _positions(): Nullable<Vector3[]>;
  88447. /**
  88448. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88449. * This means the mesh underlying bounding box and sphere are recomputed.
  88450. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88451. * @returns the current mesh
  88452. */
  88453. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88454. /** @hidden */
  88455. _preActivate(): InstancedMesh;
  88456. /** @hidden */
  88457. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88458. /** @hidden */
  88459. _postActivate(): void;
  88460. getWorldMatrix(): Matrix;
  88461. get isAnInstance(): boolean;
  88462. /**
  88463. * Returns the current associated LOD AbstractMesh.
  88464. */
  88465. getLOD(camera: Camera): AbstractMesh;
  88466. /** @hidden */
  88467. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88468. /** @hidden */
  88469. _syncSubMeshes(): InstancedMesh;
  88470. /** @hidden */
  88471. _generatePointsArray(): boolean;
  88472. /**
  88473. * Creates a new InstancedMesh from the current mesh.
  88474. * - name (string) : the cloned mesh name
  88475. * - newParent (optional Node) : the optional Node to parent the clone to.
  88476. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88477. *
  88478. * Returns the clone.
  88479. */
  88480. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88481. /**
  88482. * Disposes the InstancedMesh.
  88483. * Returns nothing.
  88484. */
  88485. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88486. }
  88487. interface Mesh {
  88488. /**
  88489. * Register a custom buffer that will be instanced
  88490. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88491. * @param kind defines the buffer kind
  88492. * @param stride defines the stride in floats
  88493. */
  88494. registerInstancedBuffer(kind: string, stride: number): void;
  88495. /** @hidden */
  88496. _userInstancedBuffersStorage: {
  88497. data: {
  88498. [key: string]: Float32Array;
  88499. };
  88500. sizes: {
  88501. [key: string]: number;
  88502. };
  88503. vertexBuffers: {
  88504. [key: string]: Nullable<VertexBuffer>;
  88505. };
  88506. strides: {
  88507. [key: string]: number;
  88508. };
  88509. };
  88510. }
  88511. interface AbstractMesh {
  88512. /**
  88513. * Object used to store instanced buffers defined by user
  88514. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88515. */
  88516. instancedBuffers: {
  88517. [key: string]: any;
  88518. };
  88519. }
  88520. }
  88521. declare module BABYLON {
  88522. /**
  88523. * Defines the options associated with the creation of a shader material.
  88524. */
  88525. export interface IShaderMaterialOptions {
  88526. /**
  88527. * Does the material work in alpha blend mode
  88528. */
  88529. needAlphaBlending: boolean;
  88530. /**
  88531. * Does the material work in alpha test mode
  88532. */
  88533. needAlphaTesting: boolean;
  88534. /**
  88535. * The list of attribute names used in the shader
  88536. */
  88537. attributes: string[];
  88538. /**
  88539. * The list of unifrom names used in the shader
  88540. */
  88541. uniforms: string[];
  88542. /**
  88543. * The list of UBO names used in the shader
  88544. */
  88545. uniformBuffers: string[];
  88546. /**
  88547. * The list of sampler names used in the shader
  88548. */
  88549. samplers: string[];
  88550. /**
  88551. * The list of defines used in the shader
  88552. */
  88553. defines: string[];
  88554. }
  88555. /**
  88556. * 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.
  88557. *
  88558. * This returned material effects how the mesh will look based on the code in the shaders.
  88559. *
  88560. * @see http://doc.babylonjs.com/how_to/shader_material
  88561. */
  88562. export class ShaderMaterial extends Material {
  88563. private _shaderPath;
  88564. private _options;
  88565. private _textures;
  88566. private _textureArrays;
  88567. private _floats;
  88568. private _ints;
  88569. private _floatsArrays;
  88570. private _colors3;
  88571. private _colors3Arrays;
  88572. private _colors4;
  88573. private _colors4Arrays;
  88574. private _vectors2;
  88575. private _vectors3;
  88576. private _vectors4;
  88577. private _matrices;
  88578. private _matrixArrays;
  88579. private _matrices3x3;
  88580. private _matrices2x2;
  88581. private _vectors2Arrays;
  88582. private _vectors3Arrays;
  88583. private _vectors4Arrays;
  88584. private _cachedWorldViewMatrix;
  88585. private _cachedWorldViewProjectionMatrix;
  88586. private _renderId;
  88587. private _multiview;
  88588. /**
  88589. * Instantiate a new shader material.
  88590. * 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.
  88591. * This returned material effects how the mesh will look based on the code in the shaders.
  88592. * @see http://doc.babylonjs.com/how_to/shader_material
  88593. * @param name Define the name of the material in the scene
  88594. * @param scene Define the scene the material belongs to
  88595. * @param shaderPath Defines the route to the shader code in one of three ways:
  88596. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88597. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88598. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88599. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88600. * @param options Define the options used to create the shader
  88601. */
  88602. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88603. /**
  88604. * Gets the shader path used to define the shader code
  88605. * It can be modified to trigger a new compilation
  88606. */
  88607. get shaderPath(): any;
  88608. /**
  88609. * Sets the shader path used to define the shader code
  88610. * It can be modified to trigger a new compilation
  88611. */
  88612. set shaderPath(shaderPath: any);
  88613. /**
  88614. * Gets the options used to compile the shader.
  88615. * They can be modified to trigger a new compilation
  88616. */
  88617. get options(): IShaderMaterialOptions;
  88618. /**
  88619. * Gets the current class name of the material e.g. "ShaderMaterial"
  88620. * Mainly use in serialization.
  88621. * @returns the class name
  88622. */
  88623. getClassName(): string;
  88624. /**
  88625. * Specifies if the material will require alpha blending
  88626. * @returns a boolean specifying if alpha blending is needed
  88627. */
  88628. needAlphaBlending(): boolean;
  88629. /**
  88630. * Specifies if this material should be rendered in alpha test mode
  88631. * @returns a boolean specifying if an alpha test is needed.
  88632. */
  88633. needAlphaTesting(): boolean;
  88634. private _checkUniform;
  88635. /**
  88636. * Set a texture in the shader.
  88637. * @param name Define the name of the uniform samplers as defined in the shader
  88638. * @param texture Define the texture to bind to this sampler
  88639. * @return the material itself allowing "fluent" like uniform updates
  88640. */
  88641. setTexture(name: string, texture: Texture): ShaderMaterial;
  88642. /**
  88643. * Set a texture array in the shader.
  88644. * @param name Define the name of the uniform sampler array as defined in the shader
  88645. * @param textures Define the list of textures to bind to this sampler
  88646. * @return the material itself allowing "fluent" like uniform updates
  88647. */
  88648. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88649. /**
  88650. * Set a float in the shader.
  88651. * @param name Define the name of the uniform as defined in the shader
  88652. * @param value Define the value to give to the uniform
  88653. * @return the material itself allowing "fluent" like uniform updates
  88654. */
  88655. setFloat(name: string, value: number): ShaderMaterial;
  88656. /**
  88657. * Set a int in the shader.
  88658. * @param name Define the name of the uniform as defined in the shader
  88659. * @param value Define the value to give to the uniform
  88660. * @return the material itself allowing "fluent" like uniform updates
  88661. */
  88662. setInt(name: string, value: number): ShaderMaterial;
  88663. /**
  88664. * Set an array of floats in the shader.
  88665. * @param name Define the name of the uniform as defined in the shader
  88666. * @param value Define the value to give to the uniform
  88667. * @return the material itself allowing "fluent" like uniform updates
  88668. */
  88669. setFloats(name: string, value: number[]): ShaderMaterial;
  88670. /**
  88671. * Set a vec3 in the shader from a Color3.
  88672. * @param name Define the name of the uniform as defined in the shader
  88673. * @param value Define the value to give to the uniform
  88674. * @return the material itself allowing "fluent" like uniform updates
  88675. */
  88676. setColor3(name: string, value: Color3): ShaderMaterial;
  88677. /**
  88678. * Set a vec3 array in the shader from a Color3 array.
  88679. * @param name Define the name of the uniform as defined in the shader
  88680. * @param value Define the value to give to the uniform
  88681. * @return the material itself allowing "fluent" like uniform updates
  88682. */
  88683. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88684. /**
  88685. * Set a vec4 in the shader from a Color4.
  88686. * @param name Define the name of the uniform as defined in the shader
  88687. * @param value Define the value to give to the uniform
  88688. * @return the material itself allowing "fluent" like uniform updates
  88689. */
  88690. setColor4(name: string, value: Color4): ShaderMaterial;
  88691. /**
  88692. * Set a vec4 array in the shader from a Color4 array.
  88693. * @param name Define the name of the uniform as defined in the shader
  88694. * @param value Define the value to give to the uniform
  88695. * @return the material itself allowing "fluent" like uniform updates
  88696. */
  88697. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88698. /**
  88699. * Set a vec2 in the shader from a Vector2.
  88700. * @param name Define the name of the uniform as defined in the shader
  88701. * @param value Define the value to give to the uniform
  88702. * @return the material itself allowing "fluent" like uniform updates
  88703. */
  88704. setVector2(name: string, value: Vector2): ShaderMaterial;
  88705. /**
  88706. * Set a vec3 in the shader from a Vector3.
  88707. * @param name Define the name of the uniform as defined in the shader
  88708. * @param value Define the value to give to the uniform
  88709. * @return the material itself allowing "fluent" like uniform updates
  88710. */
  88711. setVector3(name: string, value: Vector3): ShaderMaterial;
  88712. /**
  88713. * Set a vec4 in the shader from a Vector4.
  88714. * @param name Define the name of the uniform as defined in the shader
  88715. * @param value Define the value to give to the uniform
  88716. * @return the material itself allowing "fluent" like uniform updates
  88717. */
  88718. setVector4(name: string, value: Vector4): ShaderMaterial;
  88719. /**
  88720. * Set a mat4 in the shader from a Matrix.
  88721. * @param name Define the name of the uniform as defined in the shader
  88722. * @param value Define the value to give to the uniform
  88723. * @return the material itself allowing "fluent" like uniform updates
  88724. */
  88725. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88726. /**
  88727. * Set a float32Array in the shader from a matrix array.
  88728. * @param name Define the name of the uniform as defined in the shader
  88729. * @param value Define the value to give to the uniform
  88730. * @return the material itself allowing "fluent" like uniform updates
  88731. */
  88732. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88733. /**
  88734. * Set a mat3 in the shader from a Float32Array.
  88735. * @param name Define the name of the uniform as defined in the shader
  88736. * @param value Define the value to give to the uniform
  88737. * @return the material itself allowing "fluent" like uniform updates
  88738. */
  88739. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88740. /**
  88741. * Set a mat2 in the shader from a Float32Array.
  88742. * @param name Define the name of the uniform as defined in the shader
  88743. * @param value Define the value to give to the uniform
  88744. * @return the material itself allowing "fluent" like uniform updates
  88745. */
  88746. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88747. /**
  88748. * Set a vec2 array in the shader from a number array.
  88749. * @param name Define the name of the uniform as defined in the shader
  88750. * @param value Define the value to give to the uniform
  88751. * @return the material itself allowing "fluent" like uniform updates
  88752. */
  88753. setArray2(name: string, value: number[]): ShaderMaterial;
  88754. /**
  88755. * Set a vec3 array in the shader from a number array.
  88756. * @param name Define the name of the uniform as defined in the shader
  88757. * @param value Define the value to give to the uniform
  88758. * @return the material itself allowing "fluent" like uniform updates
  88759. */
  88760. setArray3(name: string, value: number[]): ShaderMaterial;
  88761. /**
  88762. * Set a vec4 array in the shader from a number array.
  88763. * @param name Define the name of the uniform as defined in the shader
  88764. * @param value Define the value to give to the uniform
  88765. * @return the material itself allowing "fluent" like uniform updates
  88766. */
  88767. setArray4(name: string, value: number[]): ShaderMaterial;
  88768. private _checkCache;
  88769. /**
  88770. * Specifies that the submesh is ready to be used
  88771. * @param mesh defines the mesh to check
  88772. * @param subMesh defines which submesh to check
  88773. * @param useInstances specifies that instances should be used
  88774. * @returns a boolean indicating that the submesh is ready or not
  88775. */
  88776. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88777. /**
  88778. * Checks if the material is ready to render the requested mesh
  88779. * @param mesh Define the mesh to render
  88780. * @param useInstances Define whether or not the material is used with instances
  88781. * @returns true if ready, otherwise false
  88782. */
  88783. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88784. /**
  88785. * Binds the world matrix to the material
  88786. * @param world defines the world transformation matrix
  88787. */
  88788. bindOnlyWorldMatrix(world: Matrix): void;
  88789. /**
  88790. * Binds the material to the mesh
  88791. * @param world defines the world transformation matrix
  88792. * @param mesh defines the mesh to bind the material to
  88793. */
  88794. bind(world: Matrix, mesh?: Mesh): void;
  88795. /**
  88796. * Gets the active textures from the material
  88797. * @returns an array of textures
  88798. */
  88799. getActiveTextures(): BaseTexture[];
  88800. /**
  88801. * Specifies if the material uses a texture
  88802. * @param texture defines the texture to check against the material
  88803. * @returns a boolean specifying if the material uses the texture
  88804. */
  88805. hasTexture(texture: BaseTexture): boolean;
  88806. /**
  88807. * Makes a duplicate of the material, and gives it a new name
  88808. * @param name defines the new name for the duplicated material
  88809. * @returns the cloned material
  88810. */
  88811. clone(name: string): ShaderMaterial;
  88812. /**
  88813. * Disposes the material
  88814. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88815. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88816. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88817. */
  88818. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88819. /**
  88820. * Serializes this material in a JSON representation
  88821. * @returns the serialized material object
  88822. */
  88823. serialize(): any;
  88824. /**
  88825. * Creates a shader material from parsed shader material data
  88826. * @param source defines the JSON represnetation of the material
  88827. * @param scene defines the hosting scene
  88828. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88829. * @returns a new material
  88830. */
  88831. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88832. }
  88833. }
  88834. declare module BABYLON {
  88835. /** @hidden */
  88836. export var colorPixelShader: {
  88837. name: string;
  88838. shader: string;
  88839. };
  88840. }
  88841. declare module BABYLON {
  88842. /** @hidden */
  88843. export var colorVertexShader: {
  88844. name: string;
  88845. shader: string;
  88846. };
  88847. }
  88848. declare module BABYLON {
  88849. /**
  88850. * Line mesh
  88851. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88852. */
  88853. export class LinesMesh extends Mesh {
  88854. /**
  88855. * If vertex color should be applied to the mesh
  88856. */
  88857. readonly useVertexColor?: boolean | undefined;
  88858. /**
  88859. * If vertex alpha should be applied to the mesh
  88860. */
  88861. readonly useVertexAlpha?: boolean | undefined;
  88862. /**
  88863. * Color of the line (Default: White)
  88864. */
  88865. color: Color3;
  88866. /**
  88867. * Alpha of the line (Default: 1)
  88868. */
  88869. alpha: number;
  88870. /**
  88871. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88872. * This margin is expressed in world space coordinates, so its value may vary.
  88873. * Default value is 0.1
  88874. */
  88875. intersectionThreshold: number;
  88876. private _colorShader;
  88877. private color4;
  88878. /**
  88879. * Creates a new LinesMesh
  88880. * @param name defines the name
  88881. * @param scene defines the hosting scene
  88882. * @param parent defines the parent mesh if any
  88883. * @param source defines the optional source LinesMesh used to clone data from
  88884. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88885. * When false, achieved by calling a clone(), also passing False.
  88886. * This will make creation of children, recursive.
  88887. * @param useVertexColor defines if this LinesMesh supports vertex color
  88888. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88889. */
  88890. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88891. /**
  88892. * If vertex color should be applied to the mesh
  88893. */
  88894. useVertexColor?: boolean | undefined,
  88895. /**
  88896. * If vertex alpha should be applied to the mesh
  88897. */
  88898. useVertexAlpha?: boolean | undefined);
  88899. private _addClipPlaneDefine;
  88900. private _removeClipPlaneDefine;
  88901. isReady(): boolean;
  88902. /**
  88903. * Returns the string "LineMesh"
  88904. */
  88905. getClassName(): string;
  88906. /**
  88907. * @hidden
  88908. */
  88909. get material(): Material;
  88910. /**
  88911. * @hidden
  88912. */
  88913. set material(value: Material);
  88914. /**
  88915. * @hidden
  88916. */
  88917. get checkCollisions(): boolean;
  88918. /** @hidden */
  88919. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88920. /** @hidden */
  88921. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88922. /**
  88923. * Disposes of the line mesh
  88924. * @param doNotRecurse If children should be disposed
  88925. */
  88926. dispose(doNotRecurse?: boolean): void;
  88927. /**
  88928. * Returns a new LineMesh object cloned from the current one.
  88929. */
  88930. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  88931. /**
  88932. * Creates a new InstancedLinesMesh object from the mesh model.
  88933. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88934. * @param name defines the name of the new instance
  88935. * @returns a new InstancedLinesMesh
  88936. */
  88937. createInstance(name: string): InstancedLinesMesh;
  88938. }
  88939. /**
  88940. * Creates an instance based on a source LinesMesh
  88941. */
  88942. export class InstancedLinesMesh extends InstancedMesh {
  88943. /**
  88944. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88945. * This margin is expressed in world space coordinates, so its value may vary.
  88946. * Initilized with the intersectionThreshold value of the source LinesMesh
  88947. */
  88948. intersectionThreshold: number;
  88949. constructor(name: string, source: LinesMesh);
  88950. /**
  88951. * Returns the string "InstancedLinesMesh".
  88952. */
  88953. getClassName(): string;
  88954. }
  88955. }
  88956. declare module BABYLON {
  88957. /** @hidden */
  88958. export var linePixelShader: {
  88959. name: string;
  88960. shader: string;
  88961. };
  88962. }
  88963. declare module BABYLON {
  88964. /** @hidden */
  88965. export var lineVertexShader: {
  88966. name: string;
  88967. shader: string;
  88968. };
  88969. }
  88970. declare module BABYLON {
  88971. interface AbstractMesh {
  88972. /**
  88973. * Gets the edgesRenderer associated with the mesh
  88974. */
  88975. edgesRenderer: Nullable<EdgesRenderer>;
  88976. }
  88977. interface LinesMesh {
  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 currentAbstractMesh
  88984. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88985. */
  88986. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88987. }
  88988. interface InstancedLinesMesh {
  88989. /**
  88990. * Enables the edge rendering mode on the mesh.
  88991. * This mode makes the mesh edges visible
  88992. * @param epsilon defines the maximal distance between two angles to detect a face
  88993. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88994. * @returns the current InstancedLinesMesh
  88995. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88996. */
  88997. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88998. }
  88999. /**
  89000. * Defines the minimum contract an Edges renderer should follow.
  89001. */
  89002. export interface IEdgesRenderer extends IDisposable {
  89003. /**
  89004. * Gets or sets a boolean indicating if the edgesRenderer is active
  89005. */
  89006. isEnabled: boolean;
  89007. /**
  89008. * Renders the edges of the attached mesh,
  89009. */
  89010. render(): void;
  89011. /**
  89012. * Checks wether or not the edges renderer is ready to render.
  89013. * @return true if ready, otherwise false.
  89014. */
  89015. isReady(): boolean;
  89016. }
  89017. /**
  89018. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89019. */
  89020. export class EdgesRenderer implements IEdgesRenderer {
  89021. /**
  89022. * Define the size of the edges with an orthographic camera
  89023. */
  89024. edgesWidthScalerForOrthographic: number;
  89025. /**
  89026. * Define the size of the edges with a perspective camera
  89027. */
  89028. edgesWidthScalerForPerspective: number;
  89029. protected _source: AbstractMesh;
  89030. protected _linesPositions: number[];
  89031. protected _linesNormals: number[];
  89032. protected _linesIndices: number[];
  89033. protected _epsilon: number;
  89034. protected _indicesCount: number;
  89035. protected _lineShader: ShaderMaterial;
  89036. protected _ib: DataBuffer;
  89037. protected _buffers: {
  89038. [key: string]: Nullable<VertexBuffer>;
  89039. };
  89040. protected _checkVerticesInsteadOfIndices: boolean;
  89041. private _meshRebuildObserver;
  89042. private _meshDisposeObserver;
  89043. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89044. isEnabled: boolean;
  89045. /**
  89046. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89047. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89048. * @param source Mesh used to create edges
  89049. * @param epsilon sum of angles in adjacency to check for edge
  89050. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89051. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89052. */
  89053. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89054. protected _prepareRessources(): void;
  89055. /** @hidden */
  89056. _rebuild(): void;
  89057. /**
  89058. * Releases the required resources for the edges renderer
  89059. */
  89060. dispose(): void;
  89061. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89062. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89063. /**
  89064. * Checks if the pair of p0 and p1 is en edge
  89065. * @param faceIndex
  89066. * @param edge
  89067. * @param faceNormals
  89068. * @param p0
  89069. * @param p1
  89070. * @private
  89071. */
  89072. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89073. /**
  89074. * push line into the position, normal and index buffer
  89075. * @protected
  89076. */
  89077. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89078. /**
  89079. * Generates lines edges from adjacencjes
  89080. * @private
  89081. */
  89082. _generateEdgesLines(): void;
  89083. /**
  89084. * Checks wether or not the edges renderer is ready to render.
  89085. * @return true if ready, otherwise false.
  89086. */
  89087. isReady(): boolean;
  89088. /**
  89089. * Renders the edges of the attached mesh,
  89090. */
  89091. render(): void;
  89092. }
  89093. /**
  89094. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89095. */
  89096. export class LineEdgesRenderer extends EdgesRenderer {
  89097. /**
  89098. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89099. * @param source LineMesh used to generate edges
  89100. * @param epsilon not important (specified angle for edge detection)
  89101. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89102. */
  89103. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89104. /**
  89105. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89106. */
  89107. _generateEdgesLines(): void;
  89108. }
  89109. }
  89110. declare module BABYLON {
  89111. /**
  89112. * This represents the object necessary to create a rendering group.
  89113. * This is exclusively used and created by the rendering manager.
  89114. * To modify the behavior, you use the available helpers in your scene or meshes.
  89115. * @hidden
  89116. */
  89117. export class RenderingGroup {
  89118. index: number;
  89119. private static _zeroVector;
  89120. private _scene;
  89121. private _opaqueSubMeshes;
  89122. private _transparentSubMeshes;
  89123. private _alphaTestSubMeshes;
  89124. private _depthOnlySubMeshes;
  89125. private _particleSystems;
  89126. private _spriteManagers;
  89127. private _opaqueSortCompareFn;
  89128. private _alphaTestSortCompareFn;
  89129. private _transparentSortCompareFn;
  89130. private _renderOpaque;
  89131. private _renderAlphaTest;
  89132. private _renderTransparent;
  89133. /** @hidden */
  89134. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89135. onBeforeTransparentRendering: () => void;
  89136. /**
  89137. * Set the opaque sort comparison function.
  89138. * If null the sub meshes will be render in the order they were created
  89139. */
  89140. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89141. /**
  89142. * Set the alpha test sort comparison function.
  89143. * If null the sub meshes will be render in the order they were created
  89144. */
  89145. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89146. /**
  89147. * Set the transparent sort comparison function.
  89148. * If null the sub meshes will be render in the order they were created
  89149. */
  89150. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89151. /**
  89152. * Creates a new rendering group.
  89153. * @param index The rendering group index
  89154. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89155. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89156. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89157. */
  89158. 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>);
  89159. /**
  89160. * Render all the sub meshes contained in the group.
  89161. * @param customRenderFunction Used to override the default render behaviour of the group.
  89162. * @returns true if rendered some submeshes.
  89163. */
  89164. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89165. /**
  89166. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89167. * @param subMeshes The submeshes to render
  89168. */
  89169. private renderOpaqueSorted;
  89170. /**
  89171. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89172. * @param subMeshes The submeshes to render
  89173. */
  89174. private renderAlphaTestSorted;
  89175. /**
  89176. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89177. * @param subMeshes The submeshes to render
  89178. */
  89179. private renderTransparentSorted;
  89180. /**
  89181. * Renders the submeshes in a specified order.
  89182. * @param subMeshes The submeshes to sort before render
  89183. * @param sortCompareFn The comparison function use to sort
  89184. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89185. * @param transparent Specifies to activate blending if true
  89186. */
  89187. private static renderSorted;
  89188. /**
  89189. * Renders the submeshes in the order they were dispatched (no sort applied).
  89190. * @param subMeshes The submeshes to render
  89191. */
  89192. private static renderUnsorted;
  89193. /**
  89194. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89195. * are rendered back to front if in the same alpha index.
  89196. *
  89197. * @param a The first submesh
  89198. * @param b The second submesh
  89199. * @returns The result of the comparison
  89200. */
  89201. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89202. /**
  89203. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89204. * are rendered back to front.
  89205. *
  89206. * @param a The first submesh
  89207. * @param b The second submesh
  89208. * @returns The result of the comparison
  89209. */
  89210. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89211. /**
  89212. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89213. * are rendered front to back (prevent overdraw).
  89214. *
  89215. * @param a The first submesh
  89216. * @param b The second submesh
  89217. * @returns The result of the comparison
  89218. */
  89219. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89220. /**
  89221. * Resets the different lists of submeshes to prepare a new frame.
  89222. */
  89223. prepare(): void;
  89224. dispose(): void;
  89225. /**
  89226. * Inserts the submesh in its correct queue depending on its material.
  89227. * @param subMesh The submesh to dispatch
  89228. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89229. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89230. */
  89231. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89232. dispatchSprites(spriteManager: ISpriteManager): void;
  89233. dispatchParticles(particleSystem: IParticleSystem): void;
  89234. private _renderParticles;
  89235. private _renderSprites;
  89236. }
  89237. }
  89238. declare module BABYLON {
  89239. /**
  89240. * Interface describing the different options available in the rendering manager
  89241. * regarding Auto Clear between groups.
  89242. */
  89243. export interface IRenderingManagerAutoClearSetup {
  89244. /**
  89245. * Defines whether or not autoclear is enable.
  89246. */
  89247. autoClear: boolean;
  89248. /**
  89249. * Defines whether or not to autoclear the depth buffer.
  89250. */
  89251. depth: boolean;
  89252. /**
  89253. * Defines whether or not to autoclear the stencil buffer.
  89254. */
  89255. stencil: boolean;
  89256. }
  89257. /**
  89258. * This class is used by the onRenderingGroupObservable
  89259. */
  89260. export class RenderingGroupInfo {
  89261. /**
  89262. * The Scene that being rendered
  89263. */
  89264. scene: Scene;
  89265. /**
  89266. * The camera currently used for the rendering pass
  89267. */
  89268. camera: Nullable<Camera>;
  89269. /**
  89270. * The ID of the renderingGroup being processed
  89271. */
  89272. renderingGroupId: number;
  89273. }
  89274. /**
  89275. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89276. * It is enable to manage the different groups as well as the different necessary sort functions.
  89277. * This should not be used directly aside of the few static configurations
  89278. */
  89279. export class RenderingManager {
  89280. /**
  89281. * The max id used for rendering groups (not included)
  89282. */
  89283. static MAX_RENDERINGGROUPS: number;
  89284. /**
  89285. * The min id used for rendering groups (included)
  89286. */
  89287. static MIN_RENDERINGGROUPS: number;
  89288. /**
  89289. * Used to globally prevent autoclearing scenes.
  89290. */
  89291. static AUTOCLEAR: boolean;
  89292. /**
  89293. * @hidden
  89294. */
  89295. _useSceneAutoClearSetup: boolean;
  89296. private _scene;
  89297. private _renderingGroups;
  89298. private _depthStencilBufferAlreadyCleaned;
  89299. private _autoClearDepthStencil;
  89300. private _customOpaqueSortCompareFn;
  89301. private _customAlphaTestSortCompareFn;
  89302. private _customTransparentSortCompareFn;
  89303. private _renderingGroupInfo;
  89304. /**
  89305. * Instantiates a new rendering group for a particular scene
  89306. * @param scene Defines the scene the groups belongs to
  89307. */
  89308. constructor(scene: Scene);
  89309. private _clearDepthStencilBuffer;
  89310. /**
  89311. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89312. * @hidden
  89313. */
  89314. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89315. /**
  89316. * Resets the different information of the group to prepare a new frame
  89317. * @hidden
  89318. */
  89319. reset(): void;
  89320. /**
  89321. * Dispose and release the group and its associated resources.
  89322. * @hidden
  89323. */
  89324. dispose(): void;
  89325. /**
  89326. * Clear the info related to rendering groups preventing retention points during dispose.
  89327. */
  89328. freeRenderingGroups(): void;
  89329. private _prepareRenderingGroup;
  89330. /**
  89331. * Add a sprite manager to the rendering manager in order to render it this frame.
  89332. * @param spriteManager Define the sprite manager to render
  89333. */
  89334. dispatchSprites(spriteManager: ISpriteManager): void;
  89335. /**
  89336. * Add a particle system to the rendering manager in order to render it this frame.
  89337. * @param particleSystem Define the particle system to render
  89338. */
  89339. dispatchParticles(particleSystem: IParticleSystem): void;
  89340. /**
  89341. * Add a submesh to the manager in order to render it this frame
  89342. * @param subMesh The submesh to dispatch
  89343. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89344. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89345. */
  89346. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89347. /**
  89348. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89349. * This allowed control for front to back rendering or reversly depending of the special needs.
  89350. *
  89351. * @param renderingGroupId The rendering group id corresponding to its index
  89352. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89353. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89354. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89355. */
  89356. 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;
  89357. /**
  89358. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89359. *
  89360. * @param renderingGroupId The rendering group id corresponding to its index
  89361. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89362. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89363. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89364. */
  89365. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89366. /**
  89367. * Gets the current auto clear configuration for one rendering group of the rendering
  89368. * manager.
  89369. * @param index the rendering group index to get the information for
  89370. * @returns The auto clear setup for the requested rendering group
  89371. */
  89372. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89373. }
  89374. }
  89375. declare module BABYLON {
  89376. /**
  89377. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89378. */
  89379. export interface ICustomShaderOptions {
  89380. /**
  89381. * Gets or sets the custom shader name to use
  89382. */
  89383. shaderName: string;
  89384. /**
  89385. * The list of attribute names used in the shader
  89386. */
  89387. attributes?: string[];
  89388. /**
  89389. * The list of unifrom names used in the shader
  89390. */
  89391. uniforms?: string[];
  89392. /**
  89393. * The list of sampler names used in the shader
  89394. */
  89395. samplers?: string[];
  89396. /**
  89397. * The list of defines used in the shader
  89398. */
  89399. defines?: string[];
  89400. }
  89401. /**
  89402. * Interface to implement to create a shadow generator compatible with BJS.
  89403. */
  89404. export interface IShadowGenerator {
  89405. /**
  89406. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89407. * @returns The render target texture if present otherwise, null
  89408. */
  89409. getShadowMap(): Nullable<RenderTargetTexture>;
  89410. /**
  89411. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89412. * @param subMesh The submesh we want to render in the shadow map
  89413. * @param useInstances Defines wether will draw in the map using instances
  89414. * @returns true if ready otherwise, false
  89415. */
  89416. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89417. /**
  89418. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89419. * @param defines Defines of the material we want to update
  89420. * @param lightIndex Index of the light in the enabled light list of the material
  89421. */
  89422. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89423. /**
  89424. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89425. * defined in the generator but impacting the effect).
  89426. * It implies the unifroms available on the materials are the standard BJS ones.
  89427. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89428. * @param effect The effect we are binfing the information for
  89429. */
  89430. bindShadowLight(lightIndex: string, effect: Effect): void;
  89431. /**
  89432. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89433. * (eq to shadow prjection matrix * light transform matrix)
  89434. * @returns The transform matrix used to create the shadow map
  89435. */
  89436. getTransformMatrix(): Matrix;
  89437. /**
  89438. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89439. * Cube and 2D textures for instance.
  89440. */
  89441. recreateShadowMap(): void;
  89442. /**
  89443. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89444. * @param onCompiled Callback triggered at the and of the effects compilation
  89445. * @param options Sets of optional options forcing the compilation with different modes
  89446. */
  89447. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89448. useInstances: boolean;
  89449. }>): void;
  89450. /**
  89451. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89452. * @param options Sets of optional options forcing the compilation with different modes
  89453. * @returns A promise that resolves when the compilation completes
  89454. */
  89455. forceCompilationAsync(options?: Partial<{
  89456. useInstances: boolean;
  89457. }>): Promise<void>;
  89458. /**
  89459. * Serializes the shadow generator setup to a json object.
  89460. * @returns The serialized JSON object
  89461. */
  89462. serialize(): any;
  89463. /**
  89464. * Disposes the Shadow map and related Textures and effects.
  89465. */
  89466. dispose(): void;
  89467. }
  89468. /**
  89469. * Default implementation IShadowGenerator.
  89470. * This is the main object responsible of generating shadows in the framework.
  89471. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89472. */
  89473. export class ShadowGenerator implements IShadowGenerator {
  89474. /**
  89475. * Name of the shadow generator class
  89476. */
  89477. static CLASSNAME: string;
  89478. /**
  89479. * Shadow generator mode None: no filtering applied.
  89480. */
  89481. static readonly FILTER_NONE: number;
  89482. /**
  89483. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89484. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89485. */
  89486. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89487. /**
  89488. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89489. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89490. */
  89491. static readonly FILTER_POISSONSAMPLING: number;
  89492. /**
  89493. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89494. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89495. */
  89496. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89497. /**
  89498. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89499. * edge artifacts on steep falloff.
  89500. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89501. */
  89502. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89503. /**
  89504. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89505. * edge artifacts on steep falloff.
  89506. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89507. */
  89508. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89509. /**
  89510. * Shadow generator mode PCF: Percentage Closer Filtering
  89511. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89512. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89513. */
  89514. static readonly FILTER_PCF: number;
  89515. /**
  89516. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89517. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89518. * Contact Hardening
  89519. */
  89520. static readonly FILTER_PCSS: number;
  89521. /**
  89522. * Reserved for PCF and PCSS
  89523. * Highest Quality.
  89524. *
  89525. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89526. *
  89527. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89528. */
  89529. static readonly QUALITY_HIGH: number;
  89530. /**
  89531. * Reserved for PCF and PCSS
  89532. * Good tradeoff for quality/perf cross devices
  89533. *
  89534. * Execute PCF on a 3*3 kernel.
  89535. *
  89536. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89537. */
  89538. static readonly QUALITY_MEDIUM: number;
  89539. /**
  89540. * Reserved for PCF and PCSS
  89541. * The lowest quality but the fastest.
  89542. *
  89543. * Execute PCF on a 1*1 kernel.
  89544. *
  89545. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89546. */
  89547. static readonly QUALITY_LOW: number;
  89548. /** Gets or sets the custom shader name to use */
  89549. customShaderOptions: ICustomShaderOptions;
  89550. /**
  89551. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89552. */
  89553. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89554. /**
  89555. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89556. */
  89557. onAfterShadowMapRenderObservable: Observable<Effect>;
  89558. /**
  89559. * Observable triggered before a mesh is rendered in the shadow map.
  89560. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89561. */
  89562. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89563. /**
  89564. * Observable triggered after a mesh is rendered in the shadow map.
  89565. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89566. */
  89567. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89568. protected _bias: number;
  89569. /**
  89570. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89571. */
  89572. get bias(): number;
  89573. /**
  89574. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89575. */
  89576. set bias(bias: number);
  89577. protected _normalBias: number;
  89578. /**
  89579. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89580. */
  89581. get normalBias(): number;
  89582. /**
  89583. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89584. */
  89585. set normalBias(normalBias: number);
  89586. protected _blurBoxOffset: number;
  89587. /**
  89588. * Gets the blur box offset: offset applied during the blur pass.
  89589. * Only useful if useKernelBlur = false
  89590. */
  89591. get blurBoxOffset(): number;
  89592. /**
  89593. * Sets the blur box offset: offset applied during the blur pass.
  89594. * Only useful if useKernelBlur = false
  89595. */
  89596. set blurBoxOffset(value: number);
  89597. protected _blurScale: number;
  89598. /**
  89599. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89600. * 2 means half of the size.
  89601. */
  89602. get blurScale(): number;
  89603. /**
  89604. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89605. * 2 means half of the size.
  89606. */
  89607. set blurScale(value: number);
  89608. protected _blurKernel: number;
  89609. /**
  89610. * Gets the blur kernel: kernel size of the blur pass.
  89611. * Only useful if useKernelBlur = true
  89612. */
  89613. get blurKernel(): number;
  89614. /**
  89615. * Sets the blur kernel: kernel size of the blur pass.
  89616. * Only useful if useKernelBlur = true
  89617. */
  89618. set blurKernel(value: number);
  89619. protected _useKernelBlur: boolean;
  89620. /**
  89621. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89622. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89623. */
  89624. get useKernelBlur(): boolean;
  89625. /**
  89626. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89627. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89628. */
  89629. set useKernelBlur(value: boolean);
  89630. protected _depthScale: number;
  89631. /**
  89632. * Gets the depth scale used in ESM mode.
  89633. */
  89634. get depthScale(): number;
  89635. /**
  89636. * Sets the depth scale used in ESM mode.
  89637. * This can override the scale stored on the light.
  89638. */
  89639. set depthScale(value: number);
  89640. protected _validateFilter(filter: number): number;
  89641. protected _filter: number;
  89642. /**
  89643. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89644. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89645. */
  89646. get filter(): number;
  89647. /**
  89648. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89649. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89650. */
  89651. set filter(value: number);
  89652. /**
  89653. * Gets if the current filter is set to Poisson Sampling.
  89654. */
  89655. get usePoissonSampling(): boolean;
  89656. /**
  89657. * Sets the current filter to Poisson Sampling.
  89658. */
  89659. set usePoissonSampling(value: boolean);
  89660. /**
  89661. * Gets if the current filter is set to ESM.
  89662. */
  89663. get useExponentialShadowMap(): boolean;
  89664. /**
  89665. * Sets the current filter is to ESM.
  89666. */
  89667. set useExponentialShadowMap(value: boolean);
  89668. /**
  89669. * Gets if the current filter is set to filtered ESM.
  89670. */
  89671. get useBlurExponentialShadowMap(): boolean;
  89672. /**
  89673. * Gets if the current filter is set to filtered ESM.
  89674. */
  89675. set useBlurExponentialShadowMap(value: boolean);
  89676. /**
  89677. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89678. * exponential to prevent steep falloff artifacts).
  89679. */
  89680. get useCloseExponentialShadowMap(): boolean;
  89681. /**
  89682. * Sets the current filter to "close ESM" (using the inverse of the
  89683. * exponential to prevent steep falloff artifacts).
  89684. */
  89685. set useCloseExponentialShadowMap(value: boolean);
  89686. /**
  89687. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89688. * exponential to prevent steep falloff artifacts).
  89689. */
  89690. get useBlurCloseExponentialShadowMap(): boolean;
  89691. /**
  89692. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89693. * exponential to prevent steep falloff artifacts).
  89694. */
  89695. set useBlurCloseExponentialShadowMap(value: boolean);
  89696. /**
  89697. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89698. */
  89699. get usePercentageCloserFiltering(): boolean;
  89700. /**
  89701. * Sets the current filter to "PCF" (percentage closer filtering).
  89702. */
  89703. set usePercentageCloserFiltering(value: boolean);
  89704. protected _filteringQuality: number;
  89705. /**
  89706. * Gets the PCF or PCSS Quality.
  89707. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89708. */
  89709. get filteringQuality(): number;
  89710. /**
  89711. * Sets the PCF or PCSS Quality.
  89712. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89713. */
  89714. set filteringQuality(filteringQuality: number);
  89715. /**
  89716. * Gets if the current filter is set to "PCSS" (contact hardening).
  89717. */
  89718. get useContactHardeningShadow(): boolean;
  89719. /**
  89720. * Sets the current filter to "PCSS" (contact hardening).
  89721. */
  89722. set useContactHardeningShadow(value: boolean);
  89723. protected _contactHardeningLightSizeUVRatio: number;
  89724. /**
  89725. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89726. * Using a ratio helps keeping shape stability independently of the map size.
  89727. *
  89728. * It does not account for the light projection as it was having too much
  89729. * instability during the light setup or during light position changes.
  89730. *
  89731. * Only valid if useContactHardeningShadow is true.
  89732. */
  89733. get contactHardeningLightSizeUVRatio(): number;
  89734. /**
  89735. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89736. * Using a ratio helps keeping shape stability independently of the map size.
  89737. *
  89738. * It does not account for the light projection as it was having too much
  89739. * instability during the light setup or during light position changes.
  89740. *
  89741. * Only valid if useContactHardeningShadow is true.
  89742. */
  89743. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89744. protected _darkness: number;
  89745. /** Gets or sets the actual darkness of a shadow */
  89746. get darkness(): number;
  89747. set darkness(value: number);
  89748. /**
  89749. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89750. * 0 means strongest and 1 would means no shadow.
  89751. * @returns the darkness.
  89752. */
  89753. getDarkness(): number;
  89754. /**
  89755. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89756. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89757. * @returns the shadow generator allowing fluent coding.
  89758. */
  89759. setDarkness(darkness: number): ShadowGenerator;
  89760. protected _transparencyShadow: boolean;
  89761. /** Gets or sets the ability to have transparent shadow */
  89762. get transparencyShadow(): boolean;
  89763. set transparencyShadow(value: boolean);
  89764. /**
  89765. * Sets the ability to have transparent shadow (boolean).
  89766. * @param transparent True if transparent else False
  89767. * @returns the shadow generator allowing fluent coding
  89768. */
  89769. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89770. protected _shadowMap: Nullable<RenderTargetTexture>;
  89771. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89772. /**
  89773. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89774. * @returns The render target texture if present otherwise, null
  89775. */
  89776. getShadowMap(): Nullable<RenderTargetTexture>;
  89777. /**
  89778. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89779. * @returns The render target texture if the shadow map is present otherwise, null
  89780. */
  89781. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89782. /**
  89783. * Gets the class name of that object
  89784. * @returns "ShadowGenerator"
  89785. */
  89786. getClassName(): string;
  89787. /**
  89788. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89789. * @param mesh Mesh to add
  89790. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89791. * @returns the Shadow Generator itself
  89792. */
  89793. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89794. /**
  89795. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89796. * @param mesh Mesh to remove
  89797. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89798. * @returns the Shadow Generator itself
  89799. */
  89800. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89801. /**
  89802. * Controls the extent to which the shadows fade out at the edge of the frustum
  89803. */
  89804. frustumEdgeFalloff: number;
  89805. protected _light: IShadowLight;
  89806. /**
  89807. * Returns the associated light object.
  89808. * @returns the light generating the shadow
  89809. */
  89810. getLight(): IShadowLight;
  89811. /**
  89812. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89813. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89814. * It might on the other hand introduce peter panning.
  89815. */
  89816. forceBackFacesOnly: boolean;
  89817. protected _scene: Scene;
  89818. protected _lightDirection: Vector3;
  89819. protected _effect: Effect;
  89820. protected _viewMatrix: Matrix;
  89821. protected _projectionMatrix: Matrix;
  89822. protected _transformMatrix: Matrix;
  89823. protected _cachedPosition: Vector3;
  89824. protected _cachedDirection: Vector3;
  89825. protected _cachedDefines: string;
  89826. protected _currentRenderID: number;
  89827. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89828. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89829. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89830. protected _blurPostProcesses: PostProcess[];
  89831. protected _mapSize: number;
  89832. protected _currentFaceIndex: number;
  89833. protected _currentFaceIndexCache: number;
  89834. protected _textureType: number;
  89835. protected _defaultTextureMatrix: Matrix;
  89836. protected _storedUniqueId: Nullable<number>;
  89837. /** @hidden */
  89838. static _SceneComponentInitialization: (scene: Scene) => void;
  89839. /**
  89840. * Creates a ShadowGenerator object.
  89841. * A ShadowGenerator is the required tool to use the shadows.
  89842. * Each light casting shadows needs to use its own ShadowGenerator.
  89843. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89844. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89845. * @param light The light object generating the shadows.
  89846. * @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.
  89847. */
  89848. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89849. protected _initializeGenerator(): void;
  89850. protected _createTargetRenderTexture(): void;
  89851. protected _initializeShadowMap(): void;
  89852. protected _initializeBlurRTTAndPostProcesses(): void;
  89853. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89854. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89855. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89856. protected _applyFilterValues(): void;
  89857. /**
  89858. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89859. * @param onCompiled Callback triggered at the and of the effects compilation
  89860. * @param options Sets of optional options forcing the compilation with different modes
  89861. */
  89862. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89863. useInstances: boolean;
  89864. }>): void;
  89865. /**
  89866. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89867. * @param options Sets of optional options forcing the compilation with different modes
  89868. * @returns A promise that resolves when the compilation completes
  89869. */
  89870. forceCompilationAsync(options?: Partial<{
  89871. useInstances: boolean;
  89872. }>): Promise<void>;
  89873. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  89874. /**
  89875. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89876. * @param subMesh The submesh we want to render in the shadow map
  89877. * @param useInstances Defines wether will draw in the map using instances
  89878. * @returns true if ready otherwise, false
  89879. */
  89880. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89881. /**
  89882. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89883. * @param defines Defines of the material we want to update
  89884. * @param lightIndex Index of the light in the enabled light list of the material
  89885. */
  89886. prepareDefines(defines: any, lightIndex: number): void;
  89887. /**
  89888. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89889. * defined in the generator but impacting the effect).
  89890. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89891. * @param effect The effect we are binfing the information for
  89892. */
  89893. bindShadowLight(lightIndex: string, effect: Effect): void;
  89894. /**
  89895. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89896. * (eq to shadow prjection matrix * light transform matrix)
  89897. * @returns The transform matrix used to create the shadow map
  89898. */
  89899. getTransformMatrix(): Matrix;
  89900. /**
  89901. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89902. * Cube and 2D textures for instance.
  89903. */
  89904. recreateShadowMap(): void;
  89905. protected _disposeBlurPostProcesses(): void;
  89906. protected _disposeRTTandPostProcesses(): void;
  89907. /**
  89908. * Disposes the ShadowGenerator.
  89909. * Returns nothing.
  89910. */
  89911. dispose(): void;
  89912. /**
  89913. * Serializes the shadow generator setup to a json object.
  89914. * @returns The serialized JSON object
  89915. */
  89916. serialize(): any;
  89917. /**
  89918. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  89919. * @param parsedShadowGenerator The JSON object to parse
  89920. * @param scene The scene to create the shadow map for
  89921. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  89922. * @returns The parsed shadow generator
  89923. */
  89924. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  89925. }
  89926. }
  89927. declare module BABYLON {
  89928. /**
  89929. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89930. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89931. * 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.
  89932. */
  89933. export abstract class Light extends Node {
  89934. /**
  89935. * Falloff Default: light is falling off following the material specification:
  89936. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89937. */
  89938. static readonly FALLOFF_DEFAULT: number;
  89939. /**
  89940. * Falloff Physical: light is falling off following the inverse squared distance law.
  89941. */
  89942. static readonly FALLOFF_PHYSICAL: number;
  89943. /**
  89944. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89945. * to enhance interoperability with other engines.
  89946. */
  89947. static readonly FALLOFF_GLTF: number;
  89948. /**
  89949. * Falloff Standard: light is falling off like in the standard material
  89950. * to enhance interoperability with other materials.
  89951. */
  89952. static readonly FALLOFF_STANDARD: number;
  89953. /**
  89954. * If every light affecting the material is in this lightmapMode,
  89955. * material.lightmapTexture adds or multiplies
  89956. * (depends on material.useLightmapAsShadowmap)
  89957. * after every other light calculations.
  89958. */
  89959. static readonly LIGHTMAP_DEFAULT: number;
  89960. /**
  89961. * material.lightmapTexture as only diffuse lighting from this light
  89962. * adds only specular lighting from this light
  89963. * adds dynamic shadows
  89964. */
  89965. static readonly LIGHTMAP_SPECULAR: number;
  89966. /**
  89967. * material.lightmapTexture as only lighting
  89968. * no light calculation from this light
  89969. * only adds dynamic shadows from this light
  89970. */
  89971. static readonly LIGHTMAP_SHADOWSONLY: number;
  89972. /**
  89973. * Each light type uses the default quantity according to its type:
  89974. * point/spot lights use luminous intensity
  89975. * directional lights use illuminance
  89976. */
  89977. static readonly INTENSITYMODE_AUTOMATIC: number;
  89978. /**
  89979. * lumen (lm)
  89980. */
  89981. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89982. /**
  89983. * candela (lm/sr)
  89984. */
  89985. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89986. /**
  89987. * lux (lm/m^2)
  89988. */
  89989. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89990. /**
  89991. * nit (cd/m^2)
  89992. */
  89993. static readonly INTENSITYMODE_LUMINANCE: number;
  89994. /**
  89995. * Light type const id of the point light.
  89996. */
  89997. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89998. /**
  89999. * Light type const id of the directional light.
  90000. */
  90001. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90002. /**
  90003. * Light type const id of the spot light.
  90004. */
  90005. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90006. /**
  90007. * Light type const id of the hemispheric light.
  90008. */
  90009. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90010. /**
  90011. * Diffuse gives the basic color to an object.
  90012. */
  90013. diffuse: Color3;
  90014. /**
  90015. * Specular produces a highlight color on an object.
  90016. * Note: This is note affecting PBR materials.
  90017. */
  90018. specular: Color3;
  90019. /**
  90020. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90021. * falling off base on range or angle.
  90022. * This can be set to any values in Light.FALLOFF_x.
  90023. *
  90024. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90025. * other types of materials.
  90026. */
  90027. falloffType: number;
  90028. /**
  90029. * Strength of the light.
  90030. * Note: By default it is define in the framework own unit.
  90031. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90032. */
  90033. intensity: number;
  90034. private _range;
  90035. protected _inverseSquaredRange: number;
  90036. /**
  90037. * Defines how far from the source the light is impacting in scene units.
  90038. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90039. */
  90040. get range(): number;
  90041. /**
  90042. * Defines how far from the source the light is impacting in scene units.
  90043. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90044. */
  90045. set range(value: number);
  90046. /**
  90047. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90048. * of light.
  90049. */
  90050. private _photometricScale;
  90051. private _intensityMode;
  90052. /**
  90053. * Gets the photometric scale used to interpret the intensity.
  90054. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90055. */
  90056. get intensityMode(): number;
  90057. /**
  90058. * Sets the photometric scale used to interpret the intensity.
  90059. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90060. */
  90061. set intensityMode(value: number);
  90062. private _radius;
  90063. /**
  90064. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90065. */
  90066. get radius(): number;
  90067. /**
  90068. * sets the light radius used by PBR Materials to simulate soft area lights.
  90069. */
  90070. set radius(value: number);
  90071. private _renderPriority;
  90072. /**
  90073. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90074. * exceeding the number allowed of the materials.
  90075. */
  90076. renderPriority: number;
  90077. private _shadowEnabled;
  90078. /**
  90079. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90080. * the current shadow generator.
  90081. */
  90082. get shadowEnabled(): boolean;
  90083. /**
  90084. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90085. * the current shadow generator.
  90086. */
  90087. set shadowEnabled(value: boolean);
  90088. private _includedOnlyMeshes;
  90089. /**
  90090. * Gets the only meshes impacted by this light.
  90091. */
  90092. get includedOnlyMeshes(): AbstractMesh[];
  90093. /**
  90094. * Sets the only meshes impacted by this light.
  90095. */
  90096. set includedOnlyMeshes(value: AbstractMesh[]);
  90097. private _excludedMeshes;
  90098. /**
  90099. * Gets the meshes not impacted by this light.
  90100. */
  90101. get excludedMeshes(): AbstractMesh[];
  90102. /**
  90103. * Sets the meshes not impacted by this light.
  90104. */
  90105. set excludedMeshes(value: AbstractMesh[]);
  90106. private _excludeWithLayerMask;
  90107. /**
  90108. * Gets the layer id use to find what meshes are not impacted by the light.
  90109. * Inactive if 0
  90110. */
  90111. get excludeWithLayerMask(): number;
  90112. /**
  90113. * Sets the layer id use to find what meshes are not impacted by the light.
  90114. * Inactive if 0
  90115. */
  90116. set excludeWithLayerMask(value: number);
  90117. private _includeOnlyWithLayerMask;
  90118. /**
  90119. * Gets the layer id use to find what meshes are impacted by the light.
  90120. * Inactive if 0
  90121. */
  90122. get includeOnlyWithLayerMask(): number;
  90123. /**
  90124. * Sets the layer id use to find what meshes are impacted by the light.
  90125. * Inactive if 0
  90126. */
  90127. set includeOnlyWithLayerMask(value: number);
  90128. private _lightmapMode;
  90129. /**
  90130. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90131. */
  90132. get lightmapMode(): number;
  90133. /**
  90134. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90135. */
  90136. set lightmapMode(value: number);
  90137. /**
  90138. * Shadow generator associted to the light.
  90139. * @hidden Internal use only.
  90140. */
  90141. _shadowGenerator: Nullable<IShadowGenerator>;
  90142. /**
  90143. * @hidden Internal use only.
  90144. */
  90145. _excludedMeshesIds: string[];
  90146. /**
  90147. * @hidden Internal use only.
  90148. */
  90149. _includedOnlyMeshesIds: string[];
  90150. /**
  90151. * The current light unifom buffer.
  90152. * @hidden Internal use only.
  90153. */
  90154. _uniformBuffer: UniformBuffer;
  90155. /** @hidden */
  90156. _renderId: number;
  90157. /**
  90158. * Creates a Light object in the scene.
  90159. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90160. * @param name The firendly name of the light
  90161. * @param scene The scene the light belongs too
  90162. */
  90163. constructor(name: string, scene: Scene);
  90164. protected abstract _buildUniformLayout(): void;
  90165. /**
  90166. * Sets the passed Effect "effect" with the Light information.
  90167. * @param effect The effect to update
  90168. * @param lightIndex The index of the light in the effect to update
  90169. * @returns The light
  90170. */
  90171. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90172. /**
  90173. * Sets the passed Effect "effect" with the Light textures.
  90174. * @param effect The effect to update
  90175. * @param lightIndex The index of the light in the effect to update
  90176. * @returns The light
  90177. */
  90178. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90179. /**
  90180. * Binds the lights information from the scene to the effect for the given mesh.
  90181. * @param lightIndex Light index
  90182. * @param scene The scene where the light belongs to
  90183. * @param effect The effect we are binding the data to
  90184. * @param useSpecular Defines if specular is supported
  90185. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90186. */
  90187. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90188. /**
  90189. * Sets the passed Effect "effect" with the Light information.
  90190. * @param effect The effect to update
  90191. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90192. * @returns The light
  90193. */
  90194. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90195. /**
  90196. * Returns the string "Light".
  90197. * @returns the class name
  90198. */
  90199. getClassName(): string;
  90200. /** @hidden */
  90201. readonly _isLight: boolean;
  90202. /**
  90203. * Converts the light information to a readable string for debug purpose.
  90204. * @param fullDetails Supports for multiple levels of logging within scene loading
  90205. * @returns the human readable light info
  90206. */
  90207. toString(fullDetails?: boolean): string;
  90208. /** @hidden */
  90209. protected _syncParentEnabledState(): void;
  90210. /**
  90211. * Set the enabled state of this node.
  90212. * @param value - the new enabled state
  90213. */
  90214. setEnabled(value: boolean): void;
  90215. /**
  90216. * Returns the Light associated shadow generator if any.
  90217. * @return the associated shadow generator.
  90218. */
  90219. getShadowGenerator(): Nullable<IShadowGenerator>;
  90220. /**
  90221. * Returns a Vector3, the absolute light position in the World.
  90222. * @returns the world space position of the light
  90223. */
  90224. getAbsolutePosition(): Vector3;
  90225. /**
  90226. * Specifies if the light will affect the passed mesh.
  90227. * @param mesh The mesh to test against the light
  90228. * @return true the mesh is affected otherwise, false.
  90229. */
  90230. canAffectMesh(mesh: AbstractMesh): boolean;
  90231. /**
  90232. * Sort function to order lights for rendering.
  90233. * @param a First Light object to compare to second.
  90234. * @param b Second Light object to compare first.
  90235. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90236. */
  90237. static CompareLightsPriority(a: Light, b: Light): number;
  90238. /**
  90239. * Releases resources associated with this node.
  90240. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90241. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90242. */
  90243. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90244. /**
  90245. * Returns the light type ID (integer).
  90246. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90247. */
  90248. getTypeID(): number;
  90249. /**
  90250. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90251. * @returns the scaled intensity in intensity mode unit
  90252. */
  90253. getScaledIntensity(): number;
  90254. /**
  90255. * Returns a new Light object, named "name", from the current one.
  90256. * @param name The name of the cloned light
  90257. * @returns the new created light
  90258. */
  90259. clone(name: string): Nullable<Light>;
  90260. /**
  90261. * Serializes the current light into a Serialization object.
  90262. * @returns the serialized object.
  90263. */
  90264. serialize(): any;
  90265. /**
  90266. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90267. * This new light is named "name" and added to the passed scene.
  90268. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90269. * @param name The friendly name of the light
  90270. * @param scene The scene the new light will belong to
  90271. * @returns the constructor function
  90272. */
  90273. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90274. /**
  90275. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90276. * @param parsedLight The JSON representation of the light
  90277. * @param scene The scene to create the parsed light in
  90278. * @returns the created light after parsing
  90279. */
  90280. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90281. private _hookArrayForExcluded;
  90282. private _hookArrayForIncludedOnly;
  90283. private _resyncMeshes;
  90284. /**
  90285. * Forces the meshes to update their light related information in their rendering used effects
  90286. * @hidden Internal Use Only
  90287. */
  90288. _markMeshesAsLightDirty(): void;
  90289. /**
  90290. * Recomputes the cached photometric scale if needed.
  90291. */
  90292. private _computePhotometricScale;
  90293. /**
  90294. * Returns the Photometric Scale according to the light type and intensity mode.
  90295. */
  90296. private _getPhotometricScale;
  90297. /**
  90298. * Reorder the light in the scene according to their defined priority.
  90299. * @hidden Internal Use Only
  90300. */
  90301. _reorderLightsInScene(): void;
  90302. /**
  90303. * Prepares the list of defines specific to the light type.
  90304. * @param defines the list of defines
  90305. * @param lightIndex defines the index of the light for the effect
  90306. */
  90307. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90308. }
  90309. }
  90310. declare module BABYLON {
  90311. /**
  90312. * Interface used to define Action
  90313. */
  90314. export interface IAction {
  90315. /**
  90316. * Trigger for the action
  90317. */
  90318. trigger: number;
  90319. /** Options of the trigger */
  90320. triggerOptions: any;
  90321. /**
  90322. * Gets the trigger parameters
  90323. * @returns the trigger parameters
  90324. */
  90325. getTriggerParameter(): any;
  90326. /**
  90327. * Internal only - executes current action event
  90328. * @hidden
  90329. */
  90330. _executeCurrent(evt?: ActionEvent): void;
  90331. /**
  90332. * Serialize placeholder for child classes
  90333. * @param parent of child
  90334. * @returns the serialized object
  90335. */
  90336. serialize(parent: any): any;
  90337. /**
  90338. * Internal only
  90339. * @hidden
  90340. */
  90341. _prepare(): void;
  90342. /**
  90343. * Internal only - manager for action
  90344. * @hidden
  90345. */
  90346. _actionManager: AbstractActionManager;
  90347. /**
  90348. * Adds action to chain of actions, may be a DoNothingAction
  90349. * @param action defines the next action to execute
  90350. * @returns The action passed in
  90351. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90352. */
  90353. then(action: IAction): IAction;
  90354. }
  90355. /**
  90356. * The action to be carried out following a trigger
  90357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90358. */
  90359. export class Action implements IAction {
  90360. /** the trigger, with or without parameters, for the action */
  90361. triggerOptions: any;
  90362. /**
  90363. * Trigger for the action
  90364. */
  90365. trigger: number;
  90366. /**
  90367. * Internal only - manager for action
  90368. * @hidden
  90369. */
  90370. _actionManager: ActionManager;
  90371. private _nextActiveAction;
  90372. private _child;
  90373. private _condition?;
  90374. private _triggerParameter;
  90375. /**
  90376. * An event triggered prior to action being executed.
  90377. */
  90378. onBeforeExecuteObservable: Observable<Action>;
  90379. /**
  90380. * Creates a new Action
  90381. * @param triggerOptions the trigger, with or without parameters, for the action
  90382. * @param condition an optional determinant of action
  90383. */
  90384. constructor(
  90385. /** the trigger, with or without parameters, for the action */
  90386. triggerOptions: any, condition?: Condition);
  90387. /**
  90388. * Internal only
  90389. * @hidden
  90390. */
  90391. _prepare(): void;
  90392. /**
  90393. * Gets the trigger parameters
  90394. * @returns the trigger parameters
  90395. */
  90396. getTriggerParameter(): any;
  90397. /**
  90398. * Internal only - executes current action event
  90399. * @hidden
  90400. */
  90401. _executeCurrent(evt?: ActionEvent): void;
  90402. /**
  90403. * Execute placeholder for child classes
  90404. * @param evt optional action event
  90405. */
  90406. execute(evt?: ActionEvent): void;
  90407. /**
  90408. * Skips to next active action
  90409. */
  90410. skipToNextActiveAction(): void;
  90411. /**
  90412. * Adds action to chain of actions, may be a DoNothingAction
  90413. * @param action defines the next action to execute
  90414. * @returns The action passed in
  90415. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90416. */
  90417. then(action: Action): Action;
  90418. /**
  90419. * Internal only
  90420. * @hidden
  90421. */
  90422. _getProperty(propertyPath: string): string;
  90423. /**
  90424. * Internal only
  90425. * @hidden
  90426. */
  90427. _getEffectiveTarget(target: any, propertyPath: string): any;
  90428. /**
  90429. * Serialize placeholder for child classes
  90430. * @param parent of child
  90431. * @returns the serialized object
  90432. */
  90433. serialize(parent: any): any;
  90434. /**
  90435. * Internal only called by serialize
  90436. * @hidden
  90437. */
  90438. protected _serialize(serializedAction: any, parent?: any): any;
  90439. /**
  90440. * Internal only
  90441. * @hidden
  90442. */
  90443. static _SerializeValueAsString: (value: any) => string;
  90444. /**
  90445. * Internal only
  90446. * @hidden
  90447. */
  90448. static _GetTargetProperty: (target: Node | Scene) => {
  90449. name: string;
  90450. targetType: string;
  90451. value: string;
  90452. };
  90453. }
  90454. }
  90455. declare module BABYLON {
  90456. /**
  90457. * A Condition applied to an Action
  90458. */
  90459. export class Condition {
  90460. /**
  90461. * Internal only - manager for action
  90462. * @hidden
  90463. */
  90464. _actionManager: ActionManager;
  90465. /**
  90466. * Internal only
  90467. * @hidden
  90468. */
  90469. _evaluationId: number;
  90470. /**
  90471. * Internal only
  90472. * @hidden
  90473. */
  90474. _currentResult: boolean;
  90475. /**
  90476. * Creates a new Condition
  90477. * @param actionManager the manager of the action the condition is applied to
  90478. */
  90479. constructor(actionManager: ActionManager);
  90480. /**
  90481. * Check if the current condition is valid
  90482. * @returns a boolean
  90483. */
  90484. isValid(): boolean;
  90485. /**
  90486. * Internal only
  90487. * @hidden
  90488. */
  90489. _getProperty(propertyPath: string): string;
  90490. /**
  90491. * Internal only
  90492. * @hidden
  90493. */
  90494. _getEffectiveTarget(target: any, propertyPath: string): any;
  90495. /**
  90496. * Serialize placeholder for child classes
  90497. * @returns the serialized object
  90498. */
  90499. serialize(): any;
  90500. /**
  90501. * Internal only
  90502. * @hidden
  90503. */
  90504. protected _serialize(serializedCondition: any): any;
  90505. }
  90506. /**
  90507. * Defines specific conditional operators as extensions of Condition
  90508. */
  90509. export class ValueCondition extends Condition {
  90510. /** path to specify the property of the target the conditional operator uses */
  90511. propertyPath: string;
  90512. /** the value compared by the conditional operator against the current value of the property */
  90513. value: any;
  90514. /** the conditional operator, default ValueCondition.IsEqual */
  90515. operator: number;
  90516. /**
  90517. * Internal only
  90518. * @hidden
  90519. */
  90520. private static _IsEqual;
  90521. /**
  90522. * Internal only
  90523. * @hidden
  90524. */
  90525. private static _IsDifferent;
  90526. /**
  90527. * Internal only
  90528. * @hidden
  90529. */
  90530. private static _IsGreater;
  90531. /**
  90532. * Internal only
  90533. * @hidden
  90534. */
  90535. private static _IsLesser;
  90536. /**
  90537. * returns the number for IsEqual
  90538. */
  90539. static get IsEqual(): number;
  90540. /**
  90541. * Returns the number for IsDifferent
  90542. */
  90543. static get IsDifferent(): number;
  90544. /**
  90545. * Returns the number for IsGreater
  90546. */
  90547. static get IsGreater(): number;
  90548. /**
  90549. * Returns the number for IsLesser
  90550. */
  90551. static get IsLesser(): number;
  90552. /**
  90553. * Internal only The action manager for the condition
  90554. * @hidden
  90555. */
  90556. _actionManager: ActionManager;
  90557. /**
  90558. * Internal only
  90559. * @hidden
  90560. */
  90561. private _target;
  90562. /**
  90563. * Internal only
  90564. * @hidden
  90565. */
  90566. private _effectiveTarget;
  90567. /**
  90568. * Internal only
  90569. * @hidden
  90570. */
  90571. private _property;
  90572. /**
  90573. * Creates a new ValueCondition
  90574. * @param actionManager manager for the action the condition applies to
  90575. * @param target for the action
  90576. * @param propertyPath path to specify the property of the target the conditional operator uses
  90577. * @param value the value compared by the conditional operator against the current value of the property
  90578. * @param operator the conditional operator, default ValueCondition.IsEqual
  90579. */
  90580. constructor(actionManager: ActionManager, target: any,
  90581. /** path to specify the property of the target the conditional operator uses */
  90582. propertyPath: string,
  90583. /** the value compared by the conditional operator against the current value of the property */
  90584. value: any,
  90585. /** the conditional operator, default ValueCondition.IsEqual */
  90586. operator?: number);
  90587. /**
  90588. * Compares the given value with the property value for the specified conditional operator
  90589. * @returns the result of the comparison
  90590. */
  90591. isValid(): boolean;
  90592. /**
  90593. * Serialize the ValueCondition into a JSON compatible object
  90594. * @returns serialization object
  90595. */
  90596. serialize(): any;
  90597. /**
  90598. * Gets the name of the conditional operator for the ValueCondition
  90599. * @param operator the conditional operator
  90600. * @returns the name
  90601. */
  90602. static GetOperatorName(operator: number): string;
  90603. }
  90604. /**
  90605. * Defines a predicate condition as an extension of Condition
  90606. */
  90607. export class PredicateCondition extends Condition {
  90608. /** defines the predicate function used to validate the condition */
  90609. predicate: () => boolean;
  90610. /**
  90611. * Internal only - manager for action
  90612. * @hidden
  90613. */
  90614. _actionManager: ActionManager;
  90615. /**
  90616. * Creates a new PredicateCondition
  90617. * @param actionManager manager for the action the condition applies to
  90618. * @param predicate defines the predicate function used to validate the condition
  90619. */
  90620. constructor(actionManager: ActionManager,
  90621. /** defines the predicate function used to validate the condition */
  90622. predicate: () => boolean);
  90623. /**
  90624. * @returns the validity of the predicate condition
  90625. */
  90626. isValid(): boolean;
  90627. }
  90628. /**
  90629. * Defines a state condition as an extension of Condition
  90630. */
  90631. export class StateCondition extends Condition {
  90632. /** Value to compare with target state */
  90633. value: string;
  90634. /**
  90635. * Internal only - manager for action
  90636. * @hidden
  90637. */
  90638. _actionManager: ActionManager;
  90639. /**
  90640. * Internal only
  90641. * @hidden
  90642. */
  90643. private _target;
  90644. /**
  90645. * Creates a new StateCondition
  90646. * @param actionManager manager for the action the condition applies to
  90647. * @param target of the condition
  90648. * @param value to compare with target state
  90649. */
  90650. constructor(actionManager: ActionManager, target: any,
  90651. /** Value to compare with target state */
  90652. value: string);
  90653. /**
  90654. * Gets a boolean indicating if the current condition is met
  90655. * @returns the validity of the state
  90656. */
  90657. isValid(): boolean;
  90658. /**
  90659. * Serialize the StateCondition into a JSON compatible object
  90660. * @returns serialization object
  90661. */
  90662. serialize(): any;
  90663. }
  90664. }
  90665. declare module BABYLON {
  90666. /**
  90667. * This defines an action responsible to toggle a boolean once triggered.
  90668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90669. */
  90670. export class SwitchBooleanAction extends Action {
  90671. /**
  90672. * The path to the boolean property in the target object
  90673. */
  90674. propertyPath: string;
  90675. private _target;
  90676. private _effectiveTarget;
  90677. private _property;
  90678. /**
  90679. * Instantiate the action
  90680. * @param triggerOptions defines the trigger options
  90681. * @param target defines the object containing the boolean
  90682. * @param propertyPath defines the path to the boolean property in the target object
  90683. * @param condition defines the trigger related conditions
  90684. */
  90685. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90686. /** @hidden */
  90687. _prepare(): void;
  90688. /**
  90689. * Execute the action toggle the boolean value.
  90690. */
  90691. execute(): void;
  90692. /**
  90693. * Serializes the actions and its related information.
  90694. * @param parent defines the object to serialize in
  90695. * @returns the serialized object
  90696. */
  90697. serialize(parent: any): any;
  90698. }
  90699. /**
  90700. * This defines an action responsible to set a the state field of the target
  90701. * to a desired value once triggered.
  90702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90703. */
  90704. export class SetStateAction extends Action {
  90705. /**
  90706. * The value to store in the state field.
  90707. */
  90708. value: string;
  90709. private _target;
  90710. /**
  90711. * Instantiate the action
  90712. * @param triggerOptions defines the trigger options
  90713. * @param target defines the object containing the state property
  90714. * @param value defines the value to store in the state field
  90715. * @param condition defines the trigger related conditions
  90716. */
  90717. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90718. /**
  90719. * Execute the action and store the value on the target state property.
  90720. */
  90721. execute(): void;
  90722. /**
  90723. * Serializes the actions and its related information.
  90724. * @param parent defines the object to serialize in
  90725. * @returns the serialized object
  90726. */
  90727. serialize(parent: any): any;
  90728. }
  90729. /**
  90730. * This defines an action responsible to set a property of the target
  90731. * to a desired value once triggered.
  90732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90733. */
  90734. export class SetValueAction extends Action {
  90735. /**
  90736. * The path of the property to set in the target.
  90737. */
  90738. propertyPath: string;
  90739. /**
  90740. * The value to set in the property
  90741. */
  90742. value: any;
  90743. private _target;
  90744. private _effectiveTarget;
  90745. private _property;
  90746. /**
  90747. * Instantiate the action
  90748. * @param triggerOptions defines the trigger options
  90749. * @param target defines the object containing the property
  90750. * @param propertyPath defines the path of the property to set in the target
  90751. * @param value defines the value to set in the property
  90752. * @param condition defines the trigger related conditions
  90753. */
  90754. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90755. /** @hidden */
  90756. _prepare(): void;
  90757. /**
  90758. * Execute the action and set the targetted property to the desired value.
  90759. */
  90760. execute(): void;
  90761. /**
  90762. * Serializes the actions and its related information.
  90763. * @param parent defines the object to serialize in
  90764. * @returns the serialized object
  90765. */
  90766. serialize(parent: any): any;
  90767. }
  90768. /**
  90769. * This defines an action responsible to increment the target value
  90770. * to a desired value once triggered.
  90771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90772. */
  90773. export class IncrementValueAction extends Action {
  90774. /**
  90775. * The path of the property to increment in the target.
  90776. */
  90777. propertyPath: string;
  90778. /**
  90779. * The value we should increment the property by.
  90780. */
  90781. value: any;
  90782. private _target;
  90783. private _effectiveTarget;
  90784. private _property;
  90785. /**
  90786. * Instantiate the action
  90787. * @param triggerOptions defines the trigger options
  90788. * @param target defines the object containing the property
  90789. * @param propertyPath defines the path of the property to increment in the target
  90790. * @param value defines the value value we should increment the property by
  90791. * @param condition defines the trigger related conditions
  90792. */
  90793. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90794. /** @hidden */
  90795. _prepare(): void;
  90796. /**
  90797. * Execute the action and increment the target of the value amount.
  90798. */
  90799. execute(): void;
  90800. /**
  90801. * Serializes the actions and its related information.
  90802. * @param parent defines the object to serialize in
  90803. * @returns the serialized object
  90804. */
  90805. serialize(parent: any): any;
  90806. }
  90807. /**
  90808. * This defines an action responsible to start an animation once triggered.
  90809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90810. */
  90811. export class PlayAnimationAction extends Action {
  90812. /**
  90813. * Where the animation should start (animation frame)
  90814. */
  90815. from: number;
  90816. /**
  90817. * Where the animation should stop (animation frame)
  90818. */
  90819. to: number;
  90820. /**
  90821. * Define if the animation should loop or stop after the first play.
  90822. */
  90823. loop?: boolean;
  90824. private _target;
  90825. /**
  90826. * Instantiate the action
  90827. * @param triggerOptions defines the trigger options
  90828. * @param target defines the target animation or animation name
  90829. * @param from defines from where the animation should start (animation frame)
  90830. * @param end defines where the animation should stop (animation frame)
  90831. * @param loop defines if the animation should loop or stop after the first play
  90832. * @param condition defines the trigger related conditions
  90833. */
  90834. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90835. /** @hidden */
  90836. _prepare(): void;
  90837. /**
  90838. * Execute the action and play the animation.
  90839. */
  90840. execute(): void;
  90841. /**
  90842. * Serializes the actions and its related information.
  90843. * @param parent defines the object to serialize in
  90844. * @returns the serialized object
  90845. */
  90846. serialize(parent: any): any;
  90847. }
  90848. /**
  90849. * This defines an action responsible to stop an animation once triggered.
  90850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90851. */
  90852. export class StopAnimationAction extends Action {
  90853. private _target;
  90854. /**
  90855. * Instantiate the action
  90856. * @param triggerOptions defines the trigger options
  90857. * @param target defines the target animation or animation name
  90858. * @param condition defines the trigger related conditions
  90859. */
  90860. constructor(triggerOptions: any, target: any, condition?: Condition);
  90861. /** @hidden */
  90862. _prepare(): void;
  90863. /**
  90864. * Execute the action and stop the animation.
  90865. */
  90866. execute(): void;
  90867. /**
  90868. * Serializes the actions and its related information.
  90869. * @param parent defines the object to serialize in
  90870. * @returns the serialized object
  90871. */
  90872. serialize(parent: any): any;
  90873. }
  90874. /**
  90875. * This defines an action responsible that does nothing once triggered.
  90876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90877. */
  90878. export class DoNothingAction extends Action {
  90879. /**
  90880. * Instantiate the action
  90881. * @param triggerOptions defines the trigger options
  90882. * @param condition defines the trigger related conditions
  90883. */
  90884. constructor(triggerOptions?: any, condition?: Condition);
  90885. /**
  90886. * Execute the action and do nothing.
  90887. */
  90888. execute(): void;
  90889. /**
  90890. * Serializes the actions and its related information.
  90891. * @param parent defines the object to serialize in
  90892. * @returns the serialized object
  90893. */
  90894. serialize(parent: any): any;
  90895. }
  90896. /**
  90897. * This defines an action responsible to trigger several actions once triggered.
  90898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90899. */
  90900. export class CombineAction extends Action {
  90901. /**
  90902. * The list of aggregated animations to run.
  90903. */
  90904. children: Action[];
  90905. /**
  90906. * Instantiate the action
  90907. * @param triggerOptions defines the trigger options
  90908. * @param children defines the list of aggregated animations to run
  90909. * @param condition defines the trigger related conditions
  90910. */
  90911. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90912. /** @hidden */
  90913. _prepare(): void;
  90914. /**
  90915. * Execute the action and executes all the aggregated actions.
  90916. */
  90917. execute(evt: ActionEvent): void;
  90918. /**
  90919. * Serializes the actions and its related information.
  90920. * @param parent defines the object to serialize in
  90921. * @returns the serialized object
  90922. */
  90923. serialize(parent: any): any;
  90924. }
  90925. /**
  90926. * This defines an action responsible to run code (external event) once triggered.
  90927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90928. */
  90929. export class ExecuteCodeAction extends Action {
  90930. /**
  90931. * The callback function to run.
  90932. */
  90933. func: (evt: ActionEvent) => void;
  90934. /**
  90935. * Instantiate the action
  90936. * @param triggerOptions defines the trigger options
  90937. * @param func defines the callback function to run
  90938. * @param condition defines the trigger related conditions
  90939. */
  90940. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90941. /**
  90942. * Execute the action and run the attached code.
  90943. */
  90944. execute(evt: ActionEvent): void;
  90945. }
  90946. /**
  90947. * This defines an action responsible to set the parent property of the target once triggered.
  90948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90949. */
  90950. export class SetParentAction extends Action {
  90951. private _parent;
  90952. private _target;
  90953. /**
  90954. * Instantiate the action
  90955. * @param triggerOptions defines the trigger options
  90956. * @param target defines the target containing the parent property
  90957. * @param parent defines from where the animation should start (animation frame)
  90958. * @param condition defines the trigger related conditions
  90959. */
  90960. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90961. /** @hidden */
  90962. _prepare(): void;
  90963. /**
  90964. * Execute the action and set the parent property.
  90965. */
  90966. execute(): void;
  90967. /**
  90968. * Serializes the actions and its related information.
  90969. * @param parent defines the object to serialize in
  90970. * @returns the serialized object
  90971. */
  90972. serialize(parent: any): any;
  90973. }
  90974. }
  90975. declare module BABYLON {
  90976. /**
  90977. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90978. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90980. */
  90981. export class ActionManager extends AbstractActionManager {
  90982. /**
  90983. * Nothing
  90984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90985. */
  90986. static readonly NothingTrigger: number;
  90987. /**
  90988. * On pick
  90989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90990. */
  90991. static readonly OnPickTrigger: number;
  90992. /**
  90993. * On left pick
  90994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90995. */
  90996. static readonly OnLeftPickTrigger: number;
  90997. /**
  90998. * On right pick
  90999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91000. */
  91001. static readonly OnRightPickTrigger: number;
  91002. /**
  91003. * On center pick
  91004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91005. */
  91006. static readonly OnCenterPickTrigger: number;
  91007. /**
  91008. * On pick down
  91009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91010. */
  91011. static readonly OnPickDownTrigger: number;
  91012. /**
  91013. * On double pick
  91014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91015. */
  91016. static readonly OnDoublePickTrigger: number;
  91017. /**
  91018. * On pick up
  91019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91020. */
  91021. static readonly OnPickUpTrigger: number;
  91022. /**
  91023. * On pick out.
  91024. * This trigger will only be raised if you also declared a OnPickDown
  91025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91026. */
  91027. static readonly OnPickOutTrigger: number;
  91028. /**
  91029. * On long press
  91030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91031. */
  91032. static readonly OnLongPressTrigger: number;
  91033. /**
  91034. * On pointer over
  91035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91036. */
  91037. static readonly OnPointerOverTrigger: number;
  91038. /**
  91039. * On pointer out
  91040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91041. */
  91042. static readonly OnPointerOutTrigger: number;
  91043. /**
  91044. * On every frame
  91045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91046. */
  91047. static readonly OnEveryFrameTrigger: number;
  91048. /**
  91049. * On intersection enter
  91050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91051. */
  91052. static readonly OnIntersectionEnterTrigger: number;
  91053. /**
  91054. * On intersection exit
  91055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91056. */
  91057. static readonly OnIntersectionExitTrigger: number;
  91058. /**
  91059. * On key down
  91060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91061. */
  91062. static readonly OnKeyDownTrigger: number;
  91063. /**
  91064. * On key up
  91065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91066. */
  91067. static readonly OnKeyUpTrigger: number;
  91068. private _scene;
  91069. /**
  91070. * Creates a new action manager
  91071. * @param scene defines the hosting scene
  91072. */
  91073. constructor(scene: Scene);
  91074. /**
  91075. * Releases all associated resources
  91076. */
  91077. dispose(): void;
  91078. /**
  91079. * Gets hosting scene
  91080. * @returns the hosting scene
  91081. */
  91082. getScene(): Scene;
  91083. /**
  91084. * Does this action manager handles actions of any of the given triggers
  91085. * @param triggers defines the triggers to be tested
  91086. * @return a boolean indicating whether one (or more) of the triggers is handled
  91087. */
  91088. hasSpecificTriggers(triggers: number[]): boolean;
  91089. /**
  91090. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91091. * speed.
  91092. * @param triggerA defines the trigger to be tested
  91093. * @param triggerB defines the trigger to be tested
  91094. * @return a boolean indicating whether one (or more) of the triggers is handled
  91095. */
  91096. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91097. /**
  91098. * Does this action manager handles actions of a given trigger
  91099. * @param trigger defines the trigger to be tested
  91100. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91101. * @return whether the trigger is handled
  91102. */
  91103. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91104. /**
  91105. * Does this action manager has pointer triggers
  91106. */
  91107. get hasPointerTriggers(): boolean;
  91108. /**
  91109. * Does this action manager has pick triggers
  91110. */
  91111. get hasPickTriggers(): boolean;
  91112. /**
  91113. * Registers an action to this action manager
  91114. * @param action defines the action to be registered
  91115. * @return the action amended (prepared) after registration
  91116. */
  91117. registerAction(action: IAction): Nullable<IAction>;
  91118. /**
  91119. * Unregisters an action to this action manager
  91120. * @param action defines the action to be unregistered
  91121. * @return a boolean indicating whether the action has been unregistered
  91122. */
  91123. unregisterAction(action: IAction): Boolean;
  91124. /**
  91125. * Process a specific trigger
  91126. * @param trigger defines the trigger to process
  91127. * @param evt defines the event details to be processed
  91128. */
  91129. processTrigger(trigger: number, evt?: IActionEvent): void;
  91130. /** @hidden */
  91131. _getEffectiveTarget(target: any, propertyPath: string): any;
  91132. /** @hidden */
  91133. _getProperty(propertyPath: string): string;
  91134. /**
  91135. * Serialize this manager to a JSON object
  91136. * @param name defines the property name to store this manager
  91137. * @returns a JSON representation of this manager
  91138. */
  91139. serialize(name: string): any;
  91140. /**
  91141. * Creates a new ActionManager from a JSON data
  91142. * @param parsedActions defines the JSON data to read from
  91143. * @param object defines the hosting mesh
  91144. * @param scene defines the hosting scene
  91145. */
  91146. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91147. /**
  91148. * Get a trigger name by index
  91149. * @param trigger defines the trigger index
  91150. * @returns a trigger name
  91151. */
  91152. static GetTriggerName(trigger: number): string;
  91153. }
  91154. }
  91155. declare module BABYLON {
  91156. /**
  91157. * Class used to represent a sprite
  91158. * @see http://doc.babylonjs.com/babylon101/sprites
  91159. */
  91160. export class Sprite {
  91161. /** defines the name */
  91162. name: string;
  91163. /** Gets or sets the current world position */
  91164. position: Vector3;
  91165. /** Gets or sets the main color */
  91166. color: Color4;
  91167. /** Gets or sets the width */
  91168. width: number;
  91169. /** Gets or sets the height */
  91170. height: number;
  91171. /** Gets or sets rotation angle */
  91172. angle: number;
  91173. /** Gets or sets the cell index in the sprite sheet */
  91174. cellIndex: number;
  91175. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91176. cellRef: string;
  91177. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91178. invertU: number;
  91179. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91180. invertV: number;
  91181. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91182. disposeWhenFinishedAnimating: boolean;
  91183. /** Gets the list of attached animations */
  91184. animations: Animation[];
  91185. /** Gets or sets a boolean indicating if the sprite can be picked */
  91186. isPickable: boolean;
  91187. /**
  91188. * Gets or sets the associated action manager
  91189. */
  91190. actionManager: Nullable<ActionManager>;
  91191. private _animationStarted;
  91192. private _loopAnimation;
  91193. private _fromIndex;
  91194. private _toIndex;
  91195. private _delay;
  91196. private _direction;
  91197. private _manager;
  91198. private _time;
  91199. private _onAnimationEnd;
  91200. /**
  91201. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91202. */
  91203. isVisible: boolean;
  91204. /**
  91205. * Gets or sets the sprite size
  91206. */
  91207. get size(): number;
  91208. set size(value: number);
  91209. /**
  91210. * Creates a new Sprite
  91211. * @param name defines the name
  91212. * @param manager defines the manager
  91213. */
  91214. constructor(
  91215. /** defines the name */
  91216. name: string, manager: ISpriteManager);
  91217. /**
  91218. * Starts an animation
  91219. * @param from defines the initial key
  91220. * @param to defines the end key
  91221. * @param loop defines if the animation must loop
  91222. * @param delay defines the start delay (in ms)
  91223. * @param onAnimationEnd defines a callback to call when animation ends
  91224. */
  91225. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91226. /** Stops current animation (if any) */
  91227. stopAnimation(): void;
  91228. /** @hidden */
  91229. _animate(deltaTime: number): void;
  91230. /** Release associated resources */
  91231. dispose(): void;
  91232. }
  91233. }
  91234. declare module BABYLON {
  91235. /**
  91236. * Information about the result of picking within a scene
  91237. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91238. */
  91239. export class PickingInfo {
  91240. /** @hidden */
  91241. _pickingUnavailable: boolean;
  91242. /**
  91243. * If the pick collided with an object
  91244. */
  91245. hit: boolean;
  91246. /**
  91247. * Distance away where the pick collided
  91248. */
  91249. distance: number;
  91250. /**
  91251. * The location of pick collision
  91252. */
  91253. pickedPoint: Nullable<Vector3>;
  91254. /**
  91255. * The mesh corresponding the the pick collision
  91256. */
  91257. pickedMesh: Nullable<AbstractMesh>;
  91258. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91259. bu: number;
  91260. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91261. bv: number;
  91262. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91263. faceId: number;
  91264. /** Id of the the submesh that was picked */
  91265. subMeshId: number;
  91266. /** If a sprite was picked, this will be the sprite the pick collided with */
  91267. pickedSprite: Nullable<Sprite>;
  91268. /**
  91269. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91270. */
  91271. originMesh: Nullable<AbstractMesh>;
  91272. /**
  91273. * The ray that was used to perform the picking.
  91274. */
  91275. ray: Nullable<Ray>;
  91276. /**
  91277. * Gets the normal correspodning to the face the pick collided with
  91278. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91279. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91280. * @returns The normal correspodning to the face the pick collided with
  91281. */
  91282. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91283. /**
  91284. * Gets the texture coordinates of where the pick occured
  91285. * @returns the vector containing the coordnates of the texture
  91286. */
  91287. getTextureCoordinates(): Nullable<Vector2>;
  91288. }
  91289. }
  91290. declare module BABYLON {
  91291. /**
  91292. * Gather the list of pointer event types as constants.
  91293. */
  91294. export class PointerEventTypes {
  91295. /**
  91296. * 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.
  91297. */
  91298. static readonly POINTERDOWN: number;
  91299. /**
  91300. * The pointerup event is fired when a pointer is no longer active.
  91301. */
  91302. static readonly POINTERUP: number;
  91303. /**
  91304. * The pointermove event is fired when a pointer changes coordinates.
  91305. */
  91306. static readonly POINTERMOVE: number;
  91307. /**
  91308. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91309. */
  91310. static readonly POINTERWHEEL: number;
  91311. /**
  91312. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91313. */
  91314. static readonly POINTERPICK: number;
  91315. /**
  91316. * The pointertap event is fired when a the object has been touched and released without drag.
  91317. */
  91318. static readonly POINTERTAP: number;
  91319. /**
  91320. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91321. */
  91322. static readonly POINTERDOUBLETAP: number;
  91323. }
  91324. /**
  91325. * Base class of pointer info types.
  91326. */
  91327. export class PointerInfoBase {
  91328. /**
  91329. * Defines the type of event (PointerEventTypes)
  91330. */
  91331. type: number;
  91332. /**
  91333. * Defines the related dom event
  91334. */
  91335. event: PointerEvent | MouseWheelEvent;
  91336. /**
  91337. * Instantiates the base class of pointers info.
  91338. * @param type Defines the type of event (PointerEventTypes)
  91339. * @param event Defines the related dom event
  91340. */
  91341. constructor(
  91342. /**
  91343. * Defines the type of event (PointerEventTypes)
  91344. */
  91345. type: number,
  91346. /**
  91347. * Defines the related dom event
  91348. */
  91349. event: PointerEvent | MouseWheelEvent);
  91350. }
  91351. /**
  91352. * This class is used to store pointer related info for the onPrePointerObservable event.
  91353. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91354. */
  91355. export class PointerInfoPre extends PointerInfoBase {
  91356. /**
  91357. * Ray from a pointer if availible (eg. 6dof controller)
  91358. */
  91359. ray: Nullable<Ray>;
  91360. /**
  91361. * Defines the local position of the pointer on the canvas.
  91362. */
  91363. localPosition: Vector2;
  91364. /**
  91365. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91366. */
  91367. skipOnPointerObservable: boolean;
  91368. /**
  91369. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91370. * @param type Defines the type of event (PointerEventTypes)
  91371. * @param event Defines the related dom event
  91372. * @param localX Defines the local x coordinates of the pointer when the event occured
  91373. * @param localY Defines the local y coordinates of the pointer when the event occured
  91374. */
  91375. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91376. }
  91377. /**
  91378. * This type contains all the data related to a pointer event in Babylon.js.
  91379. * 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.
  91380. */
  91381. export class PointerInfo extends PointerInfoBase {
  91382. /**
  91383. * Defines the picking info associated to the info (if any)\
  91384. */
  91385. pickInfo: Nullable<PickingInfo>;
  91386. /**
  91387. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91388. * @param type Defines the type of event (PointerEventTypes)
  91389. * @param event Defines the related dom event
  91390. * @param pickInfo Defines the picking info associated to the info (if any)\
  91391. */
  91392. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91393. /**
  91394. * Defines the picking info associated to the info (if any)\
  91395. */
  91396. pickInfo: Nullable<PickingInfo>);
  91397. }
  91398. /**
  91399. * Data relating to a touch event on the screen.
  91400. */
  91401. export interface PointerTouch {
  91402. /**
  91403. * X coordinate of touch.
  91404. */
  91405. x: number;
  91406. /**
  91407. * Y coordinate of touch.
  91408. */
  91409. y: number;
  91410. /**
  91411. * Id of touch. Unique for each finger.
  91412. */
  91413. pointerId: number;
  91414. /**
  91415. * Event type passed from DOM.
  91416. */
  91417. type: any;
  91418. }
  91419. }
  91420. declare module BABYLON {
  91421. /**
  91422. * Manage the mouse inputs to control the movement of a free camera.
  91423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91424. */
  91425. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91426. /**
  91427. * Define if touch is enabled in the mouse input
  91428. */
  91429. touchEnabled: boolean;
  91430. /**
  91431. * Defines the camera the input is attached to.
  91432. */
  91433. camera: FreeCamera;
  91434. /**
  91435. * Defines the buttons associated with the input to handle camera move.
  91436. */
  91437. buttons: number[];
  91438. /**
  91439. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91440. */
  91441. angularSensibility: number;
  91442. private _pointerInput;
  91443. private _onMouseMove;
  91444. private _observer;
  91445. private previousPosition;
  91446. /**
  91447. * Observable for when a pointer move event occurs containing the move offset
  91448. */
  91449. onPointerMovedObservable: Observable<{
  91450. offsetX: number;
  91451. offsetY: number;
  91452. }>;
  91453. /**
  91454. * @hidden
  91455. * If the camera should be rotated automatically based on pointer movement
  91456. */
  91457. _allowCameraRotation: boolean;
  91458. /**
  91459. * Manage the mouse inputs to control the movement of a free camera.
  91460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91461. * @param touchEnabled Defines if touch is enabled or not
  91462. */
  91463. constructor(
  91464. /**
  91465. * Define if touch is enabled in the mouse input
  91466. */
  91467. touchEnabled?: boolean);
  91468. /**
  91469. * Attach the input controls to a specific dom element to get the input from.
  91470. * @param element Defines the element the controls should be listened from
  91471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91472. */
  91473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91474. /**
  91475. * Called on JS contextmenu event.
  91476. * Override this method to provide functionality.
  91477. */
  91478. protected onContextMenu(evt: PointerEvent): void;
  91479. /**
  91480. * Detach the current controls from the specified dom element.
  91481. * @param element Defines the element to stop listening the inputs from
  91482. */
  91483. detachControl(element: Nullable<HTMLElement>): void;
  91484. /**
  91485. * Gets the class name of the current intput.
  91486. * @returns the class name
  91487. */
  91488. getClassName(): string;
  91489. /**
  91490. * Get the friendly name associated with the input class.
  91491. * @returns the input friendly name
  91492. */
  91493. getSimpleName(): string;
  91494. }
  91495. }
  91496. declare module BABYLON {
  91497. /**
  91498. * Manage the touch inputs to control the movement of a free camera.
  91499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91500. */
  91501. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91502. /**
  91503. * Defines the camera the input is attached to.
  91504. */
  91505. camera: FreeCamera;
  91506. /**
  91507. * Defines the touch sensibility for rotation.
  91508. * The higher the faster.
  91509. */
  91510. touchAngularSensibility: number;
  91511. /**
  91512. * Defines the touch sensibility for move.
  91513. * The higher the faster.
  91514. */
  91515. touchMoveSensibility: number;
  91516. private _offsetX;
  91517. private _offsetY;
  91518. private _pointerPressed;
  91519. private _pointerInput;
  91520. private _observer;
  91521. private _onLostFocus;
  91522. /**
  91523. * Attach the input controls to a specific dom element to get the input from.
  91524. * @param element Defines the element the controls should be listened from
  91525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91526. */
  91527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91528. /**
  91529. * Detach the current controls from the specified dom element.
  91530. * @param element Defines the element to stop listening the inputs from
  91531. */
  91532. detachControl(element: Nullable<HTMLElement>): void;
  91533. /**
  91534. * Update the current camera state depending on the inputs that have been used this frame.
  91535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91536. */
  91537. checkInputs(): void;
  91538. /**
  91539. * Gets the class name of the current intput.
  91540. * @returns the class name
  91541. */
  91542. getClassName(): string;
  91543. /**
  91544. * Get the friendly name associated with the input class.
  91545. * @returns the input friendly name
  91546. */
  91547. getSimpleName(): string;
  91548. }
  91549. }
  91550. declare module BABYLON {
  91551. /**
  91552. * Default Inputs manager for the FreeCamera.
  91553. * It groups all the default supported inputs for ease of use.
  91554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91555. */
  91556. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91557. /**
  91558. * @hidden
  91559. */
  91560. _mouseInput: Nullable<FreeCameraMouseInput>;
  91561. /**
  91562. * Instantiates a new FreeCameraInputsManager.
  91563. * @param camera Defines the camera the inputs belong to
  91564. */
  91565. constructor(camera: FreeCamera);
  91566. /**
  91567. * Add keyboard input support to the input manager.
  91568. * @returns the current input manager
  91569. */
  91570. addKeyboard(): FreeCameraInputsManager;
  91571. /**
  91572. * Add mouse input support to the input manager.
  91573. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91574. * @returns the current input manager
  91575. */
  91576. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91577. /**
  91578. * Removes the mouse input support from the manager
  91579. * @returns the current input manager
  91580. */
  91581. removeMouse(): FreeCameraInputsManager;
  91582. /**
  91583. * Add touch input support to the input manager.
  91584. * @returns the current input manager
  91585. */
  91586. addTouch(): FreeCameraInputsManager;
  91587. /**
  91588. * Remove all attached input methods from a camera
  91589. */
  91590. clear(): void;
  91591. }
  91592. }
  91593. declare module BABYLON {
  91594. /**
  91595. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91596. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91597. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91598. */
  91599. export class FreeCamera extends TargetCamera {
  91600. /**
  91601. * Define the collision ellipsoid of the camera.
  91602. * This is helpful to simulate a camera body like the player body around the camera
  91603. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91604. */
  91605. ellipsoid: Vector3;
  91606. /**
  91607. * Define an offset for the position of the ellipsoid around the camera.
  91608. * This can be helpful to determine the center of the body near the gravity center of the body
  91609. * instead of its head.
  91610. */
  91611. ellipsoidOffset: Vector3;
  91612. /**
  91613. * Enable or disable collisions of the camera with the rest of the scene objects.
  91614. */
  91615. checkCollisions: boolean;
  91616. /**
  91617. * Enable or disable gravity on the camera.
  91618. */
  91619. applyGravity: boolean;
  91620. /**
  91621. * Define the input manager associated to the camera.
  91622. */
  91623. inputs: FreeCameraInputsManager;
  91624. /**
  91625. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91626. * Higher values reduce sensitivity.
  91627. */
  91628. get angularSensibility(): number;
  91629. /**
  91630. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91631. * Higher values reduce sensitivity.
  91632. */
  91633. set angularSensibility(value: number);
  91634. /**
  91635. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91636. */
  91637. get keysUp(): number[];
  91638. set keysUp(value: number[]);
  91639. /**
  91640. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91641. */
  91642. get keysDown(): number[];
  91643. set keysDown(value: number[]);
  91644. /**
  91645. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91646. */
  91647. get keysLeft(): number[];
  91648. set keysLeft(value: number[]);
  91649. /**
  91650. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91651. */
  91652. get keysRight(): number[];
  91653. set keysRight(value: number[]);
  91654. /**
  91655. * Event raised when the camera collide with a mesh in the scene.
  91656. */
  91657. onCollide: (collidedMesh: AbstractMesh) => void;
  91658. private _collider;
  91659. private _needMoveForGravity;
  91660. private _oldPosition;
  91661. private _diffPosition;
  91662. private _newPosition;
  91663. /** @hidden */
  91664. _localDirection: Vector3;
  91665. /** @hidden */
  91666. _transformedDirection: Vector3;
  91667. /**
  91668. * Instantiates a Free Camera.
  91669. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91670. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91671. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91672. * @param name Define the name of the camera in the scene
  91673. * @param position Define the start position of the camera in the scene
  91674. * @param scene Define the scene the camera belongs to
  91675. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91676. */
  91677. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91678. /**
  91679. * Attached controls to the current camera.
  91680. * @param element Defines the element the controls should be listened from
  91681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91682. */
  91683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91684. /**
  91685. * Detach the current controls from the camera.
  91686. * The camera will stop reacting to inputs.
  91687. * @param element Defines the element to stop listening the inputs from
  91688. */
  91689. detachControl(element: HTMLElement): void;
  91690. private _collisionMask;
  91691. /**
  91692. * Define a collision mask to limit the list of object the camera can collide with
  91693. */
  91694. get collisionMask(): number;
  91695. set collisionMask(mask: number);
  91696. /** @hidden */
  91697. _collideWithWorld(displacement: Vector3): void;
  91698. private _onCollisionPositionChange;
  91699. /** @hidden */
  91700. _checkInputs(): void;
  91701. /** @hidden */
  91702. _decideIfNeedsToMove(): boolean;
  91703. /** @hidden */
  91704. _updatePosition(): void;
  91705. /**
  91706. * Destroy the camera and release the current resources hold by it.
  91707. */
  91708. dispose(): void;
  91709. /**
  91710. * Gets the current object class name.
  91711. * @return the class name
  91712. */
  91713. getClassName(): string;
  91714. }
  91715. }
  91716. declare module BABYLON {
  91717. /**
  91718. * Represents a gamepad control stick position
  91719. */
  91720. export class StickValues {
  91721. /**
  91722. * The x component of the control stick
  91723. */
  91724. x: number;
  91725. /**
  91726. * The y component of the control stick
  91727. */
  91728. y: number;
  91729. /**
  91730. * Initializes the gamepad x and y control stick values
  91731. * @param x The x component of the gamepad control stick value
  91732. * @param y The y component of the gamepad control stick value
  91733. */
  91734. constructor(
  91735. /**
  91736. * The x component of the control stick
  91737. */
  91738. x: number,
  91739. /**
  91740. * The y component of the control stick
  91741. */
  91742. y: number);
  91743. }
  91744. /**
  91745. * An interface which manages callbacks for gamepad button changes
  91746. */
  91747. export interface GamepadButtonChanges {
  91748. /**
  91749. * Called when a gamepad has been changed
  91750. */
  91751. changed: boolean;
  91752. /**
  91753. * Called when a gamepad press event has been triggered
  91754. */
  91755. pressChanged: boolean;
  91756. /**
  91757. * Called when a touch event has been triggered
  91758. */
  91759. touchChanged: boolean;
  91760. /**
  91761. * Called when a value has changed
  91762. */
  91763. valueChanged: boolean;
  91764. }
  91765. /**
  91766. * Represents a gamepad
  91767. */
  91768. export class Gamepad {
  91769. /**
  91770. * The id of the gamepad
  91771. */
  91772. id: string;
  91773. /**
  91774. * The index of the gamepad
  91775. */
  91776. index: number;
  91777. /**
  91778. * The browser gamepad
  91779. */
  91780. browserGamepad: any;
  91781. /**
  91782. * Specifies what type of gamepad this represents
  91783. */
  91784. type: number;
  91785. private _leftStick;
  91786. private _rightStick;
  91787. /** @hidden */
  91788. _isConnected: boolean;
  91789. private _leftStickAxisX;
  91790. private _leftStickAxisY;
  91791. private _rightStickAxisX;
  91792. private _rightStickAxisY;
  91793. /**
  91794. * Triggered when the left control stick has been changed
  91795. */
  91796. private _onleftstickchanged;
  91797. /**
  91798. * Triggered when the right control stick has been changed
  91799. */
  91800. private _onrightstickchanged;
  91801. /**
  91802. * Represents a gamepad controller
  91803. */
  91804. static GAMEPAD: number;
  91805. /**
  91806. * Represents a generic controller
  91807. */
  91808. static GENERIC: number;
  91809. /**
  91810. * Represents an XBox controller
  91811. */
  91812. static XBOX: number;
  91813. /**
  91814. * Represents a pose-enabled controller
  91815. */
  91816. static POSE_ENABLED: number;
  91817. /**
  91818. * Represents an Dual Shock controller
  91819. */
  91820. static DUALSHOCK: number;
  91821. /**
  91822. * Specifies whether the left control stick should be Y-inverted
  91823. */
  91824. protected _invertLeftStickY: boolean;
  91825. /**
  91826. * Specifies if the gamepad has been connected
  91827. */
  91828. get isConnected(): boolean;
  91829. /**
  91830. * Initializes the gamepad
  91831. * @param id The id of the gamepad
  91832. * @param index The index of the gamepad
  91833. * @param browserGamepad The browser gamepad
  91834. * @param leftStickX The x component of the left joystick
  91835. * @param leftStickY The y component of the left joystick
  91836. * @param rightStickX The x component of the right joystick
  91837. * @param rightStickY The y component of the right joystick
  91838. */
  91839. constructor(
  91840. /**
  91841. * The id of the gamepad
  91842. */
  91843. id: string,
  91844. /**
  91845. * The index of the gamepad
  91846. */
  91847. index: number,
  91848. /**
  91849. * The browser gamepad
  91850. */
  91851. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91852. /**
  91853. * Callback triggered when the left joystick has changed
  91854. * @param callback
  91855. */
  91856. onleftstickchanged(callback: (values: StickValues) => void): void;
  91857. /**
  91858. * Callback triggered when the right joystick has changed
  91859. * @param callback
  91860. */
  91861. onrightstickchanged(callback: (values: StickValues) => void): void;
  91862. /**
  91863. * Gets the left joystick
  91864. */
  91865. get leftStick(): StickValues;
  91866. /**
  91867. * Sets the left joystick values
  91868. */
  91869. set leftStick(newValues: StickValues);
  91870. /**
  91871. * Gets the right joystick
  91872. */
  91873. get rightStick(): StickValues;
  91874. /**
  91875. * Sets the right joystick value
  91876. */
  91877. set rightStick(newValues: StickValues);
  91878. /**
  91879. * Updates the gamepad joystick positions
  91880. */
  91881. update(): void;
  91882. /**
  91883. * Disposes the gamepad
  91884. */
  91885. dispose(): void;
  91886. }
  91887. /**
  91888. * Represents a generic gamepad
  91889. */
  91890. export class GenericPad extends Gamepad {
  91891. private _buttons;
  91892. private _onbuttondown;
  91893. private _onbuttonup;
  91894. /**
  91895. * Observable triggered when a button has been pressed
  91896. */
  91897. onButtonDownObservable: Observable<number>;
  91898. /**
  91899. * Observable triggered when a button has been released
  91900. */
  91901. onButtonUpObservable: Observable<number>;
  91902. /**
  91903. * Callback triggered when a button has been pressed
  91904. * @param callback Called when a button has been pressed
  91905. */
  91906. onbuttondown(callback: (buttonPressed: number) => void): void;
  91907. /**
  91908. * Callback triggered when a button has been released
  91909. * @param callback Called when a button has been released
  91910. */
  91911. onbuttonup(callback: (buttonReleased: number) => void): void;
  91912. /**
  91913. * Initializes the generic gamepad
  91914. * @param id The id of the generic gamepad
  91915. * @param index The index of the generic gamepad
  91916. * @param browserGamepad The browser gamepad
  91917. */
  91918. constructor(id: string, index: number, browserGamepad: any);
  91919. private _setButtonValue;
  91920. /**
  91921. * Updates the generic gamepad
  91922. */
  91923. update(): void;
  91924. /**
  91925. * Disposes the generic gamepad
  91926. */
  91927. dispose(): void;
  91928. }
  91929. }
  91930. declare module BABYLON {
  91931. /**
  91932. * Defines the types of pose enabled controllers that are supported
  91933. */
  91934. export enum PoseEnabledControllerType {
  91935. /**
  91936. * HTC Vive
  91937. */
  91938. VIVE = 0,
  91939. /**
  91940. * Oculus Rift
  91941. */
  91942. OCULUS = 1,
  91943. /**
  91944. * Windows mixed reality
  91945. */
  91946. WINDOWS = 2,
  91947. /**
  91948. * Samsung gear VR
  91949. */
  91950. GEAR_VR = 3,
  91951. /**
  91952. * Google Daydream
  91953. */
  91954. DAYDREAM = 4,
  91955. /**
  91956. * Generic
  91957. */
  91958. GENERIC = 5
  91959. }
  91960. /**
  91961. * Defines the MutableGamepadButton interface for the state of a gamepad button
  91962. */
  91963. export interface MutableGamepadButton {
  91964. /**
  91965. * Value of the button/trigger
  91966. */
  91967. value: number;
  91968. /**
  91969. * If the button/trigger is currently touched
  91970. */
  91971. touched: boolean;
  91972. /**
  91973. * If the button/trigger is currently pressed
  91974. */
  91975. pressed: boolean;
  91976. }
  91977. /**
  91978. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  91979. * @hidden
  91980. */
  91981. export interface ExtendedGamepadButton extends GamepadButton {
  91982. /**
  91983. * If the button/trigger is currently pressed
  91984. */
  91985. readonly pressed: boolean;
  91986. /**
  91987. * If the button/trigger is currently touched
  91988. */
  91989. readonly touched: boolean;
  91990. /**
  91991. * Value of the button/trigger
  91992. */
  91993. readonly value: number;
  91994. }
  91995. /** @hidden */
  91996. export interface _GamePadFactory {
  91997. /**
  91998. * Returns whether or not the current gamepad can be created for this type of controller.
  91999. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92000. * @returns true if it can be created, otherwise false
  92001. */
  92002. canCreate(gamepadInfo: any): boolean;
  92003. /**
  92004. * Creates a new instance of the Gamepad.
  92005. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92006. * @returns the new gamepad instance
  92007. */
  92008. create(gamepadInfo: any): Gamepad;
  92009. }
  92010. /**
  92011. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92012. */
  92013. export class PoseEnabledControllerHelper {
  92014. /** @hidden */
  92015. static _ControllerFactories: _GamePadFactory[];
  92016. /** @hidden */
  92017. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92018. /**
  92019. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92020. * @param vrGamepad the gamepad to initialized
  92021. * @returns a vr controller of the type the gamepad identified as
  92022. */
  92023. static InitiateController(vrGamepad: any): Gamepad;
  92024. }
  92025. /**
  92026. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92027. */
  92028. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92029. /**
  92030. * If the controller is used in a webXR session
  92031. */
  92032. isXR: boolean;
  92033. private _deviceRoomPosition;
  92034. private _deviceRoomRotationQuaternion;
  92035. /**
  92036. * The device position in babylon space
  92037. */
  92038. devicePosition: Vector3;
  92039. /**
  92040. * The device rotation in babylon space
  92041. */
  92042. deviceRotationQuaternion: Quaternion;
  92043. /**
  92044. * The scale factor of the device in babylon space
  92045. */
  92046. deviceScaleFactor: number;
  92047. /**
  92048. * (Likely devicePosition should be used instead) The device position in its room space
  92049. */
  92050. position: Vector3;
  92051. /**
  92052. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92053. */
  92054. rotationQuaternion: Quaternion;
  92055. /**
  92056. * The type of controller (Eg. Windows mixed reality)
  92057. */
  92058. controllerType: PoseEnabledControllerType;
  92059. protected _calculatedPosition: Vector3;
  92060. private _calculatedRotation;
  92061. /**
  92062. * The raw pose from the device
  92063. */
  92064. rawPose: DevicePose;
  92065. private _trackPosition;
  92066. private _maxRotationDistFromHeadset;
  92067. private _draggedRoomRotation;
  92068. /**
  92069. * @hidden
  92070. */
  92071. _disableTrackPosition(fixedPosition: Vector3): void;
  92072. /**
  92073. * Internal, the mesh attached to the controller
  92074. * @hidden
  92075. */
  92076. _mesh: Nullable<AbstractMesh>;
  92077. private _poseControlledCamera;
  92078. private _leftHandSystemQuaternion;
  92079. /**
  92080. * Internal, matrix used to convert room space to babylon space
  92081. * @hidden
  92082. */
  92083. _deviceToWorld: Matrix;
  92084. /**
  92085. * Node to be used when casting a ray from the controller
  92086. * @hidden
  92087. */
  92088. _pointingPoseNode: Nullable<TransformNode>;
  92089. /**
  92090. * Name of the child mesh that can be used to cast a ray from the controller
  92091. */
  92092. static readonly POINTING_POSE: string;
  92093. /**
  92094. * Creates a new PoseEnabledController from a gamepad
  92095. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92096. */
  92097. constructor(browserGamepad: any);
  92098. private _workingMatrix;
  92099. /**
  92100. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92101. */
  92102. update(): void;
  92103. /**
  92104. * Updates only the pose device and mesh without doing any button event checking
  92105. */
  92106. protected _updatePoseAndMesh(): void;
  92107. /**
  92108. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92109. * @param poseData raw pose fromthe device
  92110. */
  92111. updateFromDevice(poseData: DevicePose): void;
  92112. /**
  92113. * @hidden
  92114. */
  92115. _meshAttachedObservable: Observable<AbstractMesh>;
  92116. /**
  92117. * Attaches a mesh to the controller
  92118. * @param mesh the mesh to be attached
  92119. */
  92120. attachToMesh(mesh: AbstractMesh): void;
  92121. /**
  92122. * Attaches the controllers mesh to a camera
  92123. * @param camera the camera the mesh should be attached to
  92124. */
  92125. attachToPoseControlledCamera(camera: TargetCamera): void;
  92126. /**
  92127. * Disposes of the controller
  92128. */
  92129. dispose(): void;
  92130. /**
  92131. * The mesh that is attached to the controller
  92132. */
  92133. get mesh(): Nullable<AbstractMesh>;
  92134. /**
  92135. * Gets the ray of the controller in the direction the controller is pointing
  92136. * @param length the length the resulting ray should be
  92137. * @returns a ray in the direction the controller is pointing
  92138. */
  92139. getForwardRay(length?: number): Ray;
  92140. }
  92141. }
  92142. declare module BABYLON {
  92143. /**
  92144. * Defines the WebVRController object that represents controllers tracked in 3D space
  92145. */
  92146. export abstract class WebVRController extends PoseEnabledController {
  92147. /**
  92148. * Internal, the default controller model for the controller
  92149. */
  92150. protected _defaultModel: Nullable<AbstractMesh>;
  92151. /**
  92152. * Fired when the trigger state has changed
  92153. */
  92154. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92155. /**
  92156. * Fired when the main button state has changed
  92157. */
  92158. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92159. /**
  92160. * Fired when the secondary button state has changed
  92161. */
  92162. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92163. /**
  92164. * Fired when the pad state has changed
  92165. */
  92166. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92167. /**
  92168. * Fired when controllers stick values have changed
  92169. */
  92170. onPadValuesChangedObservable: Observable<StickValues>;
  92171. /**
  92172. * Array of button availible on the controller
  92173. */
  92174. protected _buttons: Array<MutableGamepadButton>;
  92175. private _onButtonStateChange;
  92176. /**
  92177. * Fired when a controller button's state has changed
  92178. * @param callback the callback containing the button that was modified
  92179. */
  92180. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92181. /**
  92182. * X and Y axis corresponding to the controllers joystick
  92183. */
  92184. pad: StickValues;
  92185. /**
  92186. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92187. */
  92188. hand: string;
  92189. /**
  92190. * The default controller model for the controller
  92191. */
  92192. get defaultModel(): Nullable<AbstractMesh>;
  92193. /**
  92194. * Creates a new WebVRController from a gamepad
  92195. * @param vrGamepad the gamepad that the WebVRController should be created from
  92196. */
  92197. constructor(vrGamepad: any);
  92198. /**
  92199. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92200. */
  92201. update(): void;
  92202. /**
  92203. * Function to be called when a button is modified
  92204. */
  92205. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92206. /**
  92207. * Loads a mesh and attaches it to the controller
  92208. * @param scene the scene the mesh should be added to
  92209. * @param meshLoaded callback for when the mesh has been loaded
  92210. */
  92211. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92212. private _setButtonValue;
  92213. private _changes;
  92214. private _checkChanges;
  92215. /**
  92216. * Disposes of th webVRCOntroller
  92217. */
  92218. dispose(): void;
  92219. }
  92220. }
  92221. declare module BABYLON {
  92222. /**
  92223. * The HemisphericLight simulates the ambient environment light,
  92224. * so the passed direction is the light reflection direction, not the incoming direction.
  92225. */
  92226. export class HemisphericLight extends Light {
  92227. /**
  92228. * The groundColor is the light in the opposite direction to the one specified during creation.
  92229. * 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.
  92230. */
  92231. groundColor: Color3;
  92232. /**
  92233. * The light reflection direction, not the incoming direction.
  92234. */
  92235. direction: Vector3;
  92236. /**
  92237. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92238. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92239. * The HemisphericLight can't cast shadows.
  92240. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92241. * @param name The friendly name of the light
  92242. * @param direction The direction of the light reflection
  92243. * @param scene The scene the light belongs to
  92244. */
  92245. constructor(name: string, direction: Vector3, scene: Scene);
  92246. protected _buildUniformLayout(): void;
  92247. /**
  92248. * Returns the string "HemisphericLight".
  92249. * @return The class name
  92250. */
  92251. getClassName(): string;
  92252. /**
  92253. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92254. * Returns the updated direction.
  92255. * @param target The target the direction should point to
  92256. * @return The computed direction
  92257. */
  92258. setDirectionToTarget(target: Vector3): Vector3;
  92259. /**
  92260. * Returns the shadow generator associated to the light.
  92261. * @returns Always null for hemispheric lights because it does not support shadows.
  92262. */
  92263. getShadowGenerator(): Nullable<IShadowGenerator>;
  92264. /**
  92265. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92266. * @param effect The effect to update
  92267. * @param lightIndex The index of the light in the effect to update
  92268. * @returns The hemispheric light
  92269. */
  92270. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92271. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92272. /**
  92273. * Computes the world matrix of the node
  92274. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92275. * @param useWasUpdatedFlag defines a reserved property
  92276. * @returns the world matrix
  92277. */
  92278. computeWorldMatrix(): Matrix;
  92279. /**
  92280. * Returns the integer 3.
  92281. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92282. */
  92283. getTypeID(): number;
  92284. /**
  92285. * Prepares the list of defines specific to the light type.
  92286. * @param defines the list of defines
  92287. * @param lightIndex defines the index of the light for the effect
  92288. */
  92289. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92290. }
  92291. }
  92292. declare module BABYLON {
  92293. /** @hidden */
  92294. export var vrMultiviewToSingleviewPixelShader: {
  92295. name: string;
  92296. shader: string;
  92297. };
  92298. }
  92299. declare module BABYLON {
  92300. /**
  92301. * Renders to multiple views with a single draw call
  92302. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92303. */
  92304. export class MultiviewRenderTarget extends RenderTargetTexture {
  92305. /**
  92306. * Creates a multiview render target
  92307. * @param scene scene used with the render target
  92308. * @param size the size of the render target (used for each view)
  92309. */
  92310. constructor(scene: Scene, size?: number | {
  92311. width: number;
  92312. height: number;
  92313. } | {
  92314. ratio: number;
  92315. });
  92316. /**
  92317. * @hidden
  92318. * @param faceIndex the face index, if its a cube texture
  92319. */
  92320. _bindFrameBuffer(faceIndex?: number): void;
  92321. /**
  92322. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92323. * @returns the view count
  92324. */
  92325. getViewCount(): number;
  92326. }
  92327. }
  92328. declare module BABYLON {
  92329. /**
  92330. * Represents a camera frustum
  92331. */
  92332. export class Frustum {
  92333. /**
  92334. * Gets the planes representing the frustum
  92335. * @param transform matrix to be applied to the returned planes
  92336. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92337. */
  92338. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92339. /**
  92340. * Gets the near frustum plane transformed by the transform matrix
  92341. * @param transform transformation matrix to be applied to the resulting frustum plane
  92342. * @param frustumPlane the resuling frustum plane
  92343. */
  92344. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92345. /**
  92346. * Gets the far frustum plane transformed by the transform matrix
  92347. * @param transform transformation matrix to be applied to the resulting frustum plane
  92348. * @param frustumPlane the resuling frustum plane
  92349. */
  92350. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92351. /**
  92352. * Gets the left frustum plane transformed by the transform matrix
  92353. * @param transform transformation matrix to be applied to the resulting frustum plane
  92354. * @param frustumPlane the resuling frustum plane
  92355. */
  92356. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92357. /**
  92358. * Gets the right frustum plane transformed by the transform matrix
  92359. * @param transform transformation matrix to be applied to the resulting frustum plane
  92360. * @param frustumPlane the resuling frustum plane
  92361. */
  92362. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92363. /**
  92364. * Gets the top frustum plane transformed by the transform matrix
  92365. * @param transform transformation matrix to be applied to the resulting frustum plane
  92366. * @param frustumPlane the resuling frustum plane
  92367. */
  92368. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92369. /**
  92370. * Gets the bottom frustum plane transformed by the transform matrix
  92371. * @param transform transformation matrix to be applied to the resulting frustum plane
  92372. * @param frustumPlane the resuling frustum plane
  92373. */
  92374. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92375. /**
  92376. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92377. * @param transform transformation matrix to be applied to the resulting frustum planes
  92378. * @param frustumPlanes the resuling frustum planes
  92379. */
  92380. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92381. }
  92382. }
  92383. declare module BABYLON {
  92384. interface Engine {
  92385. /**
  92386. * Creates a new multiview render target
  92387. * @param width defines the width of the texture
  92388. * @param height defines the height of the texture
  92389. * @returns the created multiview texture
  92390. */
  92391. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92392. /**
  92393. * Binds a multiview framebuffer to be drawn to
  92394. * @param multiviewTexture texture to bind
  92395. */
  92396. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92397. }
  92398. interface Camera {
  92399. /**
  92400. * @hidden
  92401. * 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)
  92402. */
  92403. _useMultiviewToSingleView: boolean;
  92404. /**
  92405. * @hidden
  92406. * 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)
  92407. */
  92408. _multiviewTexture: Nullable<RenderTargetTexture>;
  92409. /**
  92410. * @hidden
  92411. * ensures the multiview texture of the camera exists and has the specified width/height
  92412. * @param width height to set on the multiview texture
  92413. * @param height width to set on the multiview texture
  92414. */
  92415. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92416. }
  92417. interface Scene {
  92418. /** @hidden */
  92419. _transformMatrixR: Matrix;
  92420. /** @hidden */
  92421. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92422. /** @hidden */
  92423. _createMultiviewUbo(): void;
  92424. /** @hidden */
  92425. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92426. /** @hidden */
  92427. _renderMultiviewToSingleView(camera: Camera): void;
  92428. }
  92429. }
  92430. declare module BABYLON {
  92431. /**
  92432. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92433. * This will not be used for webXR as it supports displaying texture arrays directly
  92434. */
  92435. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92436. /**
  92437. * Initializes a VRMultiviewToSingleview
  92438. * @param name name of the post process
  92439. * @param camera camera to be applied to
  92440. * @param scaleFactor scaling factor to the size of the output texture
  92441. */
  92442. constructor(name: string, camera: Camera, scaleFactor: number);
  92443. }
  92444. }
  92445. declare module BABYLON {
  92446. /**
  92447. * Interface used to define additional presentation attributes
  92448. */
  92449. export interface IVRPresentationAttributes {
  92450. /**
  92451. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92452. */
  92453. highRefreshRate: boolean;
  92454. /**
  92455. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92456. */
  92457. foveationLevel: number;
  92458. }
  92459. interface Engine {
  92460. /** @hidden */
  92461. _vrDisplay: any;
  92462. /** @hidden */
  92463. _vrSupported: boolean;
  92464. /** @hidden */
  92465. _oldSize: Size;
  92466. /** @hidden */
  92467. _oldHardwareScaleFactor: number;
  92468. /** @hidden */
  92469. _vrExclusivePointerMode: boolean;
  92470. /** @hidden */
  92471. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92472. /** @hidden */
  92473. _onVRDisplayPointerRestricted: () => void;
  92474. /** @hidden */
  92475. _onVRDisplayPointerUnrestricted: () => void;
  92476. /** @hidden */
  92477. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92478. /** @hidden */
  92479. _onVrDisplayDisconnect: Nullable<() => void>;
  92480. /** @hidden */
  92481. _onVrDisplayPresentChange: Nullable<() => void>;
  92482. /**
  92483. * Observable signaled when VR display mode changes
  92484. */
  92485. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92486. /**
  92487. * Observable signaled when VR request present is complete
  92488. */
  92489. onVRRequestPresentComplete: Observable<boolean>;
  92490. /**
  92491. * Observable signaled when VR request present starts
  92492. */
  92493. onVRRequestPresentStart: Observable<Engine>;
  92494. /**
  92495. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92496. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92497. */
  92498. isInVRExclusivePointerMode: boolean;
  92499. /**
  92500. * Gets a boolean indicating if a webVR device was detected
  92501. * @returns true if a webVR device was detected
  92502. */
  92503. isVRDevicePresent(): boolean;
  92504. /**
  92505. * Gets the current webVR device
  92506. * @returns the current webVR device (or null)
  92507. */
  92508. getVRDevice(): any;
  92509. /**
  92510. * Initializes a webVR display and starts listening to display change events
  92511. * The onVRDisplayChangedObservable will be notified upon these changes
  92512. * @returns A promise containing a VRDisplay and if vr is supported
  92513. */
  92514. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92515. /** @hidden */
  92516. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92517. /**
  92518. * Gets or sets the presentation attributes used to configure VR rendering
  92519. */
  92520. vrPresentationAttributes?: IVRPresentationAttributes;
  92521. /**
  92522. * Call this function to switch to webVR mode
  92523. * Will do nothing if webVR is not supported or if there is no webVR device
  92524. * @param options the webvr options provided to the camera. mainly used for multiview
  92525. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92526. */
  92527. enableVR(options: WebVROptions): void;
  92528. /** @hidden */
  92529. _onVRFullScreenTriggered(): void;
  92530. }
  92531. }
  92532. declare module BABYLON {
  92533. /**
  92534. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92535. * IMPORTANT!! The data is right-hand data.
  92536. * @export
  92537. * @interface DevicePose
  92538. */
  92539. export interface DevicePose {
  92540. /**
  92541. * The position of the device, values in array are [x,y,z].
  92542. */
  92543. readonly position: Nullable<Float32Array>;
  92544. /**
  92545. * The linearVelocity of the device, values in array are [x,y,z].
  92546. */
  92547. readonly linearVelocity: Nullable<Float32Array>;
  92548. /**
  92549. * The linearAcceleration of the device, values in array are [x,y,z].
  92550. */
  92551. readonly linearAcceleration: Nullable<Float32Array>;
  92552. /**
  92553. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92554. */
  92555. readonly orientation: Nullable<Float32Array>;
  92556. /**
  92557. * The angularVelocity of the device, values in array are [x,y,z].
  92558. */
  92559. readonly angularVelocity: Nullable<Float32Array>;
  92560. /**
  92561. * The angularAcceleration of the device, values in array are [x,y,z].
  92562. */
  92563. readonly angularAcceleration: Nullable<Float32Array>;
  92564. }
  92565. /**
  92566. * Interface representing a pose controlled object in Babylon.
  92567. * A pose controlled object has both regular pose values as well as pose values
  92568. * from an external device such as a VR head mounted display
  92569. */
  92570. export interface PoseControlled {
  92571. /**
  92572. * The position of the object in babylon space.
  92573. */
  92574. position: Vector3;
  92575. /**
  92576. * The rotation quaternion of the object in babylon space.
  92577. */
  92578. rotationQuaternion: Quaternion;
  92579. /**
  92580. * The position of the device in babylon space.
  92581. */
  92582. devicePosition?: Vector3;
  92583. /**
  92584. * The rotation quaternion of the device in babylon space.
  92585. */
  92586. deviceRotationQuaternion: Quaternion;
  92587. /**
  92588. * The raw pose coming from the device.
  92589. */
  92590. rawPose: Nullable<DevicePose>;
  92591. /**
  92592. * The scale of the device to be used when translating from device space to babylon space.
  92593. */
  92594. deviceScaleFactor: number;
  92595. /**
  92596. * Updates the poseControlled values based on the input device pose.
  92597. * @param poseData the pose data to update the object with
  92598. */
  92599. updateFromDevice(poseData: DevicePose): void;
  92600. }
  92601. /**
  92602. * Set of options to customize the webVRCamera
  92603. */
  92604. export interface WebVROptions {
  92605. /**
  92606. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92607. */
  92608. trackPosition?: boolean;
  92609. /**
  92610. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92611. */
  92612. positionScale?: number;
  92613. /**
  92614. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92615. */
  92616. displayName?: string;
  92617. /**
  92618. * Should the native controller meshes be initialized. (default: true)
  92619. */
  92620. controllerMeshes?: boolean;
  92621. /**
  92622. * Creating a default HemiLight only on controllers. (default: true)
  92623. */
  92624. defaultLightingOnControllers?: boolean;
  92625. /**
  92626. * If you don't want to use the default VR button of the helper. (default: false)
  92627. */
  92628. useCustomVRButton?: boolean;
  92629. /**
  92630. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92631. */
  92632. customVRButton?: HTMLButtonElement;
  92633. /**
  92634. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92635. */
  92636. rayLength?: number;
  92637. /**
  92638. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92639. */
  92640. defaultHeight?: number;
  92641. /**
  92642. * If multiview should be used if availible (default: false)
  92643. */
  92644. useMultiview?: boolean;
  92645. }
  92646. /**
  92647. * This represents a WebVR camera.
  92648. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92649. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92650. */
  92651. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92652. private webVROptions;
  92653. /**
  92654. * @hidden
  92655. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92656. */
  92657. _vrDevice: any;
  92658. /**
  92659. * The rawPose of the vrDevice.
  92660. */
  92661. rawPose: Nullable<DevicePose>;
  92662. private _onVREnabled;
  92663. private _specsVersion;
  92664. private _attached;
  92665. private _frameData;
  92666. protected _descendants: Array<Node>;
  92667. private _deviceRoomPosition;
  92668. /** @hidden */
  92669. _deviceRoomRotationQuaternion: Quaternion;
  92670. private _standingMatrix;
  92671. /**
  92672. * Represents device position in babylon space.
  92673. */
  92674. devicePosition: Vector3;
  92675. /**
  92676. * Represents device rotation in babylon space.
  92677. */
  92678. deviceRotationQuaternion: Quaternion;
  92679. /**
  92680. * The scale of the device to be used when translating from device space to babylon space.
  92681. */
  92682. deviceScaleFactor: number;
  92683. private _deviceToWorld;
  92684. private _worldToDevice;
  92685. /**
  92686. * References to the webVR controllers for the vrDevice.
  92687. */
  92688. controllers: Array<WebVRController>;
  92689. /**
  92690. * Emits an event when a controller is attached.
  92691. */
  92692. onControllersAttachedObservable: Observable<WebVRController[]>;
  92693. /**
  92694. * Emits an event when a controller's mesh has been loaded;
  92695. */
  92696. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92697. /**
  92698. * Emits an event when the HMD's pose has been updated.
  92699. */
  92700. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92701. private _poseSet;
  92702. /**
  92703. * If the rig cameras be used as parent instead of this camera.
  92704. */
  92705. rigParenting: boolean;
  92706. private _lightOnControllers;
  92707. private _defaultHeight?;
  92708. /**
  92709. * Instantiates a WebVRFreeCamera.
  92710. * @param name The name of the WebVRFreeCamera
  92711. * @param position The starting anchor position for the camera
  92712. * @param scene The scene the camera belongs to
  92713. * @param webVROptions a set of customizable options for the webVRCamera
  92714. */
  92715. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92716. /**
  92717. * Gets the device distance from the ground in meters.
  92718. * @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.
  92719. */
  92720. deviceDistanceToRoomGround(): number;
  92721. /**
  92722. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92723. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92724. */
  92725. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92726. /**
  92727. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92728. * @returns A promise with a boolean set to if the standing matrix is supported.
  92729. */
  92730. useStandingMatrixAsync(): Promise<boolean>;
  92731. /**
  92732. * Disposes the camera
  92733. */
  92734. dispose(): void;
  92735. /**
  92736. * Gets a vrController by name.
  92737. * @param name The name of the controller to retreive
  92738. * @returns the controller matching the name specified or null if not found
  92739. */
  92740. getControllerByName(name: string): Nullable<WebVRController>;
  92741. private _leftController;
  92742. /**
  92743. * The controller corresponding to the users left hand.
  92744. */
  92745. get leftController(): Nullable<WebVRController>;
  92746. private _rightController;
  92747. /**
  92748. * The controller corresponding to the users right hand.
  92749. */
  92750. get rightController(): Nullable<WebVRController>;
  92751. /**
  92752. * Casts a ray forward from the vrCamera's gaze.
  92753. * @param length Length of the ray (default: 100)
  92754. * @returns the ray corresponding to the gaze
  92755. */
  92756. getForwardRay(length?: number): Ray;
  92757. /**
  92758. * @hidden
  92759. * Updates the camera based on device's frame data
  92760. */
  92761. _checkInputs(): void;
  92762. /**
  92763. * Updates the poseControlled values based on the input device pose.
  92764. * @param poseData Pose coming from the device
  92765. */
  92766. updateFromDevice(poseData: DevicePose): void;
  92767. private _htmlElementAttached;
  92768. private _detachIfAttached;
  92769. /**
  92770. * WebVR's attach control will start broadcasting frames to the device.
  92771. * Note that in certain browsers (chrome for example) this function must be called
  92772. * within a user-interaction callback. Example:
  92773. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92774. *
  92775. * @param element html element to attach the vrDevice to
  92776. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92777. */
  92778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92779. /**
  92780. * Detaches the camera from the html element and disables VR
  92781. *
  92782. * @param element html element to detach from
  92783. */
  92784. detachControl(element: HTMLElement): void;
  92785. /**
  92786. * @returns the name of this class
  92787. */
  92788. getClassName(): string;
  92789. /**
  92790. * Calls resetPose on the vrDisplay
  92791. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92792. */
  92793. resetToCurrentRotation(): void;
  92794. /**
  92795. * @hidden
  92796. * Updates the rig cameras (left and right eye)
  92797. */
  92798. _updateRigCameras(): void;
  92799. private _workingVector;
  92800. private _oneVector;
  92801. private _workingMatrix;
  92802. private updateCacheCalled;
  92803. private _correctPositionIfNotTrackPosition;
  92804. /**
  92805. * @hidden
  92806. * Updates the cached values of the camera
  92807. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92808. */
  92809. _updateCache(ignoreParentClass?: boolean): void;
  92810. /**
  92811. * @hidden
  92812. * Get current device position in babylon world
  92813. */
  92814. _computeDevicePosition(): void;
  92815. /**
  92816. * Updates the current device position and rotation in the babylon world
  92817. */
  92818. update(): void;
  92819. /**
  92820. * @hidden
  92821. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92822. * @returns an identity matrix
  92823. */
  92824. _getViewMatrix(): Matrix;
  92825. private _tmpMatrix;
  92826. /**
  92827. * This function is called by the two RIG cameras.
  92828. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92829. * @hidden
  92830. */
  92831. _getWebVRViewMatrix(): Matrix;
  92832. /** @hidden */
  92833. _getWebVRProjectionMatrix(): Matrix;
  92834. private _onGamepadConnectedObserver;
  92835. private _onGamepadDisconnectedObserver;
  92836. private _updateCacheWhenTrackingDisabledObserver;
  92837. /**
  92838. * Initializes the controllers and their meshes
  92839. */
  92840. initControllers(): void;
  92841. }
  92842. }
  92843. declare module BABYLON {
  92844. /**
  92845. * Size options for a post process
  92846. */
  92847. export type PostProcessOptions = {
  92848. width: number;
  92849. height: number;
  92850. };
  92851. /**
  92852. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92853. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92854. */
  92855. export class PostProcess {
  92856. /** Name of the PostProcess. */
  92857. name: string;
  92858. /**
  92859. * Gets or sets the unique id of the post process
  92860. */
  92861. uniqueId: number;
  92862. /**
  92863. * Width of the texture to apply the post process on
  92864. */
  92865. width: number;
  92866. /**
  92867. * Height of the texture to apply the post process on
  92868. */
  92869. height: number;
  92870. /**
  92871. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  92872. * @hidden
  92873. */
  92874. _outputTexture: Nullable<InternalTexture>;
  92875. /**
  92876. * Sampling mode used by the shader
  92877. * See https://doc.babylonjs.com/classes/3.1/texture
  92878. */
  92879. renderTargetSamplingMode: number;
  92880. /**
  92881. * Clear color to use when screen clearing
  92882. */
  92883. clearColor: Color4;
  92884. /**
  92885. * If the buffer needs to be cleared before applying the post process. (default: true)
  92886. * Should be set to false if shader will overwrite all previous pixels.
  92887. */
  92888. autoClear: boolean;
  92889. /**
  92890. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  92891. */
  92892. alphaMode: number;
  92893. /**
  92894. * Sets the setAlphaBlendConstants of the babylon engine
  92895. */
  92896. alphaConstants: Color4;
  92897. /**
  92898. * Animations to be used for the post processing
  92899. */
  92900. animations: Animation[];
  92901. /**
  92902. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  92903. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  92904. */
  92905. enablePixelPerfectMode: boolean;
  92906. /**
  92907. * Force the postprocess to be applied without taking in account viewport
  92908. */
  92909. forceFullscreenViewport: boolean;
  92910. /**
  92911. * List of inspectable custom properties (used by the Inspector)
  92912. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92913. */
  92914. inspectableCustomProperties: IInspectable[];
  92915. /**
  92916. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  92917. *
  92918. * | Value | Type | Description |
  92919. * | ----- | ----------------------------------- | ----------- |
  92920. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  92921. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  92922. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  92923. *
  92924. */
  92925. scaleMode: number;
  92926. /**
  92927. * Force textures to be a power of two (default: false)
  92928. */
  92929. alwaysForcePOT: boolean;
  92930. private _samples;
  92931. /**
  92932. * Number of sample textures (default: 1)
  92933. */
  92934. get samples(): number;
  92935. set samples(n: number);
  92936. /**
  92937. * Modify the scale of the post process to be the same as the viewport (default: false)
  92938. */
  92939. adaptScaleToCurrentViewport: boolean;
  92940. private _camera;
  92941. private _scene;
  92942. private _engine;
  92943. private _options;
  92944. private _reusable;
  92945. private _textureType;
  92946. private _textureFormat;
  92947. /**
  92948. * Smart array of input and output textures for the post process.
  92949. * @hidden
  92950. */
  92951. _textures: SmartArray<InternalTexture>;
  92952. /**
  92953. * The index in _textures that corresponds to the output texture.
  92954. * @hidden
  92955. */
  92956. _currentRenderTextureInd: number;
  92957. private _effect;
  92958. private _samplers;
  92959. private _fragmentUrl;
  92960. private _vertexUrl;
  92961. private _parameters;
  92962. private _scaleRatio;
  92963. protected _indexParameters: any;
  92964. private _shareOutputWithPostProcess;
  92965. private _texelSize;
  92966. private _forcedOutputTexture;
  92967. /**
  92968. * Returns the fragment url or shader name used in the post process.
  92969. * @returns the fragment url or name in the shader store.
  92970. */
  92971. getEffectName(): string;
  92972. /**
  92973. * An event triggered when the postprocess is activated.
  92974. */
  92975. onActivateObservable: Observable<Camera>;
  92976. private _onActivateObserver;
  92977. /**
  92978. * A function that is added to the onActivateObservable
  92979. */
  92980. set onActivate(callback: Nullable<(camera: Camera) => void>);
  92981. /**
  92982. * An event triggered when the postprocess changes its size.
  92983. */
  92984. onSizeChangedObservable: Observable<PostProcess>;
  92985. private _onSizeChangedObserver;
  92986. /**
  92987. * A function that is added to the onSizeChangedObservable
  92988. */
  92989. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  92990. /**
  92991. * An event triggered when the postprocess applies its effect.
  92992. */
  92993. onApplyObservable: Observable<Effect>;
  92994. private _onApplyObserver;
  92995. /**
  92996. * A function that is added to the onApplyObservable
  92997. */
  92998. set onApply(callback: (effect: Effect) => void);
  92999. /**
  93000. * An event triggered before rendering the postprocess
  93001. */
  93002. onBeforeRenderObservable: Observable<Effect>;
  93003. private _onBeforeRenderObserver;
  93004. /**
  93005. * A function that is added to the onBeforeRenderObservable
  93006. */
  93007. set onBeforeRender(callback: (effect: Effect) => void);
  93008. /**
  93009. * An event triggered after rendering the postprocess
  93010. */
  93011. onAfterRenderObservable: Observable<Effect>;
  93012. private _onAfterRenderObserver;
  93013. /**
  93014. * A function that is added to the onAfterRenderObservable
  93015. */
  93016. set onAfterRender(callback: (efect: Effect) => void);
  93017. /**
  93018. * 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
  93019. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93020. */
  93021. get inputTexture(): InternalTexture;
  93022. set inputTexture(value: InternalTexture);
  93023. /**
  93024. * Gets the camera which post process is applied to.
  93025. * @returns The camera the post process is applied to.
  93026. */
  93027. getCamera(): Camera;
  93028. /**
  93029. * Gets the texel size of the postprocess.
  93030. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93031. */
  93032. get texelSize(): Vector2;
  93033. /**
  93034. * Creates a new instance PostProcess
  93035. * @param name The name of the PostProcess.
  93036. * @param fragmentUrl The url of the fragment shader to be used.
  93037. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93038. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93039. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93040. * @param camera The camera to apply the render pass to.
  93041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93042. * @param engine The engine which the post process will be applied. (default: current engine)
  93043. * @param reusable If the post process can be reused on the same frame. (default: false)
  93044. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93045. * @param textureType Type of textures used when performing the post process. (default: 0)
  93046. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93047. * @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
  93048. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93049. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93050. */
  93051. constructor(
  93052. /** Name of the PostProcess. */
  93053. 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);
  93054. /**
  93055. * Gets a string idenfifying the name of the class
  93056. * @returns "PostProcess" string
  93057. */
  93058. getClassName(): string;
  93059. /**
  93060. * Gets the engine which this post process belongs to.
  93061. * @returns The engine the post process was enabled with.
  93062. */
  93063. getEngine(): Engine;
  93064. /**
  93065. * The effect that is created when initializing the post process.
  93066. * @returns The created effect corresponding the the postprocess.
  93067. */
  93068. getEffect(): Effect;
  93069. /**
  93070. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93071. * @param postProcess The post process to share the output with.
  93072. * @returns This post process.
  93073. */
  93074. shareOutputWith(postProcess: PostProcess): PostProcess;
  93075. /**
  93076. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93077. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93078. */
  93079. useOwnOutput(): void;
  93080. /**
  93081. * Updates the effect with the current post process compile time values and recompiles the shader.
  93082. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93083. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93084. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93085. * @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
  93086. * @param onCompiled Called when the shader has been compiled.
  93087. * @param onError Called if there is an error when compiling a shader.
  93088. */
  93089. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93090. /**
  93091. * The post process is reusable if it can be used multiple times within one frame.
  93092. * @returns If the post process is reusable
  93093. */
  93094. isReusable(): boolean;
  93095. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93096. markTextureDirty(): void;
  93097. /**
  93098. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93099. * 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.
  93100. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93101. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93102. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93103. * @returns The target texture that was bound to be written to.
  93104. */
  93105. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93106. /**
  93107. * If the post process is supported.
  93108. */
  93109. get isSupported(): boolean;
  93110. /**
  93111. * The aspect ratio of the output texture.
  93112. */
  93113. get aspectRatio(): number;
  93114. /**
  93115. * Get a value indicating if the post-process is ready to be used
  93116. * @returns true if the post-process is ready (shader is compiled)
  93117. */
  93118. isReady(): boolean;
  93119. /**
  93120. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93121. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93122. */
  93123. apply(): Nullable<Effect>;
  93124. private _disposeTextures;
  93125. /**
  93126. * Disposes the post process.
  93127. * @param camera The camera to dispose the post process on.
  93128. */
  93129. dispose(camera?: Camera): void;
  93130. }
  93131. }
  93132. declare module BABYLON {
  93133. /** @hidden */
  93134. export var kernelBlurVaryingDeclaration: {
  93135. name: string;
  93136. shader: string;
  93137. };
  93138. }
  93139. declare module BABYLON {
  93140. /** @hidden */
  93141. export var kernelBlurFragment: {
  93142. name: string;
  93143. shader: string;
  93144. };
  93145. }
  93146. declare module BABYLON {
  93147. /** @hidden */
  93148. export var kernelBlurFragment2: {
  93149. name: string;
  93150. shader: string;
  93151. };
  93152. }
  93153. declare module BABYLON {
  93154. /** @hidden */
  93155. export var kernelBlurPixelShader: {
  93156. name: string;
  93157. shader: string;
  93158. };
  93159. }
  93160. declare module BABYLON {
  93161. /** @hidden */
  93162. export var kernelBlurVertex: {
  93163. name: string;
  93164. shader: string;
  93165. };
  93166. }
  93167. declare module BABYLON {
  93168. /** @hidden */
  93169. export var kernelBlurVertexShader: {
  93170. name: string;
  93171. shader: string;
  93172. };
  93173. }
  93174. declare module BABYLON {
  93175. /**
  93176. * The Blur Post Process which blurs an image based on a kernel and direction.
  93177. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93178. */
  93179. export class BlurPostProcess extends PostProcess {
  93180. /** The direction in which to blur the image. */
  93181. direction: Vector2;
  93182. private blockCompilation;
  93183. protected _kernel: number;
  93184. protected _idealKernel: number;
  93185. protected _packedFloat: boolean;
  93186. private _staticDefines;
  93187. /**
  93188. * Sets the length in pixels of the blur sample region
  93189. */
  93190. set kernel(v: number);
  93191. /**
  93192. * Gets the length in pixels of the blur sample region
  93193. */
  93194. get kernel(): number;
  93195. /**
  93196. * Sets wether or not the blur needs to unpack/repack floats
  93197. */
  93198. set packedFloat(v: boolean);
  93199. /**
  93200. * Gets wether or not the blur is unpacking/repacking floats
  93201. */
  93202. get packedFloat(): boolean;
  93203. /**
  93204. * Creates a new instance BlurPostProcess
  93205. * @param name The name of the effect.
  93206. * @param direction The direction in which to blur the image.
  93207. * @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.
  93208. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93209. * @param camera The camera to apply the render pass to.
  93210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93211. * @param engine The engine which the post process will be applied. (default: current engine)
  93212. * @param reusable If the post process can be reused on the same frame. (default: false)
  93213. * @param textureType Type of textures used when performing the post process. (default: 0)
  93214. * @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)
  93215. */
  93216. constructor(name: string,
  93217. /** The direction in which to blur the image. */
  93218. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93219. /**
  93220. * Updates the effect with the current post process compile time values and recompiles the shader.
  93221. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93222. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93223. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93224. * @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
  93225. * @param onCompiled Called when the shader has been compiled.
  93226. * @param onError Called if there is an error when compiling a shader.
  93227. */
  93228. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93229. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93230. /**
  93231. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93232. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93233. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93234. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93235. * The gaps between physical kernels are compensated for in the weighting of the samples
  93236. * @param idealKernel Ideal blur kernel.
  93237. * @return Nearest best kernel.
  93238. */
  93239. protected _nearestBestKernel(idealKernel: number): number;
  93240. /**
  93241. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93242. * @param x The point on the Gaussian distribution to sample.
  93243. * @return the value of the Gaussian function at x.
  93244. */
  93245. protected _gaussianWeight(x: number): number;
  93246. /**
  93247. * Generates a string that can be used as a floating point number in GLSL.
  93248. * @param x Value to print.
  93249. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93250. * @return GLSL float string.
  93251. */
  93252. protected _glslFloat(x: number, decimalFigures?: number): string;
  93253. }
  93254. }
  93255. declare module BABYLON {
  93256. /**
  93257. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93258. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93259. * You can then easily use it as a reflectionTexture on a flat surface.
  93260. * In case the surface is not a plane, please consider relying on reflection probes.
  93261. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93262. */
  93263. export class MirrorTexture extends RenderTargetTexture {
  93264. private scene;
  93265. /**
  93266. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93267. * 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.
  93268. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93269. */
  93270. mirrorPlane: Plane;
  93271. /**
  93272. * Define the blur ratio used to blur the reflection if needed.
  93273. */
  93274. set blurRatio(value: number);
  93275. get blurRatio(): number;
  93276. /**
  93277. * Define the adaptive blur kernel used to blur the reflection if needed.
  93278. * This will autocompute the closest best match for the `blurKernel`
  93279. */
  93280. set adaptiveBlurKernel(value: number);
  93281. /**
  93282. * Define the blur kernel 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 blurKernel(value: number);
  93286. /**
  93287. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93288. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93289. */
  93290. set blurKernelX(value: number);
  93291. get blurKernelX(): number;
  93292. /**
  93293. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93294. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93295. */
  93296. set blurKernelY(value: number);
  93297. get blurKernelY(): number;
  93298. private _autoComputeBlurKernel;
  93299. protected _onRatioRescale(): void;
  93300. private _updateGammaSpace;
  93301. private _imageProcessingConfigChangeObserver;
  93302. private _transformMatrix;
  93303. private _mirrorMatrix;
  93304. private _savedViewMatrix;
  93305. private _blurX;
  93306. private _blurY;
  93307. private _adaptiveBlurKernel;
  93308. private _blurKernelX;
  93309. private _blurKernelY;
  93310. private _blurRatio;
  93311. /**
  93312. * Instantiates a Mirror Texture.
  93313. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93314. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93315. * You can then easily use it as a reflectionTexture on a flat surface.
  93316. * In case the surface is not a plane, please consider relying on reflection probes.
  93317. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93318. * @param name
  93319. * @param size
  93320. * @param scene
  93321. * @param generateMipMaps
  93322. * @param type
  93323. * @param samplingMode
  93324. * @param generateDepthBuffer
  93325. */
  93326. constructor(name: string, size: number | {
  93327. width: number;
  93328. height: number;
  93329. } | {
  93330. ratio: number;
  93331. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93332. private _preparePostProcesses;
  93333. /**
  93334. * Clone the mirror texture.
  93335. * @returns the cloned texture
  93336. */
  93337. clone(): MirrorTexture;
  93338. /**
  93339. * Serialize the texture to a JSON representation you could use in Parse later on
  93340. * @returns the serialized JSON representation
  93341. */
  93342. serialize(): any;
  93343. /**
  93344. * Dispose the texture and release its associated resources.
  93345. */
  93346. dispose(): void;
  93347. }
  93348. }
  93349. declare module BABYLON {
  93350. /**
  93351. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93352. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93353. */
  93354. export class Texture extends BaseTexture {
  93355. /**
  93356. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93357. */
  93358. static SerializeBuffers: boolean;
  93359. /** @hidden */
  93360. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93361. /** @hidden */
  93362. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93363. /** @hidden */
  93364. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93365. /** nearest is mag = nearest and min = nearest and mip = linear */
  93366. static readonly NEAREST_SAMPLINGMODE: number;
  93367. /** nearest is mag = nearest and min = nearest and mip = linear */
  93368. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93369. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93370. static readonly BILINEAR_SAMPLINGMODE: number;
  93371. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93372. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93373. /** Trilinear is mag = linear and min = linear and mip = linear */
  93374. static readonly TRILINEAR_SAMPLINGMODE: number;
  93375. /** Trilinear is mag = linear and min = linear and mip = linear */
  93376. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93377. /** mag = nearest and min = nearest and mip = nearest */
  93378. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93379. /** mag = nearest and min = linear and mip = nearest */
  93380. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93381. /** mag = nearest and min = linear and mip = linear */
  93382. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93383. /** mag = nearest and min = linear and mip = none */
  93384. static readonly NEAREST_LINEAR: number;
  93385. /** mag = nearest and min = nearest and mip = none */
  93386. static readonly NEAREST_NEAREST: number;
  93387. /** mag = linear and min = nearest and mip = nearest */
  93388. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93389. /** mag = linear and min = nearest and mip = linear */
  93390. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93391. /** mag = linear and min = linear and mip = none */
  93392. static readonly LINEAR_LINEAR: number;
  93393. /** mag = linear and min = nearest and mip = none */
  93394. static readonly LINEAR_NEAREST: number;
  93395. /** Explicit coordinates mode */
  93396. static readonly EXPLICIT_MODE: number;
  93397. /** Spherical coordinates mode */
  93398. static readonly SPHERICAL_MODE: number;
  93399. /** Planar coordinates mode */
  93400. static readonly PLANAR_MODE: number;
  93401. /** Cubic coordinates mode */
  93402. static readonly CUBIC_MODE: number;
  93403. /** Projection coordinates mode */
  93404. static readonly PROJECTION_MODE: number;
  93405. /** Inverse Cubic coordinates mode */
  93406. static readonly SKYBOX_MODE: number;
  93407. /** Inverse Cubic coordinates mode */
  93408. static readonly INVCUBIC_MODE: number;
  93409. /** Equirectangular coordinates mode */
  93410. static readonly EQUIRECTANGULAR_MODE: number;
  93411. /** Equirectangular Fixed coordinates mode */
  93412. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93413. /** Equirectangular Fixed Mirrored coordinates mode */
  93414. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93415. /** Texture is not repeating outside of 0..1 UVs */
  93416. static readonly CLAMP_ADDRESSMODE: number;
  93417. /** Texture is repeating outside of 0..1 UVs */
  93418. static readonly WRAP_ADDRESSMODE: number;
  93419. /** Texture is repeating and mirrored */
  93420. static readonly MIRROR_ADDRESSMODE: number;
  93421. /**
  93422. * 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
  93423. */
  93424. static UseSerializedUrlIfAny: boolean;
  93425. /**
  93426. * Define the url of the texture.
  93427. */
  93428. url: Nullable<string>;
  93429. /**
  93430. * Define an offset on the texture to offset the u coordinates of the UVs
  93431. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93432. */
  93433. uOffset: number;
  93434. /**
  93435. * Define an offset on the texture to offset the v coordinates of the UVs
  93436. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93437. */
  93438. vOffset: number;
  93439. /**
  93440. * Define an offset on the texture to scale the u coordinates of the UVs
  93441. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93442. */
  93443. uScale: number;
  93444. /**
  93445. * Define an offset on the texture to scale the v coordinates of the UVs
  93446. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93447. */
  93448. vScale: number;
  93449. /**
  93450. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93451. * @see http://doc.babylonjs.com/how_to/more_materials
  93452. */
  93453. uAng: number;
  93454. /**
  93455. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93456. * @see http://doc.babylonjs.com/how_to/more_materials
  93457. */
  93458. vAng: number;
  93459. /**
  93460. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93461. * @see http://doc.babylonjs.com/how_to/more_materials
  93462. */
  93463. wAng: number;
  93464. /**
  93465. * Defines the center of rotation (U)
  93466. */
  93467. uRotationCenter: number;
  93468. /**
  93469. * Defines the center of rotation (V)
  93470. */
  93471. vRotationCenter: number;
  93472. /**
  93473. * Defines the center of rotation (W)
  93474. */
  93475. wRotationCenter: number;
  93476. /**
  93477. * Are mip maps generated for this texture or not.
  93478. */
  93479. get noMipmap(): boolean;
  93480. /**
  93481. * List of inspectable custom properties (used by the Inspector)
  93482. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93483. */
  93484. inspectableCustomProperties: Nullable<IInspectable[]>;
  93485. private _noMipmap;
  93486. /** @hidden */
  93487. _invertY: boolean;
  93488. private _rowGenerationMatrix;
  93489. private _cachedTextureMatrix;
  93490. private _projectionModeMatrix;
  93491. private _t0;
  93492. private _t1;
  93493. private _t2;
  93494. private _cachedUOffset;
  93495. private _cachedVOffset;
  93496. private _cachedUScale;
  93497. private _cachedVScale;
  93498. private _cachedUAng;
  93499. private _cachedVAng;
  93500. private _cachedWAng;
  93501. private _cachedProjectionMatrixId;
  93502. private _cachedCoordinatesMode;
  93503. /** @hidden */
  93504. protected _initialSamplingMode: number;
  93505. /** @hidden */
  93506. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93507. private _deleteBuffer;
  93508. protected _format: Nullable<number>;
  93509. private _delayedOnLoad;
  93510. private _delayedOnError;
  93511. private _mimeType?;
  93512. /**
  93513. * Observable triggered once the texture has been loaded.
  93514. */
  93515. onLoadObservable: Observable<Texture>;
  93516. protected _isBlocking: boolean;
  93517. /**
  93518. * Is the texture preventing material to render while loading.
  93519. * If false, a default texture will be used instead of the loading one during the preparation step.
  93520. */
  93521. set isBlocking(value: boolean);
  93522. get isBlocking(): boolean;
  93523. /**
  93524. * Get the current sampling mode associated with the texture.
  93525. */
  93526. get samplingMode(): number;
  93527. /**
  93528. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93529. */
  93530. get invertY(): boolean;
  93531. /**
  93532. * Instantiates a new texture.
  93533. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93534. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93535. * @param url defines the url of the picture to load as a texture
  93536. * @param scene defines the scene or engine the texture will belong to
  93537. * @param noMipmap defines if the texture will require mip maps or not
  93538. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93539. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93540. * @param onLoad defines a callback triggered when the texture has been loaded
  93541. * @param onError defines a callback triggered when an error occurred during the loading session
  93542. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93543. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93544. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93545. * @param mimeType defines an optional mime type information
  93546. */
  93547. 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);
  93548. /**
  93549. * Update the url (and optional buffer) of this texture if url was null during construction.
  93550. * @param url the url of the texture
  93551. * @param buffer the buffer of the texture (defaults to null)
  93552. * @param onLoad callback called when the texture is loaded (defaults to null)
  93553. */
  93554. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93555. /**
  93556. * Finish the loading sequence of a texture flagged as delayed load.
  93557. * @hidden
  93558. */
  93559. delayLoad(): void;
  93560. private _prepareRowForTextureGeneration;
  93561. /**
  93562. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93563. * @returns the transform matrix of the texture.
  93564. */
  93565. getTextureMatrix(uBase?: number): Matrix;
  93566. /**
  93567. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93568. * @returns The reflection texture transform
  93569. */
  93570. getReflectionTextureMatrix(): Matrix;
  93571. /**
  93572. * Clones the texture.
  93573. * @returns the cloned texture
  93574. */
  93575. clone(): Texture;
  93576. /**
  93577. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93578. * @returns The JSON representation of the texture
  93579. */
  93580. serialize(): any;
  93581. /**
  93582. * Get the current class name of the texture useful for serialization or dynamic coding.
  93583. * @returns "Texture"
  93584. */
  93585. getClassName(): string;
  93586. /**
  93587. * Dispose the texture and release its associated resources.
  93588. */
  93589. dispose(): void;
  93590. /**
  93591. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93592. * @param parsedTexture Define the JSON representation of the texture
  93593. * @param scene Define the scene the parsed texture should be instantiated in
  93594. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93595. * @returns The parsed texture if successful
  93596. */
  93597. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93598. /**
  93599. * Creates a texture from its base 64 representation.
  93600. * @param data Define the base64 payload without the data: prefix
  93601. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93602. * @param scene Define the scene the texture should belong to
  93603. * @param noMipmap Forces the texture to not create mip map information if true
  93604. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93605. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93606. * @param onLoad define a callback triggered when the texture has been loaded
  93607. * @param onError define a callback triggered when an error occurred during the loading session
  93608. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93609. * @returns the created texture
  93610. */
  93611. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93612. /**
  93613. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93614. * @param data Define the base64 payload without the data: prefix
  93615. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93616. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93617. * @param scene Define the scene the texture should belong to
  93618. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93619. * @param noMipmap Forces the texture to not create mip map information if true
  93620. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93621. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93622. * @param onLoad define a callback triggered when the texture has been loaded
  93623. * @param onError define a callback triggered when an error occurred during the loading session
  93624. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93625. * @returns the created texture
  93626. */
  93627. 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;
  93628. }
  93629. }
  93630. declare module BABYLON {
  93631. /**
  93632. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93633. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93634. */
  93635. export class PostProcessManager {
  93636. private _scene;
  93637. private _indexBuffer;
  93638. private _vertexBuffers;
  93639. /**
  93640. * Creates a new instance PostProcess
  93641. * @param scene The scene that the post process is associated with.
  93642. */
  93643. constructor(scene: Scene);
  93644. private _prepareBuffers;
  93645. private _buildIndexBuffer;
  93646. /**
  93647. * Rebuilds the vertex buffers of the manager.
  93648. * @hidden
  93649. */
  93650. _rebuild(): void;
  93651. /**
  93652. * Prepares a frame to be run through a post process.
  93653. * @param sourceTexture The input texture to the post procesess. (default: null)
  93654. * @param postProcesses An array of post processes to be run. (default: null)
  93655. * @returns True if the post processes were able to be run.
  93656. * @hidden
  93657. */
  93658. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93659. /**
  93660. * Manually render a set of post processes to a texture.
  93661. * @param postProcesses An array of post processes to be run.
  93662. * @param targetTexture The target texture to render to.
  93663. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93664. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93665. * @param lodLevel defines which lod of the texture to render to
  93666. */
  93667. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93668. /**
  93669. * Finalize the result of the output of the postprocesses.
  93670. * @param doNotPresent If true the result will not be displayed to the screen.
  93671. * @param targetTexture The target texture to render to.
  93672. * @param faceIndex The index of the face to bind the target texture to.
  93673. * @param postProcesses The array of post processes to render.
  93674. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93675. * @hidden
  93676. */
  93677. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93678. /**
  93679. * Disposes of the post process manager.
  93680. */
  93681. dispose(): void;
  93682. }
  93683. }
  93684. declare module BABYLON {
  93685. /**
  93686. * This Helps creating a texture that will be created from a camera in your scene.
  93687. * It is basically a dynamic texture that could be used to create special effects for instance.
  93688. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93689. */
  93690. export class RenderTargetTexture extends Texture {
  93691. isCube: boolean;
  93692. /**
  93693. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93694. */
  93695. static readonly REFRESHRATE_RENDER_ONCE: number;
  93696. /**
  93697. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93698. */
  93699. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93700. /**
  93701. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93702. * the central point of your effect and can save a lot of performances.
  93703. */
  93704. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93705. /**
  93706. * Use this predicate to dynamically define the list of mesh you want to render.
  93707. * If set, the renderList property will be overwritten.
  93708. */
  93709. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93710. private _renderList;
  93711. /**
  93712. * Use this list to define the list of mesh you want to render.
  93713. */
  93714. get renderList(): Nullable<Array<AbstractMesh>>;
  93715. set renderList(value: Nullable<Array<AbstractMesh>>);
  93716. /**
  93717. * Use this function to overload the renderList array at rendering time.
  93718. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93719. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93720. * the cube (if the RTT is a cube, else layerOrFace=0).
  93721. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  93722. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  93723. * hold dummy elements!
  93724. */
  93725. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  93726. private _hookArray;
  93727. /**
  93728. * Define if particles should be rendered in your texture.
  93729. */
  93730. renderParticles: boolean;
  93731. /**
  93732. * Define if sprites should be rendered in your texture.
  93733. */
  93734. renderSprites: boolean;
  93735. /**
  93736. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93737. */
  93738. coordinatesMode: number;
  93739. /**
  93740. * Define the camera used to render the texture.
  93741. */
  93742. activeCamera: Nullable<Camera>;
  93743. /**
  93744. * Override the render function of the texture with your own one.
  93745. */
  93746. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93747. /**
  93748. * Define if camera post processes should be use while rendering the texture.
  93749. */
  93750. useCameraPostProcesses: boolean;
  93751. /**
  93752. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93753. */
  93754. ignoreCameraViewport: boolean;
  93755. private _postProcessManager;
  93756. private _postProcesses;
  93757. private _resizeObserver;
  93758. /**
  93759. * An event triggered when the texture is unbind.
  93760. */
  93761. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93762. /**
  93763. * An event triggered when the texture is unbind.
  93764. */
  93765. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93766. private _onAfterUnbindObserver;
  93767. /**
  93768. * Set a after unbind callback in the texture.
  93769. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93770. */
  93771. set onAfterUnbind(callback: () => void);
  93772. /**
  93773. * An event triggered before rendering the texture
  93774. */
  93775. onBeforeRenderObservable: Observable<number>;
  93776. private _onBeforeRenderObserver;
  93777. /**
  93778. * Set a before render callback in the texture.
  93779. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93780. */
  93781. set onBeforeRender(callback: (faceIndex: number) => void);
  93782. /**
  93783. * An event triggered after rendering the texture
  93784. */
  93785. onAfterRenderObservable: Observable<number>;
  93786. private _onAfterRenderObserver;
  93787. /**
  93788. * Set a after render callback in the texture.
  93789. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93790. */
  93791. set onAfterRender(callback: (faceIndex: number) => void);
  93792. /**
  93793. * An event triggered after the texture clear
  93794. */
  93795. onClearObservable: Observable<Engine>;
  93796. private _onClearObserver;
  93797. /**
  93798. * Set a clear callback in the texture.
  93799. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93800. */
  93801. set onClear(callback: (Engine: Engine) => void);
  93802. /**
  93803. * An event triggered when the texture is resized.
  93804. */
  93805. onResizeObservable: Observable<RenderTargetTexture>;
  93806. /**
  93807. * Define the clear color of the Render Target if it should be different from the scene.
  93808. */
  93809. clearColor: Color4;
  93810. protected _size: number | {
  93811. width: number;
  93812. height: number;
  93813. layers?: number;
  93814. };
  93815. protected _initialSizeParameter: number | {
  93816. width: number;
  93817. height: number;
  93818. } | {
  93819. ratio: number;
  93820. };
  93821. protected _sizeRatio: Nullable<number>;
  93822. /** @hidden */
  93823. _generateMipMaps: boolean;
  93824. protected _renderingManager: RenderingManager;
  93825. /** @hidden */
  93826. _waitingRenderList: string[];
  93827. protected _doNotChangeAspectRatio: boolean;
  93828. protected _currentRefreshId: number;
  93829. protected _refreshRate: number;
  93830. protected _textureMatrix: Matrix;
  93831. protected _samples: number;
  93832. protected _renderTargetOptions: RenderTargetCreationOptions;
  93833. /**
  93834. * Gets render target creation options that were used.
  93835. */
  93836. get renderTargetOptions(): RenderTargetCreationOptions;
  93837. protected _engine: Engine;
  93838. protected _onRatioRescale(): void;
  93839. /**
  93840. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93841. * It must define where the camera used to render the texture is set
  93842. */
  93843. boundingBoxPosition: Vector3;
  93844. private _boundingBoxSize;
  93845. /**
  93846. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93847. * When defined, the cubemap will switch to local mode
  93848. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93849. * @example https://www.babylonjs-playground.com/#RNASML
  93850. */
  93851. set boundingBoxSize(value: Vector3);
  93852. get boundingBoxSize(): Vector3;
  93853. /**
  93854. * In case the RTT has been created with a depth texture, get the associated
  93855. * depth texture.
  93856. * Otherwise, return null.
  93857. */
  93858. get depthStencilTexture(): Nullable<InternalTexture>;
  93859. /**
  93860. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93861. * or used a shadow, depth texture...
  93862. * @param name The friendly name of the texture
  93863. * @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)
  93864. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93865. * @param generateMipMaps True if mip maps need to be generated after render.
  93866. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93867. * @param type The type of the buffer in the RTT (int, half float, float...)
  93868. * @param isCube True if a cube texture needs to be created
  93869. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93870. * @param generateDepthBuffer True to generate a depth buffer
  93871. * @param generateStencilBuffer True to generate a stencil buffer
  93872. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93873. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93874. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93875. */
  93876. constructor(name: string, size: number | {
  93877. width: number;
  93878. height: number;
  93879. layers?: number;
  93880. } | {
  93881. ratio: number;
  93882. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93883. /**
  93884. * Creates a depth stencil texture.
  93885. * This is only available in WebGL 2 or with the depth texture extension available.
  93886. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93887. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93888. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93889. */
  93890. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93891. private _processSizeParameter;
  93892. /**
  93893. * Define the number of samples to use in case of MSAA.
  93894. * It defaults to one meaning no MSAA has been enabled.
  93895. */
  93896. get samples(): number;
  93897. set samples(value: number);
  93898. /**
  93899. * Resets the refresh counter of the texture and start bak from scratch.
  93900. * Could be useful to regenerate the texture if it is setup to render only once.
  93901. */
  93902. resetRefreshCounter(): void;
  93903. /**
  93904. * Define the refresh rate of the texture or the rendering frequency.
  93905. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93906. */
  93907. get refreshRate(): number;
  93908. set refreshRate(value: number);
  93909. /**
  93910. * Adds a post process to the render target rendering passes.
  93911. * @param postProcess define the post process to add
  93912. */
  93913. addPostProcess(postProcess: PostProcess): void;
  93914. /**
  93915. * Clear all the post processes attached to the render target
  93916. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93917. */
  93918. clearPostProcesses(dispose?: boolean): void;
  93919. /**
  93920. * Remove one of the post process from the list of attached post processes to the texture
  93921. * @param postProcess define the post process to remove from the list
  93922. */
  93923. removePostProcess(postProcess: PostProcess): void;
  93924. /** @hidden */
  93925. _shouldRender(): boolean;
  93926. /**
  93927. * Gets the actual render size of the texture.
  93928. * @returns the width of the render size
  93929. */
  93930. getRenderSize(): number;
  93931. /**
  93932. * Gets the actual render width of the texture.
  93933. * @returns the width of the render size
  93934. */
  93935. getRenderWidth(): number;
  93936. /**
  93937. * Gets the actual render height of the texture.
  93938. * @returns the height of the render size
  93939. */
  93940. getRenderHeight(): number;
  93941. /**
  93942. * Gets the actual number of layers of the texture.
  93943. * @returns the number of layers
  93944. */
  93945. getRenderLayers(): number;
  93946. /**
  93947. * Get if the texture can be rescaled or not.
  93948. */
  93949. get canRescale(): boolean;
  93950. /**
  93951. * Resize the texture using a ratio.
  93952. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93953. */
  93954. scale(ratio: number): void;
  93955. /**
  93956. * Get the texture reflection matrix used to rotate/transform the reflection.
  93957. * @returns the reflection matrix
  93958. */
  93959. getReflectionTextureMatrix(): Matrix;
  93960. /**
  93961. * Resize the texture to a new desired size.
  93962. * Be carrefull as it will recreate all the data in the new texture.
  93963. * @param size Define the new size. It can be:
  93964. * - a number for squared texture,
  93965. * - an object containing { width: number, height: number }
  93966. * - or an object containing a ratio { ratio: number }
  93967. */
  93968. resize(size: number | {
  93969. width: number;
  93970. height: number;
  93971. } | {
  93972. ratio: number;
  93973. }): void;
  93974. private _defaultRenderListPrepared;
  93975. /**
  93976. * Renders all the objects from the render list into the texture.
  93977. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93978. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93979. */
  93980. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93981. private _bestReflectionRenderTargetDimension;
  93982. private _prepareRenderingManager;
  93983. /**
  93984. * @hidden
  93985. * @param faceIndex face index to bind to if this is a cubetexture
  93986. * @param layer defines the index of the texture to bind in the array
  93987. */
  93988. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93989. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93990. private renderToTarget;
  93991. /**
  93992. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93993. * This allowed control for front to back rendering or reversly depending of the special needs.
  93994. *
  93995. * @param renderingGroupId The rendering group id corresponding to its index
  93996. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93997. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93998. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93999. */
  94000. 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;
  94001. /**
  94002. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94003. *
  94004. * @param renderingGroupId The rendering group id corresponding to its index
  94005. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94006. */
  94007. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  94008. /**
  94009. * Clones the texture.
  94010. * @returns the cloned texture
  94011. */
  94012. clone(): RenderTargetTexture;
  94013. /**
  94014. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94015. * @returns The JSON representation of the texture
  94016. */
  94017. serialize(): any;
  94018. /**
  94019. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94020. */
  94021. disposeFramebufferObjects(): void;
  94022. /**
  94023. * Dispose the texture and release its associated resources.
  94024. */
  94025. dispose(): void;
  94026. /** @hidden */
  94027. _rebuild(): void;
  94028. /**
  94029. * Clear the info related to rendering groups preventing retention point in material dispose.
  94030. */
  94031. freeRenderingGroups(): void;
  94032. /**
  94033. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94034. * @returns the view count
  94035. */
  94036. getViewCount(): number;
  94037. }
  94038. }
  94039. declare module BABYLON {
  94040. /**
  94041. * Options for compiling materials.
  94042. */
  94043. export interface IMaterialCompilationOptions {
  94044. /**
  94045. * Defines whether clip planes are enabled.
  94046. */
  94047. clipPlane: boolean;
  94048. /**
  94049. * Defines whether instances are enabled.
  94050. */
  94051. useInstances: boolean;
  94052. }
  94053. /**
  94054. * Base class for the main features of a material in Babylon.js
  94055. */
  94056. export class Material implements IAnimatable {
  94057. /**
  94058. * Returns the triangle fill mode
  94059. */
  94060. static readonly TriangleFillMode: number;
  94061. /**
  94062. * Returns the wireframe mode
  94063. */
  94064. static readonly WireFrameFillMode: number;
  94065. /**
  94066. * Returns the point fill mode
  94067. */
  94068. static readonly PointFillMode: number;
  94069. /**
  94070. * Returns the point list draw mode
  94071. */
  94072. static readonly PointListDrawMode: number;
  94073. /**
  94074. * Returns the line list draw mode
  94075. */
  94076. static readonly LineListDrawMode: number;
  94077. /**
  94078. * Returns the line loop draw mode
  94079. */
  94080. static readonly LineLoopDrawMode: number;
  94081. /**
  94082. * Returns the line strip draw mode
  94083. */
  94084. static readonly LineStripDrawMode: number;
  94085. /**
  94086. * Returns the triangle strip draw mode
  94087. */
  94088. static readonly TriangleStripDrawMode: number;
  94089. /**
  94090. * Returns the triangle fan draw mode
  94091. */
  94092. static readonly TriangleFanDrawMode: number;
  94093. /**
  94094. * Stores the clock-wise side orientation
  94095. */
  94096. static readonly ClockWiseSideOrientation: number;
  94097. /**
  94098. * Stores the counter clock-wise side orientation
  94099. */
  94100. static readonly CounterClockWiseSideOrientation: number;
  94101. /**
  94102. * The dirty texture flag value
  94103. */
  94104. static readonly TextureDirtyFlag: number;
  94105. /**
  94106. * The dirty light flag value
  94107. */
  94108. static readonly LightDirtyFlag: number;
  94109. /**
  94110. * The dirty fresnel flag value
  94111. */
  94112. static readonly FresnelDirtyFlag: number;
  94113. /**
  94114. * The dirty attribute flag value
  94115. */
  94116. static readonly AttributesDirtyFlag: number;
  94117. /**
  94118. * The dirty misc flag value
  94119. */
  94120. static readonly MiscDirtyFlag: number;
  94121. /**
  94122. * The all dirty flag value
  94123. */
  94124. static readonly AllDirtyFlag: number;
  94125. /**
  94126. * The ID of the material
  94127. */
  94128. id: string;
  94129. /**
  94130. * Gets or sets the unique id of the material
  94131. */
  94132. uniqueId: number;
  94133. /**
  94134. * The name of the material
  94135. */
  94136. name: string;
  94137. /**
  94138. * Gets or sets user defined metadata
  94139. */
  94140. metadata: any;
  94141. /**
  94142. * For internal use only. Please do not use.
  94143. */
  94144. reservedDataStore: any;
  94145. /**
  94146. * Specifies if the ready state should be checked on each call
  94147. */
  94148. checkReadyOnEveryCall: boolean;
  94149. /**
  94150. * Specifies if the ready state should be checked once
  94151. */
  94152. checkReadyOnlyOnce: boolean;
  94153. /**
  94154. * The state of the material
  94155. */
  94156. state: string;
  94157. /**
  94158. * The alpha value of the material
  94159. */
  94160. protected _alpha: number;
  94161. /**
  94162. * List of inspectable custom properties (used by the Inspector)
  94163. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94164. */
  94165. inspectableCustomProperties: IInspectable[];
  94166. /**
  94167. * Sets the alpha value of the material
  94168. */
  94169. set alpha(value: number);
  94170. /**
  94171. * Gets the alpha value of the material
  94172. */
  94173. get alpha(): number;
  94174. /**
  94175. * Specifies if back face culling is enabled
  94176. */
  94177. protected _backFaceCulling: boolean;
  94178. /**
  94179. * Sets the back-face culling state
  94180. */
  94181. set backFaceCulling(value: boolean);
  94182. /**
  94183. * Gets the back-face culling state
  94184. */
  94185. get backFaceCulling(): boolean;
  94186. /**
  94187. * Stores the value for side orientation
  94188. */
  94189. sideOrientation: number;
  94190. /**
  94191. * Callback triggered when the material is compiled
  94192. */
  94193. onCompiled: Nullable<(effect: Effect) => void>;
  94194. /**
  94195. * Callback triggered when an error occurs
  94196. */
  94197. onError: Nullable<(effect: Effect, errors: string) => void>;
  94198. /**
  94199. * Callback triggered to get the render target textures
  94200. */
  94201. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94202. /**
  94203. * Gets a boolean indicating that current material needs to register RTT
  94204. */
  94205. get hasRenderTargetTextures(): boolean;
  94206. /**
  94207. * Specifies if the material should be serialized
  94208. */
  94209. doNotSerialize: boolean;
  94210. /**
  94211. * @hidden
  94212. */
  94213. _storeEffectOnSubMeshes: boolean;
  94214. /**
  94215. * Stores the animations for the material
  94216. */
  94217. animations: Nullable<Array<Animation>>;
  94218. /**
  94219. * An event triggered when the material is disposed
  94220. */
  94221. onDisposeObservable: Observable<Material>;
  94222. /**
  94223. * An observer which watches for dispose events
  94224. */
  94225. private _onDisposeObserver;
  94226. private _onUnBindObservable;
  94227. /**
  94228. * Called during a dispose event
  94229. */
  94230. set onDispose(callback: () => void);
  94231. private _onBindObservable;
  94232. /**
  94233. * An event triggered when the material is bound
  94234. */
  94235. get onBindObservable(): Observable<AbstractMesh>;
  94236. /**
  94237. * An observer which watches for bind events
  94238. */
  94239. private _onBindObserver;
  94240. /**
  94241. * Called during a bind event
  94242. */
  94243. set onBind(callback: (Mesh: AbstractMesh) => void);
  94244. /**
  94245. * An event triggered when the material is unbound
  94246. */
  94247. get onUnBindObservable(): Observable<Material>;
  94248. /**
  94249. * Stores the value of the alpha mode
  94250. */
  94251. private _alphaMode;
  94252. /**
  94253. * Sets the value of the alpha mode.
  94254. *
  94255. * | Value | Type | Description |
  94256. * | --- | --- | --- |
  94257. * | 0 | ALPHA_DISABLE | |
  94258. * | 1 | ALPHA_ADD | |
  94259. * | 2 | ALPHA_COMBINE | |
  94260. * | 3 | ALPHA_SUBTRACT | |
  94261. * | 4 | ALPHA_MULTIPLY | |
  94262. * | 5 | ALPHA_MAXIMIZED | |
  94263. * | 6 | ALPHA_ONEONE | |
  94264. * | 7 | ALPHA_PREMULTIPLIED | |
  94265. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94266. * | 9 | ALPHA_INTERPOLATE | |
  94267. * | 10 | ALPHA_SCREENMODE | |
  94268. *
  94269. */
  94270. set alphaMode(value: number);
  94271. /**
  94272. * Gets the value of the alpha mode
  94273. */
  94274. get alphaMode(): number;
  94275. /**
  94276. * Stores the state of the need depth pre-pass value
  94277. */
  94278. private _needDepthPrePass;
  94279. /**
  94280. * Sets the need depth pre-pass value
  94281. */
  94282. set needDepthPrePass(value: boolean);
  94283. /**
  94284. * Gets the depth pre-pass value
  94285. */
  94286. get needDepthPrePass(): boolean;
  94287. /**
  94288. * Specifies if depth writing should be disabled
  94289. */
  94290. disableDepthWrite: boolean;
  94291. /**
  94292. * Specifies if depth writing should be forced
  94293. */
  94294. forceDepthWrite: boolean;
  94295. /**
  94296. * Specifies the depth function that should be used. 0 means the default engine function
  94297. */
  94298. depthFunction: number;
  94299. /**
  94300. * Specifies if there should be a separate pass for culling
  94301. */
  94302. separateCullingPass: boolean;
  94303. /**
  94304. * Stores the state specifing if fog should be enabled
  94305. */
  94306. private _fogEnabled;
  94307. /**
  94308. * Sets the state for enabling fog
  94309. */
  94310. set fogEnabled(value: boolean);
  94311. /**
  94312. * Gets the value of the fog enabled state
  94313. */
  94314. get fogEnabled(): boolean;
  94315. /**
  94316. * Stores the size of points
  94317. */
  94318. pointSize: number;
  94319. /**
  94320. * Stores the z offset value
  94321. */
  94322. zOffset: number;
  94323. /**
  94324. * Gets a value specifying if wireframe mode is enabled
  94325. */
  94326. get wireframe(): boolean;
  94327. /**
  94328. * Sets the state of wireframe mode
  94329. */
  94330. set wireframe(value: boolean);
  94331. /**
  94332. * Gets the value specifying if point clouds are enabled
  94333. */
  94334. get pointsCloud(): boolean;
  94335. /**
  94336. * Sets the state of point cloud mode
  94337. */
  94338. set pointsCloud(value: boolean);
  94339. /**
  94340. * Gets the material fill mode
  94341. */
  94342. get fillMode(): number;
  94343. /**
  94344. * Sets the material fill mode
  94345. */
  94346. set fillMode(value: number);
  94347. /**
  94348. * @hidden
  94349. * Stores the effects for the material
  94350. */
  94351. _effect: Nullable<Effect>;
  94352. /**
  94353. * Specifies if uniform buffers should be used
  94354. */
  94355. private _useUBO;
  94356. /**
  94357. * Stores a reference to the scene
  94358. */
  94359. private _scene;
  94360. /**
  94361. * Stores the fill mode state
  94362. */
  94363. private _fillMode;
  94364. /**
  94365. * Specifies if the depth write state should be cached
  94366. */
  94367. private _cachedDepthWriteState;
  94368. /**
  94369. * Specifies if the depth function state should be cached
  94370. */
  94371. private _cachedDepthFunctionState;
  94372. /**
  94373. * Stores the uniform buffer
  94374. */
  94375. protected _uniformBuffer: UniformBuffer;
  94376. /** @hidden */
  94377. _indexInSceneMaterialArray: number;
  94378. /** @hidden */
  94379. meshMap: Nullable<{
  94380. [id: string]: AbstractMesh | undefined;
  94381. }>;
  94382. /**
  94383. * Creates a material instance
  94384. * @param name defines the name of the material
  94385. * @param scene defines the scene to reference
  94386. * @param doNotAdd specifies if the material should be added to the scene
  94387. */
  94388. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94389. /**
  94390. * Returns a string representation of the current material
  94391. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94392. * @returns a string with material information
  94393. */
  94394. toString(fullDetails?: boolean): string;
  94395. /**
  94396. * Gets the class name of the material
  94397. * @returns a string with the class name of the material
  94398. */
  94399. getClassName(): string;
  94400. /**
  94401. * Specifies if updates for the material been locked
  94402. */
  94403. get isFrozen(): boolean;
  94404. /**
  94405. * Locks updates for the material
  94406. */
  94407. freeze(): void;
  94408. /**
  94409. * Unlocks updates for the material
  94410. */
  94411. unfreeze(): void;
  94412. /**
  94413. * Specifies if the material is ready to be used
  94414. * @param mesh defines the mesh to check
  94415. * @param useInstances specifies if instances should be used
  94416. * @returns a boolean indicating if the material is ready to be used
  94417. */
  94418. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94419. /**
  94420. * Specifies that the submesh is ready to be used
  94421. * @param mesh defines the mesh to check
  94422. * @param subMesh defines which submesh to check
  94423. * @param useInstances specifies that instances should be used
  94424. * @returns a boolean indicating that the submesh is ready or not
  94425. */
  94426. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94427. /**
  94428. * Returns the material effect
  94429. * @returns the effect associated with the material
  94430. */
  94431. getEffect(): Nullable<Effect>;
  94432. /**
  94433. * Returns the current scene
  94434. * @returns a Scene
  94435. */
  94436. getScene(): Scene;
  94437. /**
  94438. * Specifies if the material will require alpha blending
  94439. * @returns a boolean specifying if alpha blending is needed
  94440. */
  94441. needAlphaBlending(): boolean;
  94442. /**
  94443. * Specifies if the mesh will require alpha blending
  94444. * @param mesh defines the mesh to check
  94445. * @returns a boolean specifying if alpha blending is needed for the mesh
  94446. */
  94447. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94448. /**
  94449. * Specifies if this material should be rendered in alpha test mode
  94450. * @returns a boolean specifying if an alpha test is needed.
  94451. */
  94452. needAlphaTesting(): boolean;
  94453. /**
  94454. * Gets the texture used for the alpha test
  94455. * @returns the texture to use for alpha testing
  94456. */
  94457. getAlphaTestTexture(): Nullable<BaseTexture>;
  94458. /**
  94459. * Marks the material to indicate that it needs to be re-calculated
  94460. */
  94461. markDirty(): void;
  94462. /** @hidden */
  94463. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94464. /**
  94465. * Binds the material to the mesh
  94466. * @param world defines the world transformation matrix
  94467. * @param mesh defines the mesh to bind the material to
  94468. */
  94469. bind(world: Matrix, mesh?: Mesh): void;
  94470. /**
  94471. * Binds the submesh to the material
  94472. * @param world defines the world transformation matrix
  94473. * @param mesh defines the mesh containing the submesh
  94474. * @param subMesh defines the submesh to bind the material to
  94475. */
  94476. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94477. /**
  94478. * Binds the world matrix to the material
  94479. * @param world defines the world transformation matrix
  94480. */
  94481. bindOnlyWorldMatrix(world: Matrix): void;
  94482. /**
  94483. * Binds the scene's uniform buffer to the effect.
  94484. * @param effect defines the effect to bind to the scene uniform buffer
  94485. * @param sceneUbo defines the uniform buffer storing scene data
  94486. */
  94487. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94488. /**
  94489. * Binds the view matrix to the effect
  94490. * @param effect defines the effect to bind the view matrix to
  94491. */
  94492. bindView(effect: Effect): void;
  94493. /**
  94494. * Binds the view projection matrix to the effect
  94495. * @param effect defines the effect to bind the view projection matrix to
  94496. */
  94497. bindViewProjection(effect: Effect): void;
  94498. /**
  94499. * Specifies if material alpha testing should be turned on for the mesh
  94500. * @param mesh defines the mesh to check
  94501. */
  94502. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94503. /**
  94504. * Processes to execute after binding the material to a mesh
  94505. * @param mesh defines the rendered mesh
  94506. */
  94507. protected _afterBind(mesh?: Mesh): void;
  94508. /**
  94509. * Unbinds the material from the mesh
  94510. */
  94511. unbind(): void;
  94512. /**
  94513. * Gets the active textures from the material
  94514. * @returns an array of textures
  94515. */
  94516. getActiveTextures(): BaseTexture[];
  94517. /**
  94518. * Specifies if the material uses a texture
  94519. * @param texture defines the texture to check against the material
  94520. * @returns a boolean specifying if the material uses the texture
  94521. */
  94522. hasTexture(texture: BaseTexture): boolean;
  94523. /**
  94524. * Makes a duplicate of the material, and gives it a new name
  94525. * @param name defines the new name for the duplicated material
  94526. * @returns the cloned material
  94527. */
  94528. clone(name: string): Nullable<Material>;
  94529. /**
  94530. * Gets the meshes bound to the material
  94531. * @returns an array of meshes bound to the material
  94532. */
  94533. getBindedMeshes(): AbstractMesh[];
  94534. /**
  94535. * Force shader compilation
  94536. * @param mesh defines the mesh associated with this material
  94537. * @param onCompiled defines a function to execute once the material is compiled
  94538. * @param options defines the options to configure the compilation
  94539. * @param onError defines a function to execute if the material fails compiling
  94540. */
  94541. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94542. /**
  94543. * Force shader compilation
  94544. * @param mesh defines the mesh that will use this material
  94545. * @param options defines additional options for compiling the shaders
  94546. * @returns a promise that resolves when the compilation completes
  94547. */
  94548. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94549. private static readonly _AllDirtyCallBack;
  94550. private static readonly _ImageProcessingDirtyCallBack;
  94551. private static readonly _TextureDirtyCallBack;
  94552. private static readonly _FresnelDirtyCallBack;
  94553. private static readonly _MiscDirtyCallBack;
  94554. private static readonly _LightsDirtyCallBack;
  94555. private static readonly _AttributeDirtyCallBack;
  94556. private static _FresnelAndMiscDirtyCallBack;
  94557. private static _TextureAndMiscDirtyCallBack;
  94558. private static readonly _DirtyCallbackArray;
  94559. private static readonly _RunDirtyCallBacks;
  94560. /**
  94561. * Marks a define in the material to indicate that it needs to be re-computed
  94562. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94563. */
  94564. markAsDirty(flag: number): void;
  94565. /**
  94566. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94567. * @param func defines a function which checks material defines against the submeshes
  94568. */
  94569. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94570. /**
  94571. * Indicates that we need to re-calculated for all submeshes
  94572. */
  94573. protected _markAllSubMeshesAsAllDirty(): void;
  94574. /**
  94575. * Indicates that image processing needs to be re-calculated for all submeshes
  94576. */
  94577. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94578. /**
  94579. * Indicates that textures need to be re-calculated for all submeshes
  94580. */
  94581. protected _markAllSubMeshesAsTexturesDirty(): void;
  94582. /**
  94583. * Indicates that fresnel needs to be re-calculated for all submeshes
  94584. */
  94585. protected _markAllSubMeshesAsFresnelDirty(): void;
  94586. /**
  94587. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94588. */
  94589. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94590. /**
  94591. * Indicates that lights need to be re-calculated for all submeshes
  94592. */
  94593. protected _markAllSubMeshesAsLightsDirty(): void;
  94594. /**
  94595. * Indicates that attributes need to be re-calculated for all submeshes
  94596. */
  94597. protected _markAllSubMeshesAsAttributesDirty(): void;
  94598. /**
  94599. * Indicates that misc needs to be re-calculated for all submeshes
  94600. */
  94601. protected _markAllSubMeshesAsMiscDirty(): void;
  94602. /**
  94603. * Indicates that textures and misc need to be re-calculated for all submeshes
  94604. */
  94605. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94606. /**
  94607. * Disposes the material
  94608. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94609. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94610. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94611. */
  94612. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94613. /** @hidden */
  94614. private releaseVertexArrayObject;
  94615. /**
  94616. * Serializes this material
  94617. * @returns the serialized material object
  94618. */
  94619. serialize(): any;
  94620. /**
  94621. * Creates a material from parsed material data
  94622. * @param parsedMaterial defines parsed material data
  94623. * @param scene defines the hosting scene
  94624. * @param rootUrl defines the root URL to use to load textures
  94625. * @returns a new material
  94626. */
  94627. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94628. }
  94629. }
  94630. declare module BABYLON {
  94631. /**
  94632. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94633. * separate meshes. This can be use to improve performances.
  94634. * @see http://doc.babylonjs.com/how_to/multi_materials
  94635. */
  94636. export class MultiMaterial extends Material {
  94637. private _subMaterials;
  94638. /**
  94639. * Gets or Sets the list of Materials used within the multi material.
  94640. * They need to be ordered according to the submeshes order in the associated mesh
  94641. */
  94642. get subMaterials(): Nullable<Material>[];
  94643. set subMaterials(value: Nullable<Material>[]);
  94644. /**
  94645. * Function used to align with Node.getChildren()
  94646. * @returns the list of Materials used within the multi material
  94647. */
  94648. getChildren(): Nullable<Material>[];
  94649. /**
  94650. * Instantiates a new Multi Material
  94651. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94652. * separate meshes. This can be use to improve performances.
  94653. * @see http://doc.babylonjs.com/how_to/multi_materials
  94654. * @param name Define the name in the scene
  94655. * @param scene Define the scene the material belongs to
  94656. */
  94657. constructor(name: string, scene: Scene);
  94658. private _hookArray;
  94659. /**
  94660. * Get one of the submaterial by its index in the submaterials array
  94661. * @param index The index to look the sub material at
  94662. * @returns The Material if the index has been defined
  94663. */
  94664. getSubMaterial(index: number): Nullable<Material>;
  94665. /**
  94666. * Get the list of active textures for the whole sub materials list.
  94667. * @returns All the textures that will be used during the rendering
  94668. */
  94669. getActiveTextures(): BaseTexture[];
  94670. /**
  94671. * Gets the current class name of the material e.g. "MultiMaterial"
  94672. * Mainly use in serialization.
  94673. * @returns the class name
  94674. */
  94675. getClassName(): string;
  94676. /**
  94677. * Checks if the material is ready to render the requested sub mesh
  94678. * @param mesh Define the mesh the submesh belongs to
  94679. * @param subMesh Define the sub mesh to look readyness for
  94680. * @param useInstances Define whether or not the material is used with instances
  94681. * @returns true if ready, otherwise false
  94682. */
  94683. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94684. /**
  94685. * Clones the current material and its related sub materials
  94686. * @param name Define the name of the newly cloned material
  94687. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94688. * @returns the cloned material
  94689. */
  94690. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94691. /**
  94692. * Serializes the materials into a JSON representation.
  94693. * @returns the JSON representation
  94694. */
  94695. serialize(): any;
  94696. /**
  94697. * Dispose the material and release its associated resources
  94698. * @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)
  94699. * @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)
  94700. * @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)
  94701. */
  94702. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94703. /**
  94704. * Creates a MultiMaterial from parsed MultiMaterial data.
  94705. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94706. * @param scene defines the hosting scene
  94707. * @returns a new MultiMaterial
  94708. */
  94709. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94710. }
  94711. }
  94712. declare module BABYLON {
  94713. /**
  94714. * Base class for submeshes
  94715. */
  94716. export class BaseSubMesh {
  94717. /** @hidden */
  94718. _materialDefines: Nullable<MaterialDefines>;
  94719. /** @hidden */
  94720. _materialEffect: Nullable<Effect>;
  94721. /**
  94722. * Gets material defines used by the effect associated to the sub mesh
  94723. */
  94724. get materialDefines(): Nullable<MaterialDefines>;
  94725. /**
  94726. * Sets material defines used by the effect associated to the sub mesh
  94727. */
  94728. set materialDefines(defines: Nullable<MaterialDefines>);
  94729. /**
  94730. * Gets associated effect
  94731. */
  94732. get effect(): Nullable<Effect>;
  94733. /**
  94734. * Sets associated effect (effect used to render this submesh)
  94735. * @param effect defines the effect to associate with
  94736. * @param defines defines the set of defines used to compile this effect
  94737. */
  94738. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94739. }
  94740. /**
  94741. * Defines a subdivision inside a mesh
  94742. */
  94743. export class SubMesh extends BaseSubMesh implements ICullable {
  94744. /** the material index to use */
  94745. materialIndex: number;
  94746. /** vertex index start */
  94747. verticesStart: number;
  94748. /** vertices count */
  94749. verticesCount: number;
  94750. /** index start */
  94751. indexStart: number;
  94752. /** indices count */
  94753. indexCount: number;
  94754. /** @hidden */
  94755. _linesIndexCount: number;
  94756. private _mesh;
  94757. private _renderingMesh;
  94758. private _boundingInfo;
  94759. private _linesIndexBuffer;
  94760. /** @hidden */
  94761. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94762. /** @hidden */
  94763. _trianglePlanes: Plane[];
  94764. /** @hidden */
  94765. _lastColliderTransformMatrix: Nullable<Matrix>;
  94766. /** @hidden */
  94767. _renderId: number;
  94768. /** @hidden */
  94769. _alphaIndex: number;
  94770. /** @hidden */
  94771. _distanceToCamera: number;
  94772. /** @hidden */
  94773. _id: number;
  94774. private _currentMaterial;
  94775. /**
  94776. * Add a new submesh to a mesh
  94777. * @param materialIndex defines the material index to use
  94778. * @param verticesStart defines vertex index start
  94779. * @param verticesCount defines vertices count
  94780. * @param indexStart defines index start
  94781. * @param indexCount defines indices count
  94782. * @param mesh defines the parent mesh
  94783. * @param renderingMesh defines an optional rendering mesh
  94784. * @param createBoundingBox defines if bounding box should be created for this submesh
  94785. * @returns the new submesh
  94786. */
  94787. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94788. /**
  94789. * Creates a new submesh
  94790. * @param materialIndex defines the material index to use
  94791. * @param verticesStart defines vertex index start
  94792. * @param verticesCount defines vertices count
  94793. * @param indexStart defines index start
  94794. * @param indexCount defines indices count
  94795. * @param mesh defines the parent mesh
  94796. * @param renderingMesh defines an optional rendering mesh
  94797. * @param createBoundingBox defines if bounding box should be created for this submesh
  94798. */
  94799. constructor(
  94800. /** the material index to use */
  94801. materialIndex: number,
  94802. /** vertex index start */
  94803. verticesStart: number,
  94804. /** vertices count */
  94805. verticesCount: number,
  94806. /** index start */
  94807. indexStart: number,
  94808. /** indices count */
  94809. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94810. /**
  94811. * Returns true if this submesh covers the entire parent mesh
  94812. * @ignorenaming
  94813. */
  94814. get IsGlobal(): boolean;
  94815. /**
  94816. * Returns the submesh BoudingInfo object
  94817. * @returns current bounding info (or mesh's one if the submesh is global)
  94818. */
  94819. getBoundingInfo(): BoundingInfo;
  94820. /**
  94821. * Sets the submesh BoundingInfo
  94822. * @param boundingInfo defines the new bounding info to use
  94823. * @returns the SubMesh
  94824. */
  94825. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94826. /**
  94827. * Returns the mesh of the current submesh
  94828. * @return the parent mesh
  94829. */
  94830. getMesh(): AbstractMesh;
  94831. /**
  94832. * Returns the rendering mesh of the submesh
  94833. * @returns the rendering mesh (could be different from parent mesh)
  94834. */
  94835. getRenderingMesh(): Mesh;
  94836. /**
  94837. * Returns the submesh material
  94838. * @returns null or the current material
  94839. */
  94840. getMaterial(): Nullable<Material>;
  94841. /**
  94842. * Sets a new updated BoundingInfo object to the submesh
  94843. * @param data defines an optional position array to use to determine the bounding info
  94844. * @returns the SubMesh
  94845. */
  94846. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94847. /** @hidden */
  94848. _checkCollision(collider: Collider): boolean;
  94849. /**
  94850. * Updates the submesh BoundingInfo
  94851. * @param world defines the world matrix to use to update the bounding info
  94852. * @returns the submesh
  94853. */
  94854. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94855. /**
  94856. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94857. * @param frustumPlanes defines the frustum planes
  94858. * @returns true if the submesh is intersecting with the frustum
  94859. */
  94860. isInFrustum(frustumPlanes: Plane[]): boolean;
  94861. /**
  94862. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94863. * @param frustumPlanes defines the frustum planes
  94864. * @returns true if the submesh is inside the frustum
  94865. */
  94866. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94867. /**
  94868. * Renders the submesh
  94869. * @param enableAlphaMode defines if alpha needs to be used
  94870. * @returns the submesh
  94871. */
  94872. render(enableAlphaMode: boolean): SubMesh;
  94873. /**
  94874. * @hidden
  94875. */
  94876. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94877. /**
  94878. * Checks if the submesh intersects with a ray
  94879. * @param ray defines the ray to test
  94880. * @returns true is the passed ray intersects the submesh bounding box
  94881. */
  94882. canIntersects(ray: Ray): boolean;
  94883. /**
  94884. * Intersects current submesh with a ray
  94885. * @param ray defines the ray to test
  94886. * @param positions defines mesh's positions array
  94887. * @param indices defines mesh's indices array
  94888. * @param fastCheck defines if only bounding info should be used
  94889. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94890. * @returns intersection info or null if no intersection
  94891. */
  94892. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94893. /** @hidden */
  94894. private _intersectLines;
  94895. /** @hidden */
  94896. private _intersectUnIndexedLines;
  94897. /** @hidden */
  94898. private _intersectTriangles;
  94899. /** @hidden */
  94900. private _intersectUnIndexedTriangles;
  94901. /** @hidden */
  94902. _rebuild(): void;
  94903. /**
  94904. * Creates a new submesh from the passed mesh
  94905. * @param newMesh defines the new hosting mesh
  94906. * @param newRenderingMesh defines an optional rendering mesh
  94907. * @returns the new submesh
  94908. */
  94909. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94910. /**
  94911. * Release associated resources
  94912. */
  94913. dispose(): void;
  94914. /**
  94915. * Gets the class name
  94916. * @returns the string "SubMesh".
  94917. */
  94918. getClassName(): string;
  94919. /**
  94920. * Creates a new submesh from indices data
  94921. * @param materialIndex the index of the main mesh material
  94922. * @param startIndex the index where to start the copy in the mesh indices array
  94923. * @param indexCount the number of indices to copy then from the startIndex
  94924. * @param mesh the main mesh to create the submesh from
  94925. * @param renderingMesh the optional rendering mesh
  94926. * @returns a new submesh
  94927. */
  94928. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94929. }
  94930. }
  94931. declare module BABYLON {
  94932. /**
  94933. * Class used to represent data loading progression
  94934. */
  94935. export class SceneLoaderFlags {
  94936. private static _ForceFullSceneLoadingForIncremental;
  94937. private static _ShowLoadingScreen;
  94938. private static _CleanBoneMatrixWeights;
  94939. private static _loggingLevel;
  94940. /**
  94941. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94942. */
  94943. static get ForceFullSceneLoadingForIncremental(): boolean;
  94944. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94945. /**
  94946. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94947. */
  94948. static get ShowLoadingScreen(): boolean;
  94949. static set ShowLoadingScreen(value: boolean);
  94950. /**
  94951. * Defines the current logging level (while loading the scene)
  94952. * @ignorenaming
  94953. */
  94954. static get loggingLevel(): number;
  94955. static set loggingLevel(value: number);
  94956. /**
  94957. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94958. */
  94959. static get CleanBoneMatrixWeights(): boolean;
  94960. static set CleanBoneMatrixWeights(value: boolean);
  94961. }
  94962. }
  94963. declare module BABYLON {
  94964. /**
  94965. * Class used to store geometry data (vertex buffers + index buffer)
  94966. */
  94967. export class Geometry implements IGetSetVerticesData {
  94968. /**
  94969. * Gets or sets the ID of the geometry
  94970. */
  94971. id: string;
  94972. /**
  94973. * Gets or sets the unique ID of the geometry
  94974. */
  94975. uniqueId: number;
  94976. /**
  94977. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94978. */
  94979. delayLoadState: number;
  94980. /**
  94981. * Gets the file containing the data to load when running in delay load state
  94982. */
  94983. delayLoadingFile: Nullable<string>;
  94984. /**
  94985. * Callback called when the geometry is updated
  94986. */
  94987. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94988. private _scene;
  94989. private _engine;
  94990. private _meshes;
  94991. private _totalVertices;
  94992. /** @hidden */
  94993. _indices: IndicesArray;
  94994. /** @hidden */
  94995. _vertexBuffers: {
  94996. [key: string]: VertexBuffer;
  94997. };
  94998. private _isDisposed;
  94999. private _extend;
  95000. private _boundingBias;
  95001. /** @hidden */
  95002. _delayInfo: Array<string>;
  95003. private _indexBuffer;
  95004. private _indexBufferIsUpdatable;
  95005. /** @hidden */
  95006. _boundingInfo: Nullable<BoundingInfo>;
  95007. /** @hidden */
  95008. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  95009. /** @hidden */
  95010. _softwareSkinningFrameId: number;
  95011. private _vertexArrayObjects;
  95012. private _updatable;
  95013. /** @hidden */
  95014. _positions: Nullable<Vector3[]>;
  95015. /**
  95016. * 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
  95017. */
  95018. get boundingBias(): Vector2;
  95019. /**
  95020. * 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
  95021. */
  95022. set boundingBias(value: Vector2);
  95023. /**
  95024. * Static function used to attach a new empty geometry to a mesh
  95025. * @param mesh defines the mesh to attach the geometry to
  95026. * @returns the new Geometry
  95027. */
  95028. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95029. /**
  95030. * Creates a new geometry
  95031. * @param id defines the unique ID
  95032. * @param scene defines the hosting scene
  95033. * @param vertexData defines the VertexData used to get geometry data
  95034. * @param updatable defines if geometry must be updatable (false by default)
  95035. * @param mesh defines the mesh that will be associated with the geometry
  95036. */
  95037. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95038. /**
  95039. * Gets the current extend of the geometry
  95040. */
  95041. get extend(): {
  95042. minimum: Vector3;
  95043. maximum: Vector3;
  95044. };
  95045. /**
  95046. * Gets the hosting scene
  95047. * @returns the hosting Scene
  95048. */
  95049. getScene(): Scene;
  95050. /**
  95051. * Gets the hosting engine
  95052. * @returns the hosting Engine
  95053. */
  95054. getEngine(): Engine;
  95055. /**
  95056. * Defines if the geometry is ready to use
  95057. * @returns true if the geometry is ready to be used
  95058. */
  95059. isReady(): boolean;
  95060. /**
  95061. * Gets a value indicating that the geometry should not be serialized
  95062. */
  95063. get doNotSerialize(): boolean;
  95064. /** @hidden */
  95065. _rebuild(): void;
  95066. /**
  95067. * Affects all geometry data in one call
  95068. * @param vertexData defines the geometry data
  95069. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95070. */
  95071. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95072. /**
  95073. * Set specific vertex data
  95074. * @param kind defines the data kind (Position, normal, etc...)
  95075. * @param data defines the vertex data to use
  95076. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95077. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95078. */
  95079. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95080. /**
  95081. * Removes a specific vertex data
  95082. * @param kind defines the data kind (Position, normal, etc...)
  95083. */
  95084. removeVerticesData(kind: string): void;
  95085. /**
  95086. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95087. * @param buffer defines the vertex buffer to use
  95088. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95089. */
  95090. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95091. /**
  95092. * Update a specific vertex buffer
  95093. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95094. * It will do nothing if the buffer is not updatable
  95095. * @param kind defines the data kind (Position, normal, etc...)
  95096. * @param data defines the data to use
  95097. * @param offset defines the offset in the target buffer where to store the data
  95098. * @param useBytes set to true if the offset is in bytes
  95099. */
  95100. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95101. /**
  95102. * Update a specific vertex buffer
  95103. * This function will create a new buffer if the current one is not updatable
  95104. * @param kind defines the data kind (Position, normal, etc...)
  95105. * @param data defines the data to use
  95106. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95107. */
  95108. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95109. private _updateBoundingInfo;
  95110. /** @hidden */
  95111. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95112. /**
  95113. * Gets total number of vertices
  95114. * @returns the total number of vertices
  95115. */
  95116. getTotalVertices(): number;
  95117. /**
  95118. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95119. * @param kind defines the data kind (Position, normal, etc...)
  95120. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95121. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95122. * @returns a float array containing vertex data
  95123. */
  95124. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95125. /**
  95126. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95127. * @param kind defines the data kind (Position, normal, etc...)
  95128. * @returns true if the vertex buffer with the specified kind is updatable
  95129. */
  95130. isVertexBufferUpdatable(kind: string): boolean;
  95131. /**
  95132. * Gets a specific vertex buffer
  95133. * @param kind defines the data kind (Position, normal, etc...)
  95134. * @returns a VertexBuffer
  95135. */
  95136. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95137. /**
  95138. * Returns all vertex buffers
  95139. * @return an object holding all vertex buffers indexed by kind
  95140. */
  95141. getVertexBuffers(): Nullable<{
  95142. [key: string]: VertexBuffer;
  95143. }>;
  95144. /**
  95145. * Gets a boolean indicating if specific vertex buffer is present
  95146. * @param kind defines the data kind (Position, normal, etc...)
  95147. * @returns true if data is present
  95148. */
  95149. isVerticesDataPresent(kind: string): boolean;
  95150. /**
  95151. * Gets a list of all attached data kinds (Position, normal, etc...)
  95152. * @returns a list of string containing all kinds
  95153. */
  95154. getVerticesDataKinds(): string[];
  95155. /**
  95156. * Update index buffer
  95157. * @param indices defines the indices to store in the index buffer
  95158. * @param offset defines the offset in the target buffer where to store the data
  95159. * @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)
  95160. */
  95161. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95162. /**
  95163. * Creates a new index buffer
  95164. * @param indices defines the indices to store in the index buffer
  95165. * @param totalVertices defines the total number of vertices (could be null)
  95166. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95167. */
  95168. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95169. /**
  95170. * Return the total number of indices
  95171. * @returns the total number of indices
  95172. */
  95173. getTotalIndices(): number;
  95174. /**
  95175. * Gets the index buffer array
  95176. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95177. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95178. * @returns the index buffer array
  95179. */
  95180. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95181. /**
  95182. * Gets the index buffer
  95183. * @return the index buffer
  95184. */
  95185. getIndexBuffer(): Nullable<DataBuffer>;
  95186. /** @hidden */
  95187. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95188. /**
  95189. * Release the associated resources for a specific mesh
  95190. * @param mesh defines the source mesh
  95191. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95192. */
  95193. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95194. /**
  95195. * Apply current geometry to a given mesh
  95196. * @param mesh defines the mesh to apply geometry to
  95197. */
  95198. applyToMesh(mesh: Mesh): void;
  95199. private _updateExtend;
  95200. private _applyToMesh;
  95201. private notifyUpdate;
  95202. /**
  95203. * Load the geometry if it was flagged as delay loaded
  95204. * @param scene defines the hosting scene
  95205. * @param onLoaded defines a callback called when the geometry is loaded
  95206. */
  95207. load(scene: Scene, onLoaded?: () => void): void;
  95208. private _queueLoad;
  95209. /**
  95210. * Invert the geometry to move from a right handed system to a left handed one.
  95211. */
  95212. toLeftHanded(): void;
  95213. /** @hidden */
  95214. _resetPointsArrayCache(): void;
  95215. /** @hidden */
  95216. _generatePointsArray(): boolean;
  95217. /**
  95218. * Gets a value indicating if the geometry is disposed
  95219. * @returns true if the geometry was disposed
  95220. */
  95221. isDisposed(): boolean;
  95222. private _disposeVertexArrayObjects;
  95223. /**
  95224. * Free all associated resources
  95225. */
  95226. dispose(): void;
  95227. /**
  95228. * Clone the current geometry into a new geometry
  95229. * @param id defines the unique ID of the new geometry
  95230. * @returns a new geometry object
  95231. */
  95232. copy(id: string): Geometry;
  95233. /**
  95234. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95235. * @return a JSON representation of the current geometry data (without the vertices data)
  95236. */
  95237. serialize(): any;
  95238. private toNumberArray;
  95239. /**
  95240. * Serialize all vertices data into a JSON oject
  95241. * @returns a JSON representation of the current geometry data
  95242. */
  95243. serializeVerticeData(): any;
  95244. /**
  95245. * Extracts a clone of a mesh geometry
  95246. * @param mesh defines the source mesh
  95247. * @param id defines the unique ID of the new geometry object
  95248. * @returns the new geometry object
  95249. */
  95250. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95251. /**
  95252. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95253. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95254. * Be aware Math.random() could cause collisions, but:
  95255. * "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"
  95256. * @returns a string containing a new GUID
  95257. */
  95258. static RandomId(): string;
  95259. /** @hidden */
  95260. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95261. private static _CleanMatricesWeights;
  95262. /**
  95263. * Create a new geometry from persisted data (Using .babylon file format)
  95264. * @param parsedVertexData defines the persisted data
  95265. * @param scene defines the hosting scene
  95266. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95267. * @returns the new geometry object
  95268. */
  95269. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95270. }
  95271. }
  95272. declare module BABYLON {
  95273. /**
  95274. * Define an interface for all classes that will get and set the data on vertices
  95275. */
  95276. export interface IGetSetVerticesData {
  95277. /**
  95278. * Gets a boolean indicating if specific vertex data is present
  95279. * @param kind defines the vertex data kind to use
  95280. * @returns true is data kind is present
  95281. */
  95282. isVerticesDataPresent(kind: string): boolean;
  95283. /**
  95284. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95285. * @param kind defines the data kind (Position, normal, etc...)
  95286. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95287. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95288. * @returns a float array containing vertex data
  95289. */
  95290. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95291. /**
  95292. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95293. * @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.
  95294. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95295. * @returns the indices array or an empty array if the mesh has no geometry
  95296. */
  95297. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95298. /**
  95299. * Set specific vertex data
  95300. * @param kind defines the data kind (Position, normal, etc...)
  95301. * @param data defines the vertex data to use
  95302. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95303. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95304. */
  95305. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95306. /**
  95307. * Update a specific associated vertex buffer
  95308. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95309. * - VertexBuffer.PositionKind
  95310. * - VertexBuffer.UVKind
  95311. * - VertexBuffer.UV2Kind
  95312. * - VertexBuffer.UV3Kind
  95313. * - VertexBuffer.UV4Kind
  95314. * - VertexBuffer.UV5Kind
  95315. * - VertexBuffer.UV6Kind
  95316. * - VertexBuffer.ColorKind
  95317. * - VertexBuffer.MatricesIndicesKind
  95318. * - VertexBuffer.MatricesIndicesExtraKind
  95319. * - VertexBuffer.MatricesWeightsKind
  95320. * - VertexBuffer.MatricesWeightsExtraKind
  95321. * @param data defines the data source
  95322. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95323. * @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)
  95324. */
  95325. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95326. /**
  95327. * Creates a new index buffer
  95328. * @param indices defines the indices to store in the index buffer
  95329. * @param totalVertices defines the total number of vertices (could be null)
  95330. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95331. */
  95332. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95333. }
  95334. /**
  95335. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95336. */
  95337. export class VertexData {
  95338. /**
  95339. * Mesh side orientation : usually the external or front surface
  95340. */
  95341. static readonly FRONTSIDE: number;
  95342. /**
  95343. * Mesh side orientation : usually the internal or back surface
  95344. */
  95345. static readonly BACKSIDE: number;
  95346. /**
  95347. * Mesh side orientation : both internal and external or front and back surfaces
  95348. */
  95349. static readonly DOUBLESIDE: number;
  95350. /**
  95351. * Mesh side orientation : by default, `FRONTSIDE`
  95352. */
  95353. static readonly DEFAULTSIDE: number;
  95354. /**
  95355. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95356. */
  95357. positions: Nullable<FloatArray>;
  95358. /**
  95359. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95360. */
  95361. normals: Nullable<FloatArray>;
  95362. /**
  95363. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95364. */
  95365. tangents: Nullable<FloatArray>;
  95366. /**
  95367. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95368. */
  95369. uvs: Nullable<FloatArray>;
  95370. /**
  95371. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95372. */
  95373. uvs2: Nullable<FloatArray>;
  95374. /**
  95375. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95376. */
  95377. uvs3: Nullable<FloatArray>;
  95378. /**
  95379. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95380. */
  95381. uvs4: Nullable<FloatArray>;
  95382. /**
  95383. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95384. */
  95385. uvs5: Nullable<FloatArray>;
  95386. /**
  95387. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95388. */
  95389. uvs6: Nullable<FloatArray>;
  95390. /**
  95391. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95392. */
  95393. colors: Nullable<FloatArray>;
  95394. /**
  95395. * 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).
  95396. */
  95397. matricesIndices: Nullable<FloatArray>;
  95398. /**
  95399. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95400. */
  95401. matricesWeights: Nullable<FloatArray>;
  95402. /**
  95403. * An array extending the number of possible indices
  95404. */
  95405. matricesIndicesExtra: Nullable<FloatArray>;
  95406. /**
  95407. * An array extending the number of possible weights when the number of indices is extended
  95408. */
  95409. matricesWeightsExtra: Nullable<FloatArray>;
  95410. /**
  95411. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95412. */
  95413. indices: Nullable<IndicesArray>;
  95414. /**
  95415. * Uses the passed data array to set the set the values for the specified kind of data
  95416. * @param data a linear array of floating numbers
  95417. * @param kind the type of data that is being set, eg positions, colors etc
  95418. */
  95419. set(data: FloatArray, kind: string): void;
  95420. /**
  95421. * Associates the vertexData to the passed Mesh.
  95422. * Sets it as updatable or not (default `false`)
  95423. * @param mesh the mesh the vertexData is applied to
  95424. * @param updatable when used and having the value true allows new data to update the vertexData
  95425. * @returns the VertexData
  95426. */
  95427. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95428. /**
  95429. * Associates the vertexData to the passed Geometry.
  95430. * Sets it as updatable or not (default `false`)
  95431. * @param geometry the geometry the vertexData is applied to
  95432. * @param updatable when used and having the value true allows new data to update the vertexData
  95433. * @returns VertexData
  95434. */
  95435. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95436. /**
  95437. * Updates the associated mesh
  95438. * @param mesh the mesh to be updated
  95439. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95440. * @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
  95441. * @returns VertexData
  95442. */
  95443. updateMesh(mesh: Mesh): VertexData;
  95444. /**
  95445. * Updates the associated geometry
  95446. * @param geometry the geometry to be updated
  95447. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95448. * @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
  95449. * @returns VertexData.
  95450. */
  95451. updateGeometry(geometry: Geometry): VertexData;
  95452. private _applyTo;
  95453. private _update;
  95454. /**
  95455. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95456. * @param matrix the transforming matrix
  95457. * @returns the VertexData
  95458. */
  95459. transform(matrix: Matrix): VertexData;
  95460. /**
  95461. * Merges the passed VertexData into the current one
  95462. * @param other the VertexData to be merged into the current one
  95463. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95464. * @returns the modified VertexData
  95465. */
  95466. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95467. private _mergeElement;
  95468. private _validate;
  95469. /**
  95470. * Serializes the VertexData
  95471. * @returns a serialized object
  95472. */
  95473. serialize(): any;
  95474. /**
  95475. * Extracts the vertexData from a mesh
  95476. * @param mesh the mesh from which to extract the VertexData
  95477. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95478. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95479. * @returns the object VertexData associated to the passed mesh
  95480. */
  95481. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95482. /**
  95483. * Extracts the vertexData from the geometry
  95484. * @param geometry the geometry from which to extract the VertexData
  95485. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95486. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95487. * @returns the object VertexData associated to the passed mesh
  95488. */
  95489. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95490. private static _ExtractFrom;
  95491. /**
  95492. * Creates the VertexData for a Ribbon
  95493. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95494. * * pathArray array of paths, each of which an array of successive Vector3
  95495. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95496. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95497. * * 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
  95498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95499. * * 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)
  95500. * * 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)
  95501. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95502. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95503. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95504. * @returns the VertexData of the ribbon
  95505. */
  95506. static CreateRibbon(options: {
  95507. pathArray: Vector3[][];
  95508. closeArray?: boolean;
  95509. closePath?: boolean;
  95510. offset?: number;
  95511. sideOrientation?: number;
  95512. frontUVs?: Vector4;
  95513. backUVs?: Vector4;
  95514. invertUV?: boolean;
  95515. uvs?: Vector2[];
  95516. colors?: Color4[];
  95517. }): VertexData;
  95518. /**
  95519. * Creates the VertexData for a box
  95520. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95521. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95522. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95523. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95524. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95525. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95526. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95528. * * 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)
  95529. * * 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)
  95530. * @returns the VertexData of the box
  95531. */
  95532. static CreateBox(options: {
  95533. size?: number;
  95534. width?: number;
  95535. height?: number;
  95536. depth?: number;
  95537. faceUV?: Vector4[];
  95538. faceColors?: Color4[];
  95539. sideOrientation?: number;
  95540. frontUVs?: Vector4;
  95541. backUVs?: Vector4;
  95542. }): VertexData;
  95543. /**
  95544. * Creates the VertexData for a tiled box
  95545. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95546. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95547. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95548. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95550. * @returns the VertexData of the box
  95551. */
  95552. static CreateTiledBox(options: {
  95553. pattern?: number;
  95554. width?: number;
  95555. height?: number;
  95556. depth?: number;
  95557. tileSize?: number;
  95558. tileWidth?: number;
  95559. tileHeight?: number;
  95560. alignHorizontal?: number;
  95561. alignVertical?: number;
  95562. faceUV?: Vector4[];
  95563. faceColors?: Color4[];
  95564. sideOrientation?: number;
  95565. }): VertexData;
  95566. /**
  95567. * Creates the VertexData for a tiled plane
  95568. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95569. * * pattern a limited pattern arrangement depending on the number
  95570. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95571. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95572. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95574. * * 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)
  95575. * * 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)
  95576. * @returns the VertexData of the tiled plane
  95577. */
  95578. static CreateTiledPlane(options: {
  95579. pattern?: number;
  95580. tileSize?: number;
  95581. tileWidth?: number;
  95582. tileHeight?: number;
  95583. size?: number;
  95584. width?: number;
  95585. height?: number;
  95586. alignHorizontal?: number;
  95587. alignVertical?: number;
  95588. sideOrientation?: number;
  95589. frontUVs?: Vector4;
  95590. backUVs?: Vector4;
  95591. }): VertexData;
  95592. /**
  95593. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95594. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95595. * * segments sets the number of horizontal strips optional, default 32
  95596. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95597. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95598. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95599. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95600. * * 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
  95601. * * 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
  95602. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95603. * * 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)
  95604. * * 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)
  95605. * @returns the VertexData of the ellipsoid
  95606. */
  95607. static CreateSphere(options: {
  95608. segments?: number;
  95609. diameter?: number;
  95610. diameterX?: number;
  95611. diameterY?: number;
  95612. diameterZ?: number;
  95613. arc?: number;
  95614. slice?: number;
  95615. sideOrientation?: number;
  95616. frontUVs?: Vector4;
  95617. backUVs?: Vector4;
  95618. }): VertexData;
  95619. /**
  95620. * Creates the VertexData for a cylinder, cone or prism
  95621. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95622. * * height sets the height (y direction) of the cylinder, optional, default 2
  95623. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95624. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95625. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95626. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95627. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95628. * * 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
  95629. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95630. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95631. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95632. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95634. * * 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)
  95635. * * 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)
  95636. * @returns the VertexData of the cylinder, cone or prism
  95637. */
  95638. static CreateCylinder(options: {
  95639. height?: number;
  95640. diameterTop?: number;
  95641. diameterBottom?: number;
  95642. diameter?: number;
  95643. tessellation?: number;
  95644. subdivisions?: number;
  95645. arc?: number;
  95646. faceColors?: Color4[];
  95647. faceUV?: Vector4[];
  95648. hasRings?: boolean;
  95649. enclose?: boolean;
  95650. sideOrientation?: number;
  95651. frontUVs?: Vector4;
  95652. backUVs?: Vector4;
  95653. }): VertexData;
  95654. /**
  95655. * Creates the VertexData for a torus
  95656. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95657. * * diameter the diameter of the torus, optional default 1
  95658. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95659. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95660. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95661. * * 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)
  95662. * * 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)
  95663. * @returns the VertexData of the torus
  95664. */
  95665. static CreateTorus(options: {
  95666. diameter?: number;
  95667. thickness?: number;
  95668. tessellation?: number;
  95669. sideOrientation?: number;
  95670. frontUVs?: Vector4;
  95671. backUVs?: Vector4;
  95672. }): VertexData;
  95673. /**
  95674. * Creates the VertexData of the LineSystem
  95675. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95676. * - lines an array of lines, each line being an array of successive Vector3
  95677. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95678. * @returns the VertexData of the LineSystem
  95679. */
  95680. static CreateLineSystem(options: {
  95681. lines: Vector3[][];
  95682. colors?: Nullable<Color4[][]>;
  95683. }): VertexData;
  95684. /**
  95685. * Create the VertexData for a DashedLines
  95686. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95687. * - points an array successive Vector3
  95688. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95689. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95690. * - dashNb the intended total number of dashes, optional, default 200
  95691. * @returns the VertexData for the DashedLines
  95692. */
  95693. static CreateDashedLines(options: {
  95694. points: Vector3[];
  95695. dashSize?: number;
  95696. gapSize?: number;
  95697. dashNb?: number;
  95698. }): VertexData;
  95699. /**
  95700. * Creates the VertexData for a Ground
  95701. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95702. * - width the width (x direction) of the ground, optional, default 1
  95703. * - height the height (z direction) of the ground, optional, default 1
  95704. * - subdivisions the number of subdivisions per side, optional, default 1
  95705. * @returns the VertexData of the Ground
  95706. */
  95707. static CreateGround(options: {
  95708. width?: number;
  95709. height?: number;
  95710. subdivisions?: number;
  95711. subdivisionsX?: number;
  95712. subdivisionsY?: number;
  95713. }): VertexData;
  95714. /**
  95715. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95716. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95717. * * xmin the ground minimum X coordinate, optional, default -1
  95718. * * zmin the ground minimum Z coordinate, optional, default -1
  95719. * * xmax the ground maximum X coordinate, optional, default 1
  95720. * * zmax the ground maximum Z coordinate, optional, default 1
  95721. * * 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}
  95722. * * 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}
  95723. * @returns the VertexData of the TiledGround
  95724. */
  95725. static CreateTiledGround(options: {
  95726. xmin: number;
  95727. zmin: number;
  95728. xmax: number;
  95729. zmax: number;
  95730. subdivisions?: {
  95731. w: number;
  95732. h: number;
  95733. };
  95734. precision?: {
  95735. w: number;
  95736. h: number;
  95737. };
  95738. }): VertexData;
  95739. /**
  95740. * Creates the VertexData of the Ground designed from a heightmap
  95741. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95742. * * width the width (x direction) of the ground
  95743. * * height the height (z direction) of the ground
  95744. * * subdivisions the number of subdivisions per side
  95745. * * minHeight the minimum altitude on the ground, optional, default 0
  95746. * * maxHeight the maximum altitude on the ground, optional default 1
  95747. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95748. * * buffer the array holding the image color data
  95749. * * bufferWidth the width of image
  95750. * * bufferHeight the height of image
  95751. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95752. * @returns the VertexData of the Ground designed from a heightmap
  95753. */
  95754. static CreateGroundFromHeightMap(options: {
  95755. width: number;
  95756. height: number;
  95757. subdivisions: number;
  95758. minHeight: number;
  95759. maxHeight: number;
  95760. colorFilter: Color3;
  95761. buffer: Uint8Array;
  95762. bufferWidth: number;
  95763. bufferHeight: number;
  95764. alphaFilter: number;
  95765. }): VertexData;
  95766. /**
  95767. * Creates the VertexData for a Plane
  95768. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95769. * * size sets the width and height of the plane to the value of size, optional default 1
  95770. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95771. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95773. * * 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)
  95774. * * 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)
  95775. * @returns the VertexData of the box
  95776. */
  95777. static CreatePlane(options: {
  95778. size?: number;
  95779. width?: number;
  95780. height?: number;
  95781. sideOrientation?: number;
  95782. frontUVs?: Vector4;
  95783. backUVs?: Vector4;
  95784. }): VertexData;
  95785. /**
  95786. * Creates the VertexData of the Disc or regular Polygon
  95787. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95788. * * radius the radius of the disc, optional default 0.5
  95789. * * tessellation the number of polygon sides, optional, default 64
  95790. * * 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
  95791. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95792. * * 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)
  95793. * * 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)
  95794. * @returns the VertexData of the box
  95795. */
  95796. static CreateDisc(options: {
  95797. radius?: number;
  95798. tessellation?: number;
  95799. arc?: number;
  95800. sideOrientation?: number;
  95801. frontUVs?: Vector4;
  95802. backUVs?: Vector4;
  95803. }): VertexData;
  95804. /**
  95805. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95806. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95807. * @param polygon a mesh built from polygonTriangulation.build()
  95808. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95809. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95810. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95811. * @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)
  95812. * @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)
  95813. * @returns the VertexData of the Polygon
  95814. */
  95815. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95816. /**
  95817. * Creates the VertexData of the IcoSphere
  95818. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95819. * * radius the radius of the IcoSphere, optional default 1
  95820. * * radiusX allows stretching in the x direction, optional, default radius
  95821. * * radiusY allows stretching in the y direction, optional, default radius
  95822. * * radiusZ allows stretching in the z direction, optional, default radius
  95823. * * flat when true creates a flat shaded mesh, optional, default true
  95824. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95825. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95826. * * 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)
  95827. * * 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)
  95828. * @returns the VertexData of the IcoSphere
  95829. */
  95830. static CreateIcoSphere(options: {
  95831. radius?: number;
  95832. radiusX?: number;
  95833. radiusY?: number;
  95834. radiusZ?: number;
  95835. flat?: boolean;
  95836. subdivisions?: number;
  95837. sideOrientation?: number;
  95838. frontUVs?: Vector4;
  95839. backUVs?: Vector4;
  95840. }): VertexData;
  95841. /**
  95842. * Creates the VertexData for a Polyhedron
  95843. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95844. * * type provided types are:
  95845. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95846. * * 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)
  95847. * * size the size of the IcoSphere, optional default 1
  95848. * * sizeX allows stretching in the x direction, optional, default size
  95849. * * sizeY allows stretching in the y direction, optional, default size
  95850. * * sizeZ allows stretching in the z direction, optional, default size
  95851. * * 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
  95852. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95853. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95854. * * flat when true creates a flat shaded mesh, optional, default true
  95855. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95856. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95857. * * 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)
  95858. * * 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)
  95859. * @returns the VertexData of the Polyhedron
  95860. */
  95861. static CreatePolyhedron(options: {
  95862. type?: number;
  95863. size?: number;
  95864. sizeX?: number;
  95865. sizeY?: number;
  95866. sizeZ?: number;
  95867. custom?: any;
  95868. faceUV?: Vector4[];
  95869. faceColors?: Color4[];
  95870. flat?: boolean;
  95871. sideOrientation?: number;
  95872. frontUVs?: Vector4;
  95873. backUVs?: Vector4;
  95874. }): VertexData;
  95875. /**
  95876. * Creates the VertexData for a TorusKnot
  95877. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95878. * * radius the radius of the torus knot, optional, default 2
  95879. * * tube the thickness of the tube, optional, default 0.5
  95880. * * radialSegments the number of sides on each tube segments, optional, default 32
  95881. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95882. * * p the number of windings around the z axis, optional, default 2
  95883. * * q the number of windings around the x axis, optional, default 3
  95884. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95885. * * 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)
  95886. * * 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)
  95887. * @returns the VertexData of the Torus Knot
  95888. */
  95889. static CreateTorusKnot(options: {
  95890. radius?: number;
  95891. tube?: number;
  95892. radialSegments?: number;
  95893. tubularSegments?: number;
  95894. p?: number;
  95895. q?: number;
  95896. sideOrientation?: number;
  95897. frontUVs?: Vector4;
  95898. backUVs?: Vector4;
  95899. }): VertexData;
  95900. /**
  95901. * Compute normals for given positions and indices
  95902. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95903. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95904. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95905. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95906. * * facetNormals : optional array of facet normals (vector3)
  95907. * * facetPositions : optional array of facet positions (vector3)
  95908. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95909. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95910. * * bInfo : optional bounding info, required for facetPartitioning computation
  95911. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95912. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95913. * * useRightHandedSystem: optional boolean to for right handed system computation
  95914. * * depthSort : optional boolean to enable the facet depth sort computation
  95915. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95916. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95917. */
  95918. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95919. facetNormals?: any;
  95920. facetPositions?: any;
  95921. facetPartitioning?: any;
  95922. ratio?: number;
  95923. bInfo?: any;
  95924. bbSize?: Vector3;
  95925. subDiv?: any;
  95926. useRightHandedSystem?: boolean;
  95927. depthSort?: boolean;
  95928. distanceTo?: Vector3;
  95929. depthSortedFacets?: any;
  95930. }): void;
  95931. /** @hidden */
  95932. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95933. /**
  95934. * Applies VertexData created from the imported parameters to the geometry
  95935. * @param parsedVertexData the parsed data from an imported file
  95936. * @param geometry the geometry to apply the VertexData to
  95937. */
  95938. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95939. }
  95940. }
  95941. declare module BABYLON {
  95942. /**
  95943. * Defines a target to use with MorphTargetManager
  95944. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95945. */
  95946. export class MorphTarget implements IAnimatable {
  95947. /** defines the name of the target */
  95948. name: string;
  95949. /**
  95950. * Gets or sets the list of animations
  95951. */
  95952. animations: Animation[];
  95953. private _scene;
  95954. private _positions;
  95955. private _normals;
  95956. private _tangents;
  95957. private _uvs;
  95958. private _influence;
  95959. private _uniqueId;
  95960. /**
  95961. * Observable raised when the influence changes
  95962. */
  95963. onInfluenceChanged: Observable<boolean>;
  95964. /** @hidden */
  95965. _onDataLayoutChanged: Observable<void>;
  95966. /**
  95967. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95968. */
  95969. get influence(): number;
  95970. set influence(influence: number);
  95971. /**
  95972. * Gets or sets the id of the morph Target
  95973. */
  95974. id: string;
  95975. private _animationPropertiesOverride;
  95976. /**
  95977. * Gets or sets the animation properties override
  95978. */
  95979. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95980. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95981. /**
  95982. * Creates a new MorphTarget
  95983. * @param name defines the name of the target
  95984. * @param influence defines the influence to use
  95985. * @param scene defines the scene the morphtarget belongs to
  95986. */
  95987. constructor(
  95988. /** defines the name of the target */
  95989. name: string, influence?: number, scene?: Nullable<Scene>);
  95990. /**
  95991. * Gets the unique ID of this manager
  95992. */
  95993. get uniqueId(): number;
  95994. /**
  95995. * Gets a boolean defining if the target contains position data
  95996. */
  95997. get hasPositions(): boolean;
  95998. /**
  95999. * Gets a boolean defining if the target contains normal data
  96000. */
  96001. get hasNormals(): boolean;
  96002. /**
  96003. * Gets a boolean defining if the target contains tangent data
  96004. */
  96005. get hasTangents(): boolean;
  96006. /**
  96007. * Gets a boolean defining if the target contains texture coordinates data
  96008. */
  96009. get hasUVs(): boolean;
  96010. /**
  96011. * Affects position data to this target
  96012. * @param data defines the position data to use
  96013. */
  96014. setPositions(data: Nullable<FloatArray>): void;
  96015. /**
  96016. * Gets the position data stored in this target
  96017. * @returns a FloatArray containing the position data (or null if not present)
  96018. */
  96019. getPositions(): Nullable<FloatArray>;
  96020. /**
  96021. * Affects normal data to this target
  96022. * @param data defines the normal data to use
  96023. */
  96024. setNormals(data: Nullable<FloatArray>): void;
  96025. /**
  96026. * Gets the normal data stored in this target
  96027. * @returns a FloatArray containing the normal data (or null if not present)
  96028. */
  96029. getNormals(): Nullable<FloatArray>;
  96030. /**
  96031. * Affects tangent data to this target
  96032. * @param data defines the tangent data to use
  96033. */
  96034. setTangents(data: Nullable<FloatArray>): void;
  96035. /**
  96036. * Gets the tangent data stored in this target
  96037. * @returns a FloatArray containing the tangent data (or null if not present)
  96038. */
  96039. getTangents(): Nullable<FloatArray>;
  96040. /**
  96041. * Affects texture coordinates data to this target
  96042. * @param data defines the texture coordinates data to use
  96043. */
  96044. setUVs(data: Nullable<FloatArray>): void;
  96045. /**
  96046. * Gets the texture coordinates data stored in this target
  96047. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96048. */
  96049. getUVs(): Nullable<FloatArray>;
  96050. /**
  96051. * Clone the current target
  96052. * @returns a new MorphTarget
  96053. */
  96054. clone(): MorphTarget;
  96055. /**
  96056. * Serializes the current target into a Serialization object
  96057. * @returns the serialized object
  96058. */
  96059. serialize(): any;
  96060. /**
  96061. * Returns the string "MorphTarget"
  96062. * @returns "MorphTarget"
  96063. */
  96064. getClassName(): string;
  96065. /**
  96066. * Creates a new target from serialized data
  96067. * @param serializationObject defines the serialized data to use
  96068. * @returns a new MorphTarget
  96069. */
  96070. static Parse(serializationObject: any): MorphTarget;
  96071. /**
  96072. * Creates a MorphTarget from mesh data
  96073. * @param mesh defines the source mesh
  96074. * @param name defines the name to use for the new target
  96075. * @param influence defines the influence to attach to the target
  96076. * @returns a new MorphTarget
  96077. */
  96078. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96079. }
  96080. }
  96081. declare module BABYLON {
  96082. /**
  96083. * This class is used to deform meshes using morphing between different targets
  96084. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96085. */
  96086. export class MorphTargetManager {
  96087. private _targets;
  96088. private _targetInfluenceChangedObservers;
  96089. private _targetDataLayoutChangedObservers;
  96090. private _activeTargets;
  96091. private _scene;
  96092. private _influences;
  96093. private _supportsNormals;
  96094. private _supportsTangents;
  96095. private _supportsUVs;
  96096. private _vertexCount;
  96097. private _uniqueId;
  96098. private _tempInfluences;
  96099. /**
  96100. * Gets or sets a boolean indicating if normals must be morphed
  96101. */
  96102. enableNormalMorphing: boolean;
  96103. /**
  96104. * Gets or sets a boolean indicating if tangents must be morphed
  96105. */
  96106. enableTangentMorphing: boolean;
  96107. /**
  96108. * Gets or sets a boolean indicating if UV must be morphed
  96109. */
  96110. enableUVMorphing: boolean;
  96111. /**
  96112. * Creates a new MorphTargetManager
  96113. * @param scene defines the current scene
  96114. */
  96115. constructor(scene?: Nullable<Scene>);
  96116. /**
  96117. * Gets the unique ID of this manager
  96118. */
  96119. get uniqueId(): number;
  96120. /**
  96121. * Gets the number of vertices handled by this manager
  96122. */
  96123. get vertexCount(): number;
  96124. /**
  96125. * Gets a boolean indicating if this manager supports morphing of normals
  96126. */
  96127. get supportsNormals(): boolean;
  96128. /**
  96129. * Gets a boolean indicating if this manager supports morphing of tangents
  96130. */
  96131. get supportsTangents(): boolean;
  96132. /**
  96133. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96134. */
  96135. get supportsUVs(): boolean;
  96136. /**
  96137. * Gets the number of targets stored in this manager
  96138. */
  96139. get numTargets(): number;
  96140. /**
  96141. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96142. */
  96143. get numInfluencers(): number;
  96144. /**
  96145. * Gets the list of influences (one per target)
  96146. */
  96147. get influences(): Float32Array;
  96148. /**
  96149. * Gets the active target at specified index. An active target is a target with an influence > 0
  96150. * @param index defines the index to check
  96151. * @returns the requested target
  96152. */
  96153. getActiveTarget(index: number): MorphTarget;
  96154. /**
  96155. * Gets the target at specified index
  96156. * @param index defines the index to check
  96157. * @returns the requested target
  96158. */
  96159. getTarget(index: number): MorphTarget;
  96160. /**
  96161. * Add a new target to this manager
  96162. * @param target defines the target to add
  96163. */
  96164. addTarget(target: MorphTarget): void;
  96165. /**
  96166. * Removes a target from the manager
  96167. * @param target defines the target to remove
  96168. */
  96169. removeTarget(target: MorphTarget): void;
  96170. /**
  96171. * Clone the current manager
  96172. * @returns a new MorphTargetManager
  96173. */
  96174. clone(): MorphTargetManager;
  96175. /**
  96176. * Serializes the current manager into a Serialization object
  96177. * @returns the serialized object
  96178. */
  96179. serialize(): any;
  96180. private _syncActiveTargets;
  96181. /**
  96182. * Syncrhonize the targets with all the meshes using this morph target manager
  96183. */
  96184. synchronize(): void;
  96185. /**
  96186. * Creates a new MorphTargetManager from serialized data
  96187. * @param serializationObject defines the serialized data
  96188. * @param scene defines the hosting scene
  96189. * @returns the new MorphTargetManager
  96190. */
  96191. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96192. }
  96193. }
  96194. declare module BABYLON {
  96195. /**
  96196. * Class used to represent a specific level of detail of a mesh
  96197. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96198. */
  96199. export class MeshLODLevel {
  96200. /** Defines the distance where this level should start being displayed */
  96201. distance: number;
  96202. /** Defines the mesh to use to render this level */
  96203. mesh: Nullable<Mesh>;
  96204. /**
  96205. * Creates a new LOD level
  96206. * @param distance defines the distance where this level should star being displayed
  96207. * @param mesh defines the mesh to use to render this level
  96208. */
  96209. constructor(
  96210. /** Defines the distance where this level should start being displayed */
  96211. distance: number,
  96212. /** Defines the mesh to use to render this level */
  96213. mesh: Nullable<Mesh>);
  96214. }
  96215. }
  96216. declare module BABYLON {
  96217. /**
  96218. * Mesh representing the gorund
  96219. */
  96220. export class GroundMesh extends Mesh {
  96221. /** If octree should be generated */
  96222. generateOctree: boolean;
  96223. private _heightQuads;
  96224. /** @hidden */
  96225. _subdivisionsX: number;
  96226. /** @hidden */
  96227. _subdivisionsY: number;
  96228. /** @hidden */
  96229. _width: number;
  96230. /** @hidden */
  96231. _height: number;
  96232. /** @hidden */
  96233. _minX: number;
  96234. /** @hidden */
  96235. _maxX: number;
  96236. /** @hidden */
  96237. _minZ: number;
  96238. /** @hidden */
  96239. _maxZ: number;
  96240. constructor(name: string, scene: Scene);
  96241. /**
  96242. * "GroundMesh"
  96243. * @returns "GroundMesh"
  96244. */
  96245. getClassName(): string;
  96246. /**
  96247. * The minimum of x and y subdivisions
  96248. */
  96249. get subdivisions(): number;
  96250. /**
  96251. * X subdivisions
  96252. */
  96253. get subdivisionsX(): number;
  96254. /**
  96255. * Y subdivisions
  96256. */
  96257. get subdivisionsY(): number;
  96258. /**
  96259. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96260. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96261. * @param chunksCount the number of subdivisions for x and y
  96262. * @param octreeBlocksSize (Default: 32)
  96263. */
  96264. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96265. /**
  96266. * Returns a height (y) value in the Worl system :
  96267. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96268. * @param x x coordinate
  96269. * @param z z coordinate
  96270. * @returns the ground y position if (x, z) are outside the ground surface.
  96271. */
  96272. getHeightAtCoordinates(x: number, z: number): number;
  96273. /**
  96274. * Returns a normalized vector (Vector3) orthogonal to the ground
  96275. * at the ground coordinates (x, z) expressed in the World system.
  96276. * @param x x coordinate
  96277. * @param z z coordinate
  96278. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96279. */
  96280. getNormalAtCoordinates(x: number, z: number): Vector3;
  96281. /**
  96282. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96283. * at the ground coordinates (x, z) expressed in the World system.
  96284. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96285. * @param x x coordinate
  96286. * @param z z coordinate
  96287. * @param ref vector to store the result
  96288. * @returns the GroundMesh.
  96289. */
  96290. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96291. /**
  96292. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96293. * if the ground has been updated.
  96294. * This can be used in the render loop.
  96295. * @returns the GroundMesh.
  96296. */
  96297. updateCoordinateHeights(): GroundMesh;
  96298. private _getFacetAt;
  96299. private _initHeightQuads;
  96300. private _computeHeightQuads;
  96301. /**
  96302. * Serializes this ground mesh
  96303. * @param serializationObject object to write serialization to
  96304. */
  96305. serialize(serializationObject: any): void;
  96306. /**
  96307. * Parses a serialized ground mesh
  96308. * @param parsedMesh the serialized mesh
  96309. * @param scene the scene to create the ground mesh in
  96310. * @returns the created ground mesh
  96311. */
  96312. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96313. }
  96314. }
  96315. declare module BABYLON {
  96316. /**
  96317. * Interface for Physics-Joint data
  96318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96319. */
  96320. export interface PhysicsJointData {
  96321. /**
  96322. * The main pivot of the joint
  96323. */
  96324. mainPivot?: Vector3;
  96325. /**
  96326. * The connected pivot of the joint
  96327. */
  96328. connectedPivot?: Vector3;
  96329. /**
  96330. * The main axis of the joint
  96331. */
  96332. mainAxis?: Vector3;
  96333. /**
  96334. * The connected axis of the joint
  96335. */
  96336. connectedAxis?: Vector3;
  96337. /**
  96338. * The collision of the joint
  96339. */
  96340. collision?: boolean;
  96341. /**
  96342. * Native Oimo/Cannon/Energy data
  96343. */
  96344. nativeParams?: any;
  96345. }
  96346. /**
  96347. * This is a holder class for the physics joint created by the physics plugin
  96348. * It holds a set of functions to control the underlying joint
  96349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96350. */
  96351. export class PhysicsJoint {
  96352. /**
  96353. * The type of the physics joint
  96354. */
  96355. type: number;
  96356. /**
  96357. * The data for the physics joint
  96358. */
  96359. jointData: PhysicsJointData;
  96360. private _physicsJoint;
  96361. protected _physicsPlugin: IPhysicsEnginePlugin;
  96362. /**
  96363. * Initializes the physics joint
  96364. * @param type The type of the physics joint
  96365. * @param jointData The data for the physics joint
  96366. */
  96367. constructor(
  96368. /**
  96369. * The type of the physics joint
  96370. */
  96371. type: number,
  96372. /**
  96373. * The data for the physics joint
  96374. */
  96375. jointData: PhysicsJointData);
  96376. /**
  96377. * Gets the physics joint
  96378. */
  96379. get physicsJoint(): any;
  96380. /**
  96381. * Sets the physics joint
  96382. */
  96383. set physicsJoint(newJoint: any);
  96384. /**
  96385. * Sets the physics plugin
  96386. */
  96387. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96388. /**
  96389. * Execute a function that is physics-plugin specific.
  96390. * @param {Function} func the function that will be executed.
  96391. * It accepts two parameters: the physics world and the physics joint
  96392. */
  96393. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96394. /**
  96395. * Distance-Joint type
  96396. */
  96397. static DistanceJoint: number;
  96398. /**
  96399. * Hinge-Joint type
  96400. */
  96401. static HingeJoint: number;
  96402. /**
  96403. * Ball-and-Socket joint type
  96404. */
  96405. static BallAndSocketJoint: number;
  96406. /**
  96407. * Wheel-Joint type
  96408. */
  96409. static WheelJoint: number;
  96410. /**
  96411. * Slider-Joint type
  96412. */
  96413. static SliderJoint: number;
  96414. /**
  96415. * Prismatic-Joint type
  96416. */
  96417. static PrismaticJoint: number;
  96418. /**
  96419. * Universal-Joint type
  96420. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96421. */
  96422. static UniversalJoint: number;
  96423. /**
  96424. * Hinge-Joint 2 type
  96425. */
  96426. static Hinge2Joint: number;
  96427. /**
  96428. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96429. */
  96430. static PointToPointJoint: number;
  96431. /**
  96432. * Spring-Joint type
  96433. */
  96434. static SpringJoint: number;
  96435. /**
  96436. * Lock-Joint type
  96437. */
  96438. static LockJoint: number;
  96439. }
  96440. /**
  96441. * A class representing a physics distance joint
  96442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96443. */
  96444. export class DistanceJoint extends PhysicsJoint {
  96445. /**
  96446. *
  96447. * @param jointData The data for the Distance-Joint
  96448. */
  96449. constructor(jointData: DistanceJointData);
  96450. /**
  96451. * Update the predefined distance.
  96452. * @param maxDistance The maximum preferred distance
  96453. * @param minDistance The minimum preferred distance
  96454. */
  96455. updateDistance(maxDistance: number, minDistance?: number): void;
  96456. }
  96457. /**
  96458. * Represents a Motor-Enabled Joint
  96459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96460. */
  96461. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96462. /**
  96463. * Initializes the Motor-Enabled Joint
  96464. * @param type The type of the joint
  96465. * @param jointData The physica joint data for the joint
  96466. */
  96467. constructor(type: number, jointData: PhysicsJointData);
  96468. /**
  96469. * Set the motor values.
  96470. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96471. * @param force the force to apply
  96472. * @param maxForce max force for this motor.
  96473. */
  96474. setMotor(force?: number, maxForce?: number): void;
  96475. /**
  96476. * Set the motor's limits.
  96477. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96478. * @param upperLimit The upper limit of the motor
  96479. * @param lowerLimit The lower limit of the motor
  96480. */
  96481. setLimit(upperLimit: number, lowerLimit?: number): void;
  96482. }
  96483. /**
  96484. * This class represents a single physics Hinge-Joint
  96485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96486. */
  96487. export class HingeJoint extends MotorEnabledJoint {
  96488. /**
  96489. * Initializes the Hinge-Joint
  96490. * @param jointData The joint data for the Hinge-Joint
  96491. */
  96492. constructor(jointData: PhysicsJointData);
  96493. /**
  96494. * Set the motor values.
  96495. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96496. * @param {number} force the force to apply
  96497. * @param {number} maxForce max force for this motor.
  96498. */
  96499. setMotor(force?: number, maxForce?: number): void;
  96500. /**
  96501. * Set the motor's limits.
  96502. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96503. * @param upperLimit The upper limit of the motor
  96504. * @param lowerLimit The lower limit of the motor
  96505. */
  96506. setLimit(upperLimit: number, lowerLimit?: number): void;
  96507. }
  96508. /**
  96509. * This class represents a dual hinge physics joint (same as wheel joint)
  96510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96511. */
  96512. export class Hinge2Joint extends MotorEnabledJoint {
  96513. /**
  96514. * Initializes the Hinge2-Joint
  96515. * @param jointData The joint data for the Hinge2-Joint
  96516. */
  96517. constructor(jointData: PhysicsJointData);
  96518. /**
  96519. * Set the motor values.
  96520. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96521. * @param {number} targetSpeed the speed the motor is to reach
  96522. * @param {number} maxForce max force for this motor.
  96523. * @param {motorIndex} the motor's index, 0 or 1.
  96524. */
  96525. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96526. /**
  96527. * Set the motor limits.
  96528. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96529. * @param {number} upperLimit the upper limit
  96530. * @param {number} lowerLimit lower limit
  96531. * @param {motorIndex} the motor's index, 0 or 1.
  96532. */
  96533. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96534. }
  96535. /**
  96536. * Interface for a motor enabled joint
  96537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96538. */
  96539. export interface IMotorEnabledJoint {
  96540. /**
  96541. * Physics joint
  96542. */
  96543. physicsJoint: any;
  96544. /**
  96545. * Sets the motor of the motor-enabled joint
  96546. * @param force The force of the motor
  96547. * @param maxForce The maximum force of the motor
  96548. * @param motorIndex The index of the motor
  96549. */
  96550. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96551. /**
  96552. * Sets the limit of the motor
  96553. * @param upperLimit The upper limit of the motor
  96554. * @param lowerLimit The lower limit of the motor
  96555. * @param motorIndex The index of the motor
  96556. */
  96557. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96558. }
  96559. /**
  96560. * Joint data for a Distance-Joint
  96561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96562. */
  96563. export interface DistanceJointData extends PhysicsJointData {
  96564. /**
  96565. * Max distance the 2 joint objects can be apart
  96566. */
  96567. maxDistance: number;
  96568. }
  96569. /**
  96570. * Joint data from a spring joint
  96571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96572. */
  96573. export interface SpringJointData extends PhysicsJointData {
  96574. /**
  96575. * Length of the spring
  96576. */
  96577. length: number;
  96578. /**
  96579. * Stiffness of the spring
  96580. */
  96581. stiffness: number;
  96582. /**
  96583. * Damping of the spring
  96584. */
  96585. damping: number;
  96586. /** this callback will be called when applying the force to the impostors. */
  96587. forceApplicationCallback: () => void;
  96588. }
  96589. }
  96590. declare module BABYLON {
  96591. /**
  96592. * Holds the data for the raycast result
  96593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96594. */
  96595. export class PhysicsRaycastResult {
  96596. private _hasHit;
  96597. private _hitDistance;
  96598. private _hitNormalWorld;
  96599. private _hitPointWorld;
  96600. private _rayFromWorld;
  96601. private _rayToWorld;
  96602. /**
  96603. * Gets if there was a hit
  96604. */
  96605. get hasHit(): boolean;
  96606. /**
  96607. * Gets the distance from the hit
  96608. */
  96609. get hitDistance(): number;
  96610. /**
  96611. * Gets the hit normal/direction in the world
  96612. */
  96613. get hitNormalWorld(): Vector3;
  96614. /**
  96615. * Gets the hit point in the world
  96616. */
  96617. get hitPointWorld(): Vector3;
  96618. /**
  96619. * Gets the ray "start point" of the ray in the world
  96620. */
  96621. get rayFromWorld(): Vector3;
  96622. /**
  96623. * Gets the ray "end point" of the ray in the world
  96624. */
  96625. get rayToWorld(): Vector3;
  96626. /**
  96627. * Sets the hit data (normal & point in world space)
  96628. * @param hitNormalWorld defines the normal in world space
  96629. * @param hitPointWorld defines the point in world space
  96630. */
  96631. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96632. /**
  96633. * Sets the distance from the start point to the hit point
  96634. * @param distance
  96635. */
  96636. setHitDistance(distance: number): void;
  96637. /**
  96638. * Calculates the distance manually
  96639. */
  96640. calculateHitDistance(): void;
  96641. /**
  96642. * Resets all the values to default
  96643. * @param from The from point on world space
  96644. * @param to The to point on world space
  96645. */
  96646. reset(from?: Vector3, to?: Vector3): void;
  96647. }
  96648. /**
  96649. * Interface for the size containing width and height
  96650. */
  96651. interface IXYZ {
  96652. /**
  96653. * X
  96654. */
  96655. x: number;
  96656. /**
  96657. * Y
  96658. */
  96659. y: number;
  96660. /**
  96661. * Z
  96662. */
  96663. z: number;
  96664. }
  96665. }
  96666. declare module BABYLON {
  96667. /**
  96668. * Interface used to describe a physics joint
  96669. */
  96670. export interface PhysicsImpostorJoint {
  96671. /** Defines the main impostor to which the joint is linked */
  96672. mainImpostor: PhysicsImpostor;
  96673. /** Defines the impostor that is connected to the main impostor using this joint */
  96674. connectedImpostor: PhysicsImpostor;
  96675. /** Defines the joint itself */
  96676. joint: PhysicsJoint;
  96677. }
  96678. /** @hidden */
  96679. export interface IPhysicsEnginePlugin {
  96680. world: any;
  96681. name: string;
  96682. setGravity(gravity: Vector3): void;
  96683. setTimeStep(timeStep: number): void;
  96684. getTimeStep(): number;
  96685. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96686. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96687. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96688. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96689. removePhysicsBody(impostor: PhysicsImpostor): void;
  96690. generateJoint(joint: PhysicsImpostorJoint): void;
  96691. removeJoint(joint: PhysicsImpostorJoint): void;
  96692. isSupported(): boolean;
  96693. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96694. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96695. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96696. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96697. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96698. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96699. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96700. getBodyMass(impostor: PhysicsImpostor): number;
  96701. getBodyFriction(impostor: PhysicsImpostor): number;
  96702. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96703. getBodyRestitution(impostor: PhysicsImpostor): number;
  96704. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96705. getBodyPressure?(impostor: PhysicsImpostor): number;
  96706. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96707. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96708. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96709. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96710. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96711. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96712. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96713. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96714. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96715. sleepBody(impostor: PhysicsImpostor): void;
  96716. wakeUpBody(impostor: PhysicsImpostor): void;
  96717. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96718. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96719. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96720. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96721. getRadius(impostor: PhysicsImpostor): number;
  96722. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96723. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96724. dispose(): void;
  96725. }
  96726. /**
  96727. * Interface used to define a physics engine
  96728. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96729. */
  96730. export interface IPhysicsEngine {
  96731. /**
  96732. * Gets the gravity vector used by the simulation
  96733. */
  96734. gravity: Vector3;
  96735. /**
  96736. * Sets the gravity vector used by the simulation
  96737. * @param gravity defines the gravity vector to use
  96738. */
  96739. setGravity(gravity: Vector3): void;
  96740. /**
  96741. * Set the time step of the physics engine.
  96742. * Default is 1/60.
  96743. * To slow it down, enter 1/600 for example.
  96744. * To speed it up, 1/30
  96745. * @param newTimeStep the new timestep to apply to this world.
  96746. */
  96747. setTimeStep(newTimeStep: number): void;
  96748. /**
  96749. * Get the time step of the physics engine.
  96750. * @returns the current time step
  96751. */
  96752. getTimeStep(): number;
  96753. /**
  96754. * Set the sub time step of the physics engine.
  96755. * Default is 0 meaning there is no sub steps
  96756. * To increase physics resolution precision, set a small value (like 1 ms)
  96757. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96758. */
  96759. setSubTimeStep(subTimeStep: number): void;
  96760. /**
  96761. * Get the sub time step of the physics engine.
  96762. * @returns the current sub time step
  96763. */
  96764. getSubTimeStep(): number;
  96765. /**
  96766. * Release all resources
  96767. */
  96768. dispose(): void;
  96769. /**
  96770. * Gets the name of the current physics plugin
  96771. * @returns the name of the plugin
  96772. */
  96773. getPhysicsPluginName(): string;
  96774. /**
  96775. * Adding a new impostor for the impostor tracking.
  96776. * This will be done by the impostor itself.
  96777. * @param impostor the impostor to add
  96778. */
  96779. addImpostor(impostor: PhysicsImpostor): void;
  96780. /**
  96781. * Remove an impostor from the engine.
  96782. * This impostor and its mesh will not longer be updated by the physics engine.
  96783. * @param impostor the impostor to remove
  96784. */
  96785. removeImpostor(impostor: PhysicsImpostor): void;
  96786. /**
  96787. * Add a joint to the physics engine
  96788. * @param mainImpostor defines the main impostor to which the joint is added.
  96789. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96790. * @param joint defines the joint that will connect both impostors.
  96791. */
  96792. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96793. /**
  96794. * Removes a joint from the simulation
  96795. * @param mainImpostor defines the impostor used with the joint
  96796. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96797. * @param joint defines the joint to remove
  96798. */
  96799. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96800. /**
  96801. * Gets the current plugin used to run the simulation
  96802. * @returns current plugin
  96803. */
  96804. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96805. /**
  96806. * Gets the list of physic impostors
  96807. * @returns an array of PhysicsImpostor
  96808. */
  96809. getImpostors(): Array<PhysicsImpostor>;
  96810. /**
  96811. * Gets the impostor for a physics enabled object
  96812. * @param object defines the object impersonated by the impostor
  96813. * @returns the PhysicsImpostor or null if not found
  96814. */
  96815. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96816. /**
  96817. * Gets the impostor for a physics body object
  96818. * @param body defines physics body used by the impostor
  96819. * @returns the PhysicsImpostor or null if not found
  96820. */
  96821. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96822. /**
  96823. * Does a raycast in the physics world
  96824. * @param from when should the ray start?
  96825. * @param to when should the ray end?
  96826. * @returns PhysicsRaycastResult
  96827. */
  96828. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96829. /**
  96830. * Called by the scene. No need to call it.
  96831. * @param delta defines the timespam between frames
  96832. */
  96833. _step(delta: number): void;
  96834. }
  96835. }
  96836. declare module BABYLON {
  96837. /**
  96838. * The interface for the physics imposter parameters
  96839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96840. */
  96841. export interface PhysicsImpostorParameters {
  96842. /**
  96843. * The mass of the physics imposter
  96844. */
  96845. mass: number;
  96846. /**
  96847. * The friction of the physics imposter
  96848. */
  96849. friction?: number;
  96850. /**
  96851. * The coefficient of restitution of the physics imposter
  96852. */
  96853. restitution?: number;
  96854. /**
  96855. * The native options of the physics imposter
  96856. */
  96857. nativeOptions?: any;
  96858. /**
  96859. * Specifies if the parent should be ignored
  96860. */
  96861. ignoreParent?: boolean;
  96862. /**
  96863. * Specifies if bi-directional transformations should be disabled
  96864. */
  96865. disableBidirectionalTransformation?: boolean;
  96866. /**
  96867. * The pressure inside the physics imposter, soft object only
  96868. */
  96869. pressure?: number;
  96870. /**
  96871. * The stiffness the physics imposter, soft object only
  96872. */
  96873. stiffness?: number;
  96874. /**
  96875. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96876. */
  96877. velocityIterations?: number;
  96878. /**
  96879. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96880. */
  96881. positionIterations?: number;
  96882. /**
  96883. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96884. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96885. * Add to fix multiple points
  96886. */
  96887. fixedPoints?: number;
  96888. /**
  96889. * The collision margin around a soft object
  96890. */
  96891. margin?: number;
  96892. /**
  96893. * The collision margin around a soft object
  96894. */
  96895. damping?: number;
  96896. /**
  96897. * The path for a rope based on an extrusion
  96898. */
  96899. path?: any;
  96900. /**
  96901. * The shape of an extrusion used for a rope based on an extrusion
  96902. */
  96903. shape?: any;
  96904. }
  96905. /**
  96906. * Interface for a physics-enabled object
  96907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96908. */
  96909. export interface IPhysicsEnabledObject {
  96910. /**
  96911. * The position of the physics-enabled object
  96912. */
  96913. position: Vector3;
  96914. /**
  96915. * The rotation of the physics-enabled object
  96916. */
  96917. rotationQuaternion: Nullable<Quaternion>;
  96918. /**
  96919. * The scale of the physics-enabled object
  96920. */
  96921. scaling: Vector3;
  96922. /**
  96923. * The rotation of the physics-enabled object
  96924. */
  96925. rotation?: Vector3;
  96926. /**
  96927. * The parent of the physics-enabled object
  96928. */
  96929. parent?: any;
  96930. /**
  96931. * The bounding info of the physics-enabled object
  96932. * @returns The bounding info of the physics-enabled object
  96933. */
  96934. getBoundingInfo(): BoundingInfo;
  96935. /**
  96936. * Computes the world matrix
  96937. * @param force Specifies if the world matrix should be computed by force
  96938. * @returns A world matrix
  96939. */
  96940. computeWorldMatrix(force: boolean): Matrix;
  96941. /**
  96942. * Gets the world matrix
  96943. * @returns A world matrix
  96944. */
  96945. getWorldMatrix?(): Matrix;
  96946. /**
  96947. * Gets the child meshes
  96948. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96949. * @returns An array of abstract meshes
  96950. */
  96951. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96952. /**
  96953. * Gets the vertex data
  96954. * @param kind The type of vertex data
  96955. * @returns A nullable array of numbers, or a float32 array
  96956. */
  96957. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96958. /**
  96959. * Gets the indices from the mesh
  96960. * @returns A nullable array of index arrays
  96961. */
  96962. getIndices?(): Nullable<IndicesArray>;
  96963. /**
  96964. * Gets the scene from the mesh
  96965. * @returns the indices array or null
  96966. */
  96967. getScene?(): Scene;
  96968. /**
  96969. * Gets the absolute position from the mesh
  96970. * @returns the absolute position
  96971. */
  96972. getAbsolutePosition(): Vector3;
  96973. /**
  96974. * Gets the absolute pivot point from the mesh
  96975. * @returns the absolute pivot point
  96976. */
  96977. getAbsolutePivotPoint(): Vector3;
  96978. /**
  96979. * Rotates the mesh
  96980. * @param axis The axis of rotation
  96981. * @param amount The amount of rotation
  96982. * @param space The space of the rotation
  96983. * @returns The rotation transform node
  96984. */
  96985. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96986. /**
  96987. * Translates the mesh
  96988. * @param axis The axis of translation
  96989. * @param distance The distance of translation
  96990. * @param space The space of the translation
  96991. * @returns The transform node
  96992. */
  96993. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96994. /**
  96995. * Sets the absolute position of the mesh
  96996. * @param absolutePosition The absolute position of the mesh
  96997. * @returns The transform node
  96998. */
  96999. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  97000. /**
  97001. * Gets the class name of the mesh
  97002. * @returns The class name
  97003. */
  97004. getClassName(): string;
  97005. }
  97006. /**
  97007. * Represents a physics imposter
  97008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97009. */
  97010. export class PhysicsImpostor {
  97011. /**
  97012. * The physics-enabled object used as the physics imposter
  97013. */
  97014. object: IPhysicsEnabledObject;
  97015. /**
  97016. * The type of the physics imposter
  97017. */
  97018. type: number;
  97019. private _options;
  97020. private _scene?;
  97021. /**
  97022. * The default object size of the imposter
  97023. */
  97024. static DEFAULT_OBJECT_SIZE: Vector3;
  97025. /**
  97026. * The identity quaternion of the imposter
  97027. */
  97028. static IDENTITY_QUATERNION: Quaternion;
  97029. /** @hidden */
  97030. _pluginData: any;
  97031. private _physicsEngine;
  97032. private _physicsBody;
  97033. private _bodyUpdateRequired;
  97034. private _onBeforePhysicsStepCallbacks;
  97035. private _onAfterPhysicsStepCallbacks;
  97036. /** @hidden */
  97037. _onPhysicsCollideCallbacks: Array<{
  97038. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97039. otherImpostors: Array<PhysicsImpostor>;
  97040. }>;
  97041. private _deltaPosition;
  97042. private _deltaRotation;
  97043. private _deltaRotationConjugated;
  97044. /** @hidden */
  97045. _isFromLine: boolean;
  97046. private _parent;
  97047. private _isDisposed;
  97048. private static _tmpVecs;
  97049. private static _tmpQuat;
  97050. /**
  97051. * Specifies if the physics imposter is disposed
  97052. */
  97053. get isDisposed(): boolean;
  97054. /**
  97055. * Gets the mass of the physics imposter
  97056. */
  97057. get mass(): number;
  97058. set mass(value: number);
  97059. /**
  97060. * Gets the coefficient of friction
  97061. */
  97062. get friction(): number;
  97063. /**
  97064. * Sets the coefficient of friction
  97065. */
  97066. set friction(value: number);
  97067. /**
  97068. * Gets the coefficient of restitution
  97069. */
  97070. get restitution(): number;
  97071. /**
  97072. * Sets the coefficient of restitution
  97073. */
  97074. set restitution(value: number);
  97075. /**
  97076. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97077. */
  97078. get pressure(): number;
  97079. /**
  97080. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97081. */
  97082. set pressure(value: number);
  97083. /**
  97084. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97085. */
  97086. get stiffness(): number;
  97087. /**
  97088. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97089. */
  97090. set stiffness(value: number);
  97091. /**
  97092. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97093. */
  97094. get velocityIterations(): number;
  97095. /**
  97096. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97097. */
  97098. set velocityIterations(value: number);
  97099. /**
  97100. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97101. */
  97102. get positionIterations(): number;
  97103. /**
  97104. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97105. */
  97106. set positionIterations(value: number);
  97107. /**
  97108. * The unique id of the physics imposter
  97109. * set by the physics engine when adding this impostor to the array
  97110. */
  97111. uniqueId: number;
  97112. /**
  97113. * @hidden
  97114. */
  97115. soft: boolean;
  97116. /**
  97117. * @hidden
  97118. */
  97119. segments: number;
  97120. private _joints;
  97121. /**
  97122. * Initializes the physics imposter
  97123. * @param object The physics-enabled object used as the physics imposter
  97124. * @param type The type of the physics imposter
  97125. * @param _options The options for the physics imposter
  97126. * @param _scene The Babylon scene
  97127. */
  97128. constructor(
  97129. /**
  97130. * The physics-enabled object used as the physics imposter
  97131. */
  97132. object: IPhysicsEnabledObject,
  97133. /**
  97134. * The type of the physics imposter
  97135. */
  97136. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97137. /**
  97138. * This function will completly initialize this impostor.
  97139. * It will create a new body - but only if this mesh has no parent.
  97140. * If it has, this impostor will not be used other than to define the impostor
  97141. * of the child mesh.
  97142. * @hidden
  97143. */
  97144. _init(): void;
  97145. private _getPhysicsParent;
  97146. /**
  97147. * Should a new body be generated.
  97148. * @returns boolean specifying if body initialization is required
  97149. */
  97150. isBodyInitRequired(): boolean;
  97151. /**
  97152. * Sets the updated scaling
  97153. * @param updated Specifies if the scaling is updated
  97154. */
  97155. setScalingUpdated(): void;
  97156. /**
  97157. * Force a regeneration of this or the parent's impostor's body.
  97158. * Use under cautious - This will remove all joints already implemented.
  97159. */
  97160. forceUpdate(): void;
  97161. /**
  97162. * Gets the body that holds this impostor. Either its own, or its parent.
  97163. */
  97164. get physicsBody(): any;
  97165. /**
  97166. * Get the parent of the physics imposter
  97167. * @returns Physics imposter or null
  97168. */
  97169. get parent(): Nullable<PhysicsImpostor>;
  97170. /**
  97171. * Sets the parent of the physics imposter
  97172. */
  97173. set parent(value: Nullable<PhysicsImpostor>);
  97174. /**
  97175. * Set the physics body. Used mainly by the physics engine/plugin
  97176. */
  97177. set physicsBody(physicsBody: any);
  97178. /**
  97179. * Resets the update flags
  97180. */
  97181. resetUpdateFlags(): void;
  97182. /**
  97183. * Gets the object extend size
  97184. * @returns the object extend size
  97185. */
  97186. getObjectExtendSize(): Vector3;
  97187. /**
  97188. * Gets the object center
  97189. * @returns The object center
  97190. */
  97191. getObjectCenter(): Vector3;
  97192. /**
  97193. * Get a specific parameter from the options parameters
  97194. * @param paramName The object parameter name
  97195. * @returns The object parameter
  97196. */
  97197. getParam(paramName: string): any;
  97198. /**
  97199. * Sets a specific parameter in the options given to the physics plugin
  97200. * @param paramName The parameter name
  97201. * @param value The value of the parameter
  97202. */
  97203. setParam(paramName: string, value: number): void;
  97204. /**
  97205. * Specifically change the body's mass option. Won't recreate the physics body object
  97206. * @param mass The mass of the physics imposter
  97207. */
  97208. setMass(mass: number): void;
  97209. /**
  97210. * Gets the linear velocity
  97211. * @returns linear velocity or null
  97212. */
  97213. getLinearVelocity(): Nullable<Vector3>;
  97214. /**
  97215. * Sets the linear velocity
  97216. * @param velocity linear velocity or null
  97217. */
  97218. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97219. /**
  97220. * Gets the angular velocity
  97221. * @returns angular velocity or null
  97222. */
  97223. getAngularVelocity(): Nullable<Vector3>;
  97224. /**
  97225. * Sets the angular velocity
  97226. * @param velocity The velocity or null
  97227. */
  97228. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97229. /**
  97230. * Execute a function with the physics plugin native code
  97231. * Provide a function the will have two variables - the world object and the physics body object
  97232. * @param func The function to execute with the physics plugin native code
  97233. */
  97234. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97235. /**
  97236. * Register a function that will be executed before the physics world is stepping forward
  97237. * @param func The function to execute before the physics world is stepped forward
  97238. */
  97239. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97240. /**
  97241. * Unregister a function that will be executed before the physics world is stepping forward
  97242. * @param func The function to execute before the physics world is stepped forward
  97243. */
  97244. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97245. /**
  97246. * Register a function that will be executed after the physics step
  97247. * @param func The function to execute after physics step
  97248. */
  97249. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97250. /**
  97251. * Unregisters a function that will be executed after the physics step
  97252. * @param func The function to execute after physics step
  97253. */
  97254. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97255. /**
  97256. * register a function that will be executed when this impostor collides against a different body
  97257. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97258. * @param func Callback that is executed on collision
  97259. */
  97260. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97261. /**
  97262. * Unregisters the physics imposter on contact
  97263. * @param collideAgainst The physics object to collide against
  97264. * @param func Callback to execute on collision
  97265. */
  97266. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97267. private _tmpQuat;
  97268. private _tmpQuat2;
  97269. /**
  97270. * Get the parent rotation
  97271. * @returns The parent rotation
  97272. */
  97273. getParentsRotation(): Quaternion;
  97274. /**
  97275. * this function is executed by the physics engine.
  97276. */
  97277. beforeStep: () => void;
  97278. /**
  97279. * this function is executed by the physics engine
  97280. */
  97281. afterStep: () => void;
  97282. /**
  97283. * Legacy collision detection event support
  97284. */
  97285. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97286. /**
  97287. * event and body object due to cannon's event-based architecture.
  97288. */
  97289. onCollide: (e: {
  97290. body: any;
  97291. }) => void;
  97292. /**
  97293. * Apply a force
  97294. * @param force The force to apply
  97295. * @param contactPoint The contact point for the force
  97296. * @returns The physics imposter
  97297. */
  97298. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97299. /**
  97300. * Apply an impulse
  97301. * @param force The impulse force
  97302. * @param contactPoint The contact point for the impulse force
  97303. * @returns The physics imposter
  97304. */
  97305. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97306. /**
  97307. * A help function to create a joint
  97308. * @param otherImpostor A physics imposter used to create a joint
  97309. * @param jointType The type of joint
  97310. * @param jointData The data for the joint
  97311. * @returns The physics imposter
  97312. */
  97313. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97314. /**
  97315. * Add a joint to this impostor with a different impostor
  97316. * @param otherImpostor A physics imposter used to add a joint
  97317. * @param joint The joint to add
  97318. * @returns The physics imposter
  97319. */
  97320. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97321. /**
  97322. * Add an anchor to a cloth impostor
  97323. * @param otherImpostor rigid impostor to anchor to
  97324. * @param width ratio across width from 0 to 1
  97325. * @param height ratio up height from 0 to 1
  97326. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97327. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97328. * @returns impostor the soft imposter
  97329. */
  97330. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97331. /**
  97332. * Add a hook to a rope impostor
  97333. * @param otherImpostor rigid impostor to anchor to
  97334. * @param length ratio across rope from 0 to 1
  97335. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97336. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97337. * @returns impostor the rope imposter
  97338. */
  97339. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97340. /**
  97341. * Will keep this body still, in a sleep mode.
  97342. * @returns the physics imposter
  97343. */
  97344. sleep(): PhysicsImpostor;
  97345. /**
  97346. * Wake the body up.
  97347. * @returns The physics imposter
  97348. */
  97349. wakeUp(): PhysicsImpostor;
  97350. /**
  97351. * Clones the physics imposter
  97352. * @param newObject The physics imposter clones to this physics-enabled object
  97353. * @returns A nullable physics imposter
  97354. */
  97355. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97356. /**
  97357. * Disposes the physics imposter
  97358. */
  97359. dispose(): void;
  97360. /**
  97361. * Sets the delta position
  97362. * @param position The delta position amount
  97363. */
  97364. setDeltaPosition(position: Vector3): void;
  97365. /**
  97366. * Sets the delta rotation
  97367. * @param rotation The delta rotation amount
  97368. */
  97369. setDeltaRotation(rotation: Quaternion): void;
  97370. /**
  97371. * Gets the box size of the physics imposter and stores the result in the input parameter
  97372. * @param result Stores the box size
  97373. * @returns The physics imposter
  97374. */
  97375. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97376. /**
  97377. * Gets the radius of the physics imposter
  97378. * @returns Radius of the physics imposter
  97379. */
  97380. getRadius(): number;
  97381. /**
  97382. * Sync a bone with this impostor
  97383. * @param bone The bone to sync to the impostor.
  97384. * @param boneMesh The mesh that the bone is influencing.
  97385. * @param jointPivot The pivot of the joint / bone in local space.
  97386. * @param distToJoint Optional distance from the impostor to the joint.
  97387. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97388. */
  97389. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97390. /**
  97391. * Sync impostor to a bone
  97392. * @param bone The bone that the impostor will be synced to.
  97393. * @param boneMesh The mesh that the bone is influencing.
  97394. * @param jointPivot The pivot of the joint / bone in local space.
  97395. * @param distToJoint Optional distance from the impostor to the joint.
  97396. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97397. * @param boneAxis Optional vector3 axis the bone is aligned with
  97398. */
  97399. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97400. /**
  97401. * No-Imposter type
  97402. */
  97403. static NoImpostor: number;
  97404. /**
  97405. * Sphere-Imposter type
  97406. */
  97407. static SphereImpostor: number;
  97408. /**
  97409. * Box-Imposter type
  97410. */
  97411. static BoxImpostor: number;
  97412. /**
  97413. * Plane-Imposter type
  97414. */
  97415. static PlaneImpostor: number;
  97416. /**
  97417. * Mesh-imposter type
  97418. */
  97419. static MeshImpostor: number;
  97420. /**
  97421. * Capsule-Impostor type (Ammo.js plugin only)
  97422. */
  97423. static CapsuleImpostor: number;
  97424. /**
  97425. * Cylinder-Imposter type
  97426. */
  97427. static CylinderImpostor: number;
  97428. /**
  97429. * Particle-Imposter type
  97430. */
  97431. static ParticleImpostor: number;
  97432. /**
  97433. * Heightmap-Imposter type
  97434. */
  97435. static HeightmapImpostor: number;
  97436. /**
  97437. * ConvexHull-Impostor type (Ammo.js plugin only)
  97438. */
  97439. static ConvexHullImpostor: number;
  97440. /**
  97441. * Custom-Imposter type (Ammo.js plugin only)
  97442. */
  97443. static CustomImpostor: number;
  97444. /**
  97445. * Rope-Imposter type
  97446. */
  97447. static RopeImpostor: number;
  97448. /**
  97449. * Cloth-Imposter type
  97450. */
  97451. static ClothImpostor: number;
  97452. /**
  97453. * Softbody-Imposter type
  97454. */
  97455. static SoftbodyImpostor: number;
  97456. }
  97457. }
  97458. declare module BABYLON {
  97459. /**
  97460. * @hidden
  97461. **/
  97462. export class _CreationDataStorage {
  97463. closePath?: boolean;
  97464. closeArray?: boolean;
  97465. idx: number[];
  97466. dashSize: number;
  97467. gapSize: number;
  97468. path3D: Path3D;
  97469. pathArray: Vector3[][];
  97470. arc: number;
  97471. radius: number;
  97472. cap: number;
  97473. tessellation: number;
  97474. }
  97475. /**
  97476. * @hidden
  97477. **/
  97478. class _InstanceDataStorage {
  97479. visibleInstances: any;
  97480. batchCache: _InstancesBatch;
  97481. instancesBufferSize: number;
  97482. instancesBuffer: Nullable<Buffer>;
  97483. instancesData: Float32Array;
  97484. overridenInstanceCount: number;
  97485. isFrozen: boolean;
  97486. previousBatch: Nullable<_InstancesBatch>;
  97487. hardwareInstancedRendering: boolean;
  97488. sideOrientation: number;
  97489. manualUpdate: boolean;
  97490. }
  97491. /**
  97492. * @hidden
  97493. **/
  97494. export class _InstancesBatch {
  97495. mustReturn: boolean;
  97496. visibleInstances: Nullable<InstancedMesh[]>[];
  97497. renderSelf: boolean[];
  97498. hardwareInstancedRendering: boolean[];
  97499. }
  97500. /**
  97501. * Class used to represent renderable models
  97502. */
  97503. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97504. /**
  97505. * Mesh side orientation : usually the external or front surface
  97506. */
  97507. static readonly FRONTSIDE: number;
  97508. /**
  97509. * Mesh side orientation : usually the internal or back surface
  97510. */
  97511. static readonly BACKSIDE: number;
  97512. /**
  97513. * Mesh side orientation : both internal and external or front and back surfaces
  97514. */
  97515. static readonly DOUBLESIDE: number;
  97516. /**
  97517. * Mesh side orientation : by default, `FRONTSIDE`
  97518. */
  97519. static readonly DEFAULTSIDE: number;
  97520. /**
  97521. * Mesh cap setting : no cap
  97522. */
  97523. static readonly NO_CAP: number;
  97524. /**
  97525. * Mesh cap setting : one cap at the beginning of the mesh
  97526. */
  97527. static readonly CAP_START: number;
  97528. /**
  97529. * Mesh cap setting : one cap at the end of the mesh
  97530. */
  97531. static readonly CAP_END: number;
  97532. /**
  97533. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97534. */
  97535. static readonly CAP_ALL: number;
  97536. /**
  97537. * Mesh pattern setting : no flip or rotate
  97538. */
  97539. static readonly NO_FLIP: number;
  97540. /**
  97541. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97542. */
  97543. static readonly FLIP_TILE: number;
  97544. /**
  97545. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97546. */
  97547. static readonly ROTATE_TILE: number;
  97548. /**
  97549. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97550. */
  97551. static readonly FLIP_ROW: number;
  97552. /**
  97553. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97554. */
  97555. static readonly ROTATE_ROW: number;
  97556. /**
  97557. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97558. */
  97559. static readonly FLIP_N_ROTATE_TILE: number;
  97560. /**
  97561. * Mesh pattern setting : rotate pattern and rotate
  97562. */
  97563. static readonly FLIP_N_ROTATE_ROW: number;
  97564. /**
  97565. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97566. */
  97567. static readonly CENTER: number;
  97568. /**
  97569. * Mesh tile positioning : part tiles on left
  97570. */
  97571. static readonly LEFT: number;
  97572. /**
  97573. * Mesh tile positioning : part tiles on right
  97574. */
  97575. static readonly RIGHT: number;
  97576. /**
  97577. * Mesh tile positioning : part tiles on top
  97578. */
  97579. static readonly TOP: number;
  97580. /**
  97581. * Mesh tile positioning : part tiles on bottom
  97582. */
  97583. static readonly BOTTOM: number;
  97584. /**
  97585. * Gets the default side orientation.
  97586. * @param orientation the orientation to value to attempt to get
  97587. * @returns the default orientation
  97588. * @hidden
  97589. */
  97590. static _GetDefaultSideOrientation(orientation?: number): number;
  97591. private _internalMeshDataInfo;
  97592. /**
  97593. * An event triggered before rendering the mesh
  97594. */
  97595. get onBeforeRenderObservable(): Observable<Mesh>;
  97596. /**
  97597. * An event triggered before binding the mesh
  97598. */
  97599. get onBeforeBindObservable(): Observable<Mesh>;
  97600. /**
  97601. * An event triggered after rendering the mesh
  97602. */
  97603. get onAfterRenderObservable(): Observable<Mesh>;
  97604. /**
  97605. * An event triggered before drawing the mesh
  97606. */
  97607. get onBeforeDrawObservable(): Observable<Mesh>;
  97608. private _onBeforeDrawObserver;
  97609. /**
  97610. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97611. */
  97612. set onBeforeDraw(callback: () => void);
  97613. get hasInstances(): boolean;
  97614. /**
  97615. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97616. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97617. */
  97618. delayLoadState: number;
  97619. /**
  97620. * Gets the list of instances created from this mesh
  97621. * it is not supposed to be modified manually.
  97622. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97623. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97624. */
  97625. instances: InstancedMesh[];
  97626. /**
  97627. * Gets the file containing delay loading data for this mesh
  97628. */
  97629. delayLoadingFile: string;
  97630. /** @hidden */
  97631. _binaryInfo: any;
  97632. /**
  97633. * User defined function used to change how LOD level selection is done
  97634. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97635. */
  97636. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97637. /**
  97638. * Gets or sets the morph target manager
  97639. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97640. */
  97641. get morphTargetManager(): Nullable<MorphTargetManager>;
  97642. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97643. /** @hidden */
  97644. _creationDataStorage: Nullable<_CreationDataStorage>;
  97645. /** @hidden */
  97646. _geometry: Nullable<Geometry>;
  97647. /** @hidden */
  97648. _delayInfo: Array<string>;
  97649. /** @hidden */
  97650. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97651. /** @hidden */
  97652. _instanceDataStorage: _InstanceDataStorage;
  97653. private _effectiveMaterial;
  97654. /** @hidden */
  97655. _shouldGenerateFlatShading: boolean;
  97656. /** @hidden */
  97657. _originalBuilderSideOrientation: number;
  97658. /**
  97659. * Use this property to change the original side orientation defined at construction time
  97660. */
  97661. overrideMaterialSideOrientation: Nullable<number>;
  97662. /**
  97663. * Gets the source mesh (the one used to clone this one from)
  97664. */
  97665. get source(): Nullable<Mesh>;
  97666. /**
  97667. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97668. */
  97669. get isUnIndexed(): boolean;
  97670. set isUnIndexed(value: boolean);
  97671. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97672. get worldMatrixInstancedBuffer(): Float32Array;
  97673. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97674. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97675. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97676. /**
  97677. * @constructor
  97678. * @param name The value used by scene.getMeshByName() to do a lookup.
  97679. * @param scene The scene to add this mesh to.
  97680. * @param parent The parent of this mesh, if it has one
  97681. * @param source An optional Mesh from which geometry is shared, cloned.
  97682. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97683. * When false, achieved by calling a clone(), also passing False.
  97684. * This will make creation of children, recursive.
  97685. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97686. */
  97687. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97688. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97689. doNotInstantiate: boolean;
  97690. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97691. /**
  97692. * Gets the class name
  97693. * @returns the string "Mesh".
  97694. */
  97695. getClassName(): string;
  97696. /** @hidden */
  97697. get _isMesh(): boolean;
  97698. /**
  97699. * Returns a description of this mesh
  97700. * @param fullDetails define if full details about this mesh must be used
  97701. * @returns a descriptive string representing this mesh
  97702. */
  97703. toString(fullDetails?: boolean): string;
  97704. /** @hidden */
  97705. _unBindEffect(): void;
  97706. /**
  97707. * Gets a boolean indicating if this mesh has LOD
  97708. */
  97709. get hasLODLevels(): boolean;
  97710. /**
  97711. * Gets the list of MeshLODLevel associated with the current mesh
  97712. * @returns an array of MeshLODLevel
  97713. */
  97714. getLODLevels(): MeshLODLevel[];
  97715. private _sortLODLevels;
  97716. /**
  97717. * Add a mesh as LOD level triggered at the given distance.
  97718. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97719. * @param distance The distance from the center of the object to show this level
  97720. * @param mesh The mesh to be added as LOD level (can be null)
  97721. * @return This mesh (for chaining)
  97722. */
  97723. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97724. /**
  97725. * Returns the LOD level mesh at the passed distance or null if not found.
  97726. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97727. * @param distance The distance from the center of the object to show this level
  97728. * @returns a Mesh or `null`
  97729. */
  97730. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97731. /**
  97732. * Remove a mesh from the LOD array
  97733. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97734. * @param mesh defines the mesh to be removed
  97735. * @return This mesh (for chaining)
  97736. */
  97737. removeLODLevel(mesh: Mesh): Mesh;
  97738. /**
  97739. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97740. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97741. * @param camera defines the camera to use to compute distance
  97742. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97743. * @return This mesh (for chaining)
  97744. */
  97745. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97746. /**
  97747. * Gets the mesh internal Geometry object
  97748. */
  97749. get geometry(): Nullable<Geometry>;
  97750. /**
  97751. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97752. * @returns the total number of vertices
  97753. */
  97754. getTotalVertices(): number;
  97755. /**
  97756. * Returns the content of an associated vertex buffer
  97757. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97758. * - VertexBuffer.PositionKind
  97759. * - VertexBuffer.UVKind
  97760. * - VertexBuffer.UV2Kind
  97761. * - VertexBuffer.UV3Kind
  97762. * - VertexBuffer.UV4Kind
  97763. * - VertexBuffer.UV5Kind
  97764. * - VertexBuffer.UV6Kind
  97765. * - VertexBuffer.ColorKind
  97766. * - VertexBuffer.MatricesIndicesKind
  97767. * - VertexBuffer.MatricesIndicesExtraKind
  97768. * - VertexBuffer.MatricesWeightsKind
  97769. * - VertexBuffer.MatricesWeightsExtraKind
  97770. * @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
  97771. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97772. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97773. */
  97774. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97775. /**
  97776. * Returns the mesh VertexBuffer object from the requested `kind`
  97777. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97778. * - VertexBuffer.PositionKind
  97779. * - VertexBuffer.NormalKind
  97780. * - VertexBuffer.UVKind
  97781. * - VertexBuffer.UV2Kind
  97782. * - VertexBuffer.UV3Kind
  97783. * - VertexBuffer.UV4Kind
  97784. * - VertexBuffer.UV5Kind
  97785. * - VertexBuffer.UV6Kind
  97786. * - VertexBuffer.ColorKind
  97787. * - VertexBuffer.MatricesIndicesKind
  97788. * - VertexBuffer.MatricesIndicesExtraKind
  97789. * - VertexBuffer.MatricesWeightsKind
  97790. * - VertexBuffer.MatricesWeightsExtraKind
  97791. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97792. */
  97793. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97794. /**
  97795. * Tests if a specific vertex buffer is associated with this mesh
  97796. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97797. * - VertexBuffer.PositionKind
  97798. * - VertexBuffer.NormalKind
  97799. * - VertexBuffer.UVKind
  97800. * - VertexBuffer.UV2Kind
  97801. * - VertexBuffer.UV3Kind
  97802. * - VertexBuffer.UV4Kind
  97803. * - VertexBuffer.UV5Kind
  97804. * - VertexBuffer.UV6Kind
  97805. * - VertexBuffer.ColorKind
  97806. * - VertexBuffer.MatricesIndicesKind
  97807. * - VertexBuffer.MatricesIndicesExtraKind
  97808. * - VertexBuffer.MatricesWeightsKind
  97809. * - VertexBuffer.MatricesWeightsExtraKind
  97810. * @returns a boolean
  97811. */
  97812. isVerticesDataPresent(kind: string): boolean;
  97813. /**
  97814. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97815. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97816. * - VertexBuffer.PositionKind
  97817. * - VertexBuffer.UVKind
  97818. * - VertexBuffer.UV2Kind
  97819. * - VertexBuffer.UV3Kind
  97820. * - VertexBuffer.UV4Kind
  97821. * - VertexBuffer.UV5Kind
  97822. * - VertexBuffer.UV6Kind
  97823. * - VertexBuffer.ColorKind
  97824. * - VertexBuffer.MatricesIndicesKind
  97825. * - VertexBuffer.MatricesIndicesExtraKind
  97826. * - VertexBuffer.MatricesWeightsKind
  97827. * - VertexBuffer.MatricesWeightsExtraKind
  97828. * @returns a boolean
  97829. */
  97830. isVertexBufferUpdatable(kind: string): boolean;
  97831. /**
  97832. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97833. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97834. * - VertexBuffer.PositionKind
  97835. * - VertexBuffer.NormalKind
  97836. * - VertexBuffer.UVKind
  97837. * - VertexBuffer.UV2Kind
  97838. * - VertexBuffer.UV3Kind
  97839. * - VertexBuffer.UV4Kind
  97840. * - VertexBuffer.UV5Kind
  97841. * - VertexBuffer.UV6Kind
  97842. * - VertexBuffer.ColorKind
  97843. * - VertexBuffer.MatricesIndicesKind
  97844. * - VertexBuffer.MatricesIndicesExtraKind
  97845. * - VertexBuffer.MatricesWeightsKind
  97846. * - VertexBuffer.MatricesWeightsExtraKind
  97847. * @returns an array of strings
  97848. */
  97849. getVerticesDataKinds(): string[];
  97850. /**
  97851. * Returns a positive integer : the total number of indices in this mesh geometry.
  97852. * @returns the numner of indices or zero if the mesh has no geometry.
  97853. */
  97854. getTotalIndices(): number;
  97855. /**
  97856. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97857. * @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.
  97858. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97859. * @returns the indices array or an empty array if the mesh has no geometry
  97860. */
  97861. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97862. get isBlocked(): boolean;
  97863. /**
  97864. * Determine if the current mesh is ready to be rendered
  97865. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97866. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97867. * @returns true if all associated assets are ready (material, textures, shaders)
  97868. */
  97869. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97870. /**
  97871. * 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.
  97872. */
  97873. get areNormalsFrozen(): boolean;
  97874. /**
  97875. * 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.
  97876. * @returns the current mesh
  97877. */
  97878. freezeNormals(): Mesh;
  97879. /**
  97880. * 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
  97881. * @returns the current mesh
  97882. */
  97883. unfreezeNormals(): Mesh;
  97884. /**
  97885. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97886. */
  97887. set overridenInstanceCount(count: number);
  97888. /** @hidden */
  97889. _preActivate(): Mesh;
  97890. /** @hidden */
  97891. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97892. /** @hidden */
  97893. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97894. /**
  97895. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97896. * This means the mesh underlying bounding box and sphere are recomputed.
  97897. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97898. * @returns the current mesh
  97899. */
  97900. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97901. /** @hidden */
  97902. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97903. /**
  97904. * This function will subdivide the mesh into multiple submeshes
  97905. * @param count defines the expected number of submeshes
  97906. */
  97907. subdivide(count: number): void;
  97908. /**
  97909. * Copy a FloatArray into a specific associated vertex buffer
  97910. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97911. * - VertexBuffer.PositionKind
  97912. * - VertexBuffer.UVKind
  97913. * - VertexBuffer.UV2Kind
  97914. * - VertexBuffer.UV3Kind
  97915. * - VertexBuffer.UV4Kind
  97916. * - VertexBuffer.UV5Kind
  97917. * - VertexBuffer.UV6Kind
  97918. * - VertexBuffer.ColorKind
  97919. * - VertexBuffer.MatricesIndicesKind
  97920. * - VertexBuffer.MatricesIndicesExtraKind
  97921. * - VertexBuffer.MatricesWeightsKind
  97922. * - VertexBuffer.MatricesWeightsExtraKind
  97923. * @param data defines the data source
  97924. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97925. * @param stride defines the data stride size (can be null)
  97926. * @returns the current mesh
  97927. */
  97928. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97929. /**
  97930. * Delete a vertex buffer associated with this mesh
  97931. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97932. * - VertexBuffer.PositionKind
  97933. * - VertexBuffer.UVKind
  97934. * - VertexBuffer.UV2Kind
  97935. * - VertexBuffer.UV3Kind
  97936. * - VertexBuffer.UV4Kind
  97937. * - VertexBuffer.UV5Kind
  97938. * - VertexBuffer.UV6Kind
  97939. * - VertexBuffer.ColorKind
  97940. * - VertexBuffer.MatricesIndicesKind
  97941. * - VertexBuffer.MatricesIndicesExtraKind
  97942. * - VertexBuffer.MatricesWeightsKind
  97943. * - VertexBuffer.MatricesWeightsExtraKind
  97944. */
  97945. removeVerticesData(kind: string): void;
  97946. /**
  97947. * Flags an associated vertex buffer as updatable
  97948. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97949. * - VertexBuffer.PositionKind
  97950. * - VertexBuffer.UVKind
  97951. * - VertexBuffer.UV2Kind
  97952. * - VertexBuffer.UV3Kind
  97953. * - VertexBuffer.UV4Kind
  97954. * - VertexBuffer.UV5Kind
  97955. * - VertexBuffer.UV6Kind
  97956. * - VertexBuffer.ColorKind
  97957. * - VertexBuffer.MatricesIndicesKind
  97958. * - VertexBuffer.MatricesIndicesExtraKind
  97959. * - VertexBuffer.MatricesWeightsKind
  97960. * - VertexBuffer.MatricesWeightsExtraKind
  97961. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97962. */
  97963. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97964. /**
  97965. * Sets the mesh global Vertex Buffer
  97966. * @param buffer defines the buffer to use
  97967. * @returns the current mesh
  97968. */
  97969. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97970. /**
  97971. * Update a specific associated vertex buffer
  97972. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97973. * - VertexBuffer.PositionKind
  97974. * - VertexBuffer.UVKind
  97975. * - VertexBuffer.UV2Kind
  97976. * - VertexBuffer.UV3Kind
  97977. * - VertexBuffer.UV4Kind
  97978. * - VertexBuffer.UV5Kind
  97979. * - VertexBuffer.UV6Kind
  97980. * - VertexBuffer.ColorKind
  97981. * - VertexBuffer.MatricesIndicesKind
  97982. * - VertexBuffer.MatricesIndicesExtraKind
  97983. * - VertexBuffer.MatricesWeightsKind
  97984. * - VertexBuffer.MatricesWeightsExtraKind
  97985. * @param data defines the data source
  97986. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97987. * @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)
  97988. * @returns the current mesh
  97989. */
  97990. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97991. /**
  97992. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97993. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97994. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97995. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97996. * @returns the current mesh
  97997. */
  97998. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97999. /**
  98000. * Creates a un-shared specific occurence of the geometry for the mesh.
  98001. * @returns the current mesh
  98002. */
  98003. makeGeometryUnique(): Mesh;
  98004. /**
  98005. * Set the index buffer of this mesh
  98006. * @param indices defines the source data
  98007. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  98008. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  98009. * @returns the current mesh
  98010. */
  98011. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98012. /**
  98013. * Update the current index buffer
  98014. * @param indices defines the source data
  98015. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98016. * @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)
  98017. * @returns the current mesh
  98018. */
  98019. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98020. /**
  98021. * Invert the geometry to move from a right handed system to a left handed one.
  98022. * @returns the current mesh
  98023. */
  98024. toLeftHanded(): Mesh;
  98025. /** @hidden */
  98026. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98027. /** @hidden */
  98028. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98029. /**
  98030. * Registers for this mesh a javascript function called just before the rendering process
  98031. * @param func defines the function to call before rendering this mesh
  98032. * @returns the current mesh
  98033. */
  98034. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98035. /**
  98036. * Disposes a previously registered javascript function called before the rendering
  98037. * @param func defines the function to remove
  98038. * @returns the current mesh
  98039. */
  98040. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98041. /**
  98042. * Registers for this mesh a javascript function called just after the rendering is complete
  98043. * @param func defines the function to call after rendering this mesh
  98044. * @returns the current mesh
  98045. */
  98046. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98047. /**
  98048. * Disposes a previously registered javascript function called after the rendering.
  98049. * @param func defines the function to remove
  98050. * @returns the current mesh
  98051. */
  98052. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98053. /** @hidden */
  98054. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98055. /** @hidden */
  98056. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98057. /** @hidden */
  98058. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98059. /** @hidden */
  98060. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98061. /** @hidden */
  98062. _rebuild(): void;
  98063. /** @hidden */
  98064. _freeze(): void;
  98065. /** @hidden */
  98066. _unFreeze(): void;
  98067. /**
  98068. * 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
  98069. * @param subMesh defines the subMesh to render
  98070. * @param enableAlphaMode defines if alpha mode can be changed
  98071. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98072. * @returns the current mesh
  98073. */
  98074. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98075. private _onBeforeDraw;
  98076. /**
  98077. * Renormalize the mesh and patch it up if there are no weights
  98078. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98079. * However in the case of zero weights then we set just a single influence to 1.
  98080. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98081. */
  98082. cleanMatrixWeights(): void;
  98083. private normalizeSkinFourWeights;
  98084. private normalizeSkinWeightsAndExtra;
  98085. /**
  98086. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98087. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98088. * the user know there was an issue with importing the mesh
  98089. * @returns a validation object with skinned, valid and report string
  98090. */
  98091. validateSkinning(): {
  98092. skinned: boolean;
  98093. valid: boolean;
  98094. report: string;
  98095. };
  98096. /** @hidden */
  98097. _checkDelayState(): Mesh;
  98098. private _queueLoad;
  98099. /**
  98100. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98101. * A mesh is in the frustum if its bounding box intersects the frustum
  98102. * @param frustumPlanes defines the frustum to test
  98103. * @returns true if the mesh is in the frustum planes
  98104. */
  98105. isInFrustum(frustumPlanes: Plane[]): boolean;
  98106. /**
  98107. * Sets the mesh material by the material or multiMaterial `id` property
  98108. * @param id is a string identifying the material or the multiMaterial
  98109. * @returns the current mesh
  98110. */
  98111. setMaterialByID(id: string): Mesh;
  98112. /**
  98113. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98114. * @returns an array of IAnimatable
  98115. */
  98116. getAnimatables(): IAnimatable[];
  98117. /**
  98118. * Modifies the mesh geometry according to the passed transformation matrix.
  98119. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98120. * The mesh normals are modified using the same transformation.
  98121. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98122. * @param transform defines the transform matrix to use
  98123. * @see http://doc.babylonjs.com/resources/baking_transformations
  98124. * @returns the current mesh
  98125. */
  98126. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98127. /**
  98128. * Modifies the mesh geometry according to its own current World Matrix.
  98129. * The mesh World Matrix is then reset.
  98130. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98131. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98132. * @see http://doc.babylonjs.com/resources/baking_transformations
  98133. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98134. * @returns the current mesh
  98135. */
  98136. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98137. /** @hidden */
  98138. get _positions(): Nullable<Vector3[]>;
  98139. /** @hidden */
  98140. _resetPointsArrayCache(): Mesh;
  98141. /** @hidden */
  98142. _generatePointsArray(): boolean;
  98143. /**
  98144. * Returns a new Mesh object generated from the current mesh properties.
  98145. * This method must not get confused with createInstance()
  98146. * @param name is a string, the name given to the new mesh
  98147. * @param newParent can be any Node object (default `null`)
  98148. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98149. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98150. * @returns a new mesh
  98151. */
  98152. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98153. /**
  98154. * Releases resources associated with this mesh.
  98155. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98156. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98157. */
  98158. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98159. /** @hidden */
  98160. _disposeInstanceSpecificData(): void;
  98161. /**
  98162. * Modifies the mesh geometry according to a displacement map.
  98163. * 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.
  98164. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98165. * @param url is a string, the URL from the image file is to be downloaded.
  98166. * @param minHeight is the lower limit of the displacement.
  98167. * @param maxHeight is the upper limit of the displacement.
  98168. * @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.
  98169. * @param uvOffset is an optional vector2 used to offset UV.
  98170. * @param uvScale is an optional vector2 used to scale UV.
  98171. * @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.
  98172. * @returns the Mesh.
  98173. */
  98174. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98175. /**
  98176. * Modifies the mesh geometry according to a displacementMap buffer.
  98177. * 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.
  98178. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98179. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98180. * @param heightMapWidth is the width of the buffer image.
  98181. * @param heightMapHeight is the height of the buffer image.
  98182. * @param minHeight is the lower limit of the displacement.
  98183. * @param maxHeight is the upper limit of the displacement.
  98184. * @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.
  98185. * @param uvOffset is an optional vector2 used to offset UV.
  98186. * @param uvScale is an optional vector2 used to scale UV.
  98187. * @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.
  98188. * @returns the Mesh.
  98189. */
  98190. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98191. /**
  98192. * Modify the mesh to get a flat shading rendering.
  98193. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98194. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98195. * @returns current mesh
  98196. */
  98197. convertToFlatShadedMesh(): Mesh;
  98198. /**
  98199. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98200. * In other words, more vertices, no more indices and a single bigger VBO.
  98201. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98202. * @returns current mesh
  98203. */
  98204. convertToUnIndexedMesh(): Mesh;
  98205. /**
  98206. * Inverses facet orientations.
  98207. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98208. * @param flipNormals will also inverts the normals
  98209. * @returns current mesh
  98210. */
  98211. flipFaces(flipNormals?: boolean): Mesh;
  98212. /**
  98213. * Increase the number of facets and hence vertices in a mesh
  98214. * Vertex normals are interpolated from existing vertex normals
  98215. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98216. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98217. */
  98218. increaseVertices(numberPerEdge: number): void;
  98219. /**
  98220. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98221. * This will undo any application of covertToFlatShadedMesh
  98222. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98223. */
  98224. forceSharedVertices(): void;
  98225. /** @hidden */
  98226. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98227. /** @hidden */
  98228. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98229. /**
  98230. * Creates a new InstancedMesh object from the mesh model.
  98231. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98232. * @param name defines the name of the new instance
  98233. * @returns a new InstancedMesh
  98234. */
  98235. createInstance(name: string): InstancedMesh;
  98236. /**
  98237. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98238. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98239. * @returns the current mesh
  98240. */
  98241. synchronizeInstances(): Mesh;
  98242. /**
  98243. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98244. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98245. * This should be used together with the simplification to avoid disappearing triangles.
  98246. * @param successCallback an optional success callback to be called after the optimization finished.
  98247. * @returns the current mesh
  98248. */
  98249. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98250. /**
  98251. * Serialize current mesh
  98252. * @param serializationObject defines the object which will receive the serialization data
  98253. */
  98254. serialize(serializationObject: any): void;
  98255. /** @hidden */
  98256. _syncGeometryWithMorphTargetManager(): void;
  98257. /** @hidden */
  98258. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98259. /**
  98260. * Returns a new Mesh object parsed from the source provided.
  98261. * @param parsedMesh is the source
  98262. * @param scene defines the hosting scene
  98263. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98264. * @returns a new Mesh
  98265. */
  98266. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98267. /**
  98268. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98269. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98270. * @param name defines the name of the mesh to create
  98271. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98272. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98273. * @param closePath creates a seam between the first and the last points of each path of the path array
  98274. * @param offset is taken in account only if the `pathArray` is containing a single path
  98275. * @param scene defines the hosting scene
  98276. * @param updatable defines if the mesh must be flagged as updatable
  98277. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98278. * @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)
  98279. * @returns a new Mesh
  98280. */
  98281. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98282. /**
  98283. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98284. * @param name defines the name of the mesh to create
  98285. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98286. * @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
  98287. * @param scene defines the hosting scene
  98288. * @param updatable defines if the mesh must be flagged as updatable
  98289. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98290. * @returns a new Mesh
  98291. */
  98292. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98293. /**
  98294. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98295. * @param name defines the name of the mesh to create
  98296. * @param size sets the size (float) of each box side (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 CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98303. /**
  98304. * Creates a sphere 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. * @param updatable defines if the mesh must be flagged as updatable
  98310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98311. * @returns a new Mesh
  98312. */
  98313. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98314. /**
  98315. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98316. * @param name defines the name of the mesh to create
  98317. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98318. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98319. * @param scene defines the hosting scene
  98320. * @returns a new Mesh
  98321. */
  98322. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98323. /**
  98324. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98325. * @param name defines the name of the mesh to create
  98326. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98327. * @param diameterTop set the top cap diameter (floats, default 1)
  98328. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98329. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98330. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98331. * @param scene defines the hosting scene
  98332. * @param updatable defines if the mesh must be flagged as updatable
  98333. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98334. * @returns a new Mesh
  98335. */
  98336. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98337. /**
  98338. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98339. * @param name defines the name of the mesh to create
  98340. * @param diameter sets the diameter size (float) of the torus (default 1)
  98341. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98342. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98343. * @param scene defines the hosting scene
  98344. * @param updatable defines if the mesh must be flagged as updatable
  98345. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98346. * @returns a new Mesh
  98347. */
  98348. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98349. /**
  98350. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98351. * @param name defines the name of the mesh to create
  98352. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98353. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98354. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98355. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98356. * @param p the number of windings on X axis (positive integers, default 2)
  98357. * @param q the number of windings on Y axis (positive integers, default 3)
  98358. * @param scene defines the hosting scene
  98359. * @param updatable defines if the mesh must be flagged as updatable
  98360. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98361. * @returns a new Mesh
  98362. */
  98363. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98364. /**
  98365. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98366. * @param name defines the name of the mesh to create
  98367. * @param points is an array successive Vector3
  98368. * @param scene defines the hosting scene
  98369. * @param updatable defines if the mesh must be flagged as updatable
  98370. * @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).
  98371. * @returns a new Mesh
  98372. */
  98373. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98374. /**
  98375. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98376. * @param name defines the name of the mesh to create
  98377. * @param points is an array successive Vector3
  98378. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98379. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98380. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98381. * @param scene defines the hosting scene
  98382. * @param updatable defines if the mesh must be flagged as updatable
  98383. * @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)
  98384. * @returns a new Mesh
  98385. */
  98386. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98387. /**
  98388. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98389. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98390. * 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.
  98391. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98392. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98393. * Remember you can only change the shape positions, not their number when updating a polygon.
  98394. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98395. * @param name defines the name of the mesh to create
  98396. * @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
  98397. * @param scene defines the hosting scene
  98398. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98399. * @param updatable defines if the mesh must be flagged as updatable
  98400. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98401. * @param earcutInjection can be used to inject your own earcut reference
  98402. * @returns a new Mesh
  98403. */
  98404. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98405. /**
  98406. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98407. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98408. * @param name defines the name of the mesh to create
  98409. * @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
  98410. * @param depth defines the height of extrusion
  98411. * @param scene defines the hosting scene
  98412. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98413. * @param updatable defines if the mesh must be flagged as updatable
  98414. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98415. * @param earcutInjection can be used to inject your own earcut reference
  98416. * @returns a new Mesh
  98417. */
  98418. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98419. /**
  98420. * Creates an extruded shape mesh.
  98421. * 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
  98422. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98423. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98424. * @param name defines the name of the mesh to create
  98425. * @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
  98426. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98427. * @param scale is the value to scale the shape
  98428. * @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
  98429. * @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
  98430. * @param scene defines the hosting scene
  98431. * @param updatable defines if the mesh must be flagged as updatable
  98432. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98433. * @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)
  98434. * @returns a new Mesh
  98435. */
  98436. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98437. /**
  98438. * Creates an custom extruded shape mesh.
  98439. * The custom extrusion is a parametric shape.
  98440. * It has no predefined shape. Its final shape will depend on the input parameters.
  98441. * Please consider using the same method from the MeshBuilder class instead
  98442. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98443. * @param name defines the name of the mesh to create
  98444. * @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
  98445. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98446. * @param scaleFunction is a custom Javascript function called on each path point
  98447. * @param rotationFunction is a custom Javascript function called on each path point
  98448. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98449. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98450. * @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
  98451. * @param scene defines the hosting scene
  98452. * @param updatable defines if the mesh must be flagged as updatable
  98453. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98454. * @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)
  98455. * @returns a new Mesh
  98456. */
  98457. 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;
  98458. /**
  98459. * Creates lathe mesh.
  98460. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98461. * Please consider using the same method from the MeshBuilder class instead
  98462. * @param name defines the name of the mesh to create
  98463. * @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
  98464. * @param radius is the radius value of the lathe
  98465. * @param tessellation is the side number of the lathe.
  98466. * @param scene defines the hosting scene
  98467. * @param updatable defines if the mesh must be flagged as updatable
  98468. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98469. * @returns a new Mesh
  98470. */
  98471. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98472. /**
  98473. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98474. * @param name defines the name of the mesh to create
  98475. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98476. * @param scene defines the hosting scene
  98477. * @param updatable defines if the mesh must be flagged as updatable
  98478. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98479. * @returns a new Mesh
  98480. */
  98481. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98482. /**
  98483. * Creates a ground mesh.
  98484. * Please consider using the same method from the MeshBuilder class instead
  98485. * @param name defines the name of the mesh to create
  98486. * @param width set the width of the ground
  98487. * @param height set the height of the ground
  98488. * @param subdivisions sets the number of subdivisions per side
  98489. * @param scene defines the hosting scene
  98490. * @param updatable defines if the mesh must be flagged as updatable
  98491. * @returns a new Mesh
  98492. */
  98493. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98494. /**
  98495. * Creates a tiled ground mesh.
  98496. * Please consider using the same method from the MeshBuilder class instead
  98497. * @param name defines the name of the mesh to create
  98498. * @param xmin set the ground minimum X coordinate
  98499. * @param zmin set the ground minimum Y coordinate
  98500. * @param xmax set the ground maximum X coordinate
  98501. * @param zmax set the ground maximum Z coordinate
  98502. * @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
  98503. * @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
  98504. * @param scene defines the hosting scene
  98505. * @param updatable defines if the mesh must be flagged as updatable
  98506. * @returns a new Mesh
  98507. */
  98508. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98509. w: number;
  98510. h: number;
  98511. }, precision: {
  98512. w: number;
  98513. h: number;
  98514. }, scene: Scene, updatable?: boolean): Mesh;
  98515. /**
  98516. * Creates a ground mesh from a height map.
  98517. * Please consider using the same method from the MeshBuilder class instead
  98518. * @see http://doc.babylonjs.com/babylon101/height_map
  98519. * @param name defines the name of the mesh to create
  98520. * @param url sets the URL of the height map image resource
  98521. * @param width set the ground width size
  98522. * @param height set the ground height size
  98523. * @param subdivisions sets the number of subdivision per side
  98524. * @param minHeight is the minimum altitude on the ground
  98525. * @param maxHeight is the maximum altitude on the ground
  98526. * @param scene defines the hosting scene
  98527. * @param updatable defines if the mesh must be flagged as updatable
  98528. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98529. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98530. * @returns a new Mesh
  98531. */
  98532. 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;
  98533. /**
  98534. * Creates a tube mesh.
  98535. * The tube is a parametric shape.
  98536. * It has no predefined shape. Its final shape will depend on the input parameters.
  98537. * Please consider using the same method from the MeshBuilder class instead
  98538. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98539. * @param name defines the name of the mesh to create
  98540. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98541. * @param radius sets the tube radius size
  98542. * @param tessellation is the number of sides on the tubular surface
  98543. * @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
  98544. * @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
  98545. * @param scene defines the hosting scene
  98546. * @param updatable defines if the mesh must be flagged as updatable
  98547. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98548. * @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)
  98549. * @returns a new Mesh
  98550. */
  98551. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98552. (i: number, distance: number): number;
  98553. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98554. /**
  98555. * Creates a polyhedron mesh.
  98556. * Please consider using the same method from the MeshBuilder class instead.
  98557. * * 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
  98558. * * The parameter `size` (positive float, default 1) sets the polygon size
  98559. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98560. * * 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`
  98561. * * 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
  98562. * * 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)`)
  98563. * * 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
  98564. * * 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
  98565. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98566. * * If you create a double-sided mesh, you can choose what parts of 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
  98567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98568. * @param name defines the name of the mesh to create
  98569. * @param options defines the options used to create the mesh
  98570. * @param scene defines the hosting scene
  98571. * @returns a new Mesh
  98572. */
  98573. static CreatePolyhedron(name: string, options: {
  98574. type?: number;
  98575. size?: number;
  98576. sizeX?: number;
  98577. sizeY?: number;
  98578. sizeZ?: number;
  98579. custom?: any;
  98580. faceUV?: Vector4[];
  98581. faceColors?: Color4[];
  98582. updatable?: boolean;
  98583. sideOrientation?: number;
  98584. }, scene: Scene): Mesh;
  98585. /**
  98586. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98587. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98588. * * 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`)
  98589. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98590. * * 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
  98591. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98592. * * If you create a double-sided mesh, you can choose what parts of 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
  98593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98594. * @param name defines the name of the mesh
  98595. * @param options defines the options used to create the mesh
  98596. * @param scene defines the hosting scene
  98597. * @returns a new Mesh
  98598. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98599. */
  98600. static CreateIcoSphere(name: string, options: {
  98601. radius?: number;
  98602. flat?: boolean;
  98603. subdivisions?: number;
  98604. sideOrientation?: number;
  98605. updatable?: boolean;
  98606. }, scene: Scene): Mesh;
  98607. /**
  98608. * Creates a decal mesh.
  98609. * Please consider using the same method from the MeshBuilder class instead.
  98610. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98611. * @param name defines the name of the mesh
  98612. * @param sourceMesh defines the mesh receiving the decal
  98613. * @param position sets the position of the decal in world coordinates
  98614. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98615. * @param size sets the decal scaling
  98616. * @param angle sets the angle to rotate the decal
  98617. * @returns a new Mesh
  98618. */
  98619. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98620. /**
  98621. * Prepare internal position array for software CPU skinning
  98622. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98623. */
  98624. setPositionsForCPUSkinning(): Float32Array;
  98625. /**
  98626. * Prepare internal normal array for software CPU skinning
  98627. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98628. */
  98629. setNormalsForCPUSkinning(): Float32Array;
  98630. /**
  98631. * Updates the vertex buffer by applying transformation from the bones
  98632. * @param skeleton defines the skeleton to apply to current mesh
  98633. * @returns the current mesh
  98634. */
  98635. applySkeleton(skeleton: Skeleton): Mesh;
  98636. /**
  98637. * 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
  98638. * @param meshes defines the list of meshes to scan
  98639. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98640. */
  98641. static MinMax(meshes: AbstractMesh[]): {
  98642. min: Vector3;
  98643. max: Vector3;
  98644. };
  98645. /**
  98646. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98647. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98648. * @returns a vector3
  98649. */
  98650. static Center(meshesOrMinMaxVector: {
  98651. min: Vector3;
  98652. max: Vector3;
  98653. } | AbstractMesh[]): Vector3;
  98654. /**
  98655. * Merge the array of meshes into a single mesh for performance reasons.
  98656. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98657. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98658. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98659. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98660. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98661. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98662. * @returns a new mesh
  98663. */
  98664. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98665. /** @hidden */
  98666. addInstance(instance: InstancedMesh): void;
  98667. /** @hidden */
  98668. removeInstance(instance: InstancedMesh): void;
  98669. }
  98670. }
  98671. declare module BABYLON {
  98672. /**
  98673. * This is the base class of all the camera used in the application.
  98674. * @see http://doc.babylonjs.com/features/cameras
  98675. */
  98676. export class Camera extends Node {
  98677. /** @hidden */
  98678. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98679. /**
  98680. * This is the default projection mode used by the cameras.
  98681. * It helps recreating a feeling of perspective and better appreciate depth.
  98682. * This is the best way to simulate real life cameras.
  98683. */
  98684. static readonly PERSPECTIVE_CAMERA: number;
  98685. /**
  98686. * This helps creating camera with an orthographic mode.
  98687. * 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.
  98688. */
  98689. static readonly ORTHOGRAPHIC_CAMERA: number;
  98690. /**
  98691. * This is the default FOV mode for perspective cameras.
  98692. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98693. */
  98694. static readonly FOVMODE_VERTICAL_FIXED: number;
  98695. /**
  98696. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98697. */
  98698. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98699. /**
  98700. * This specifies ther is no need for a camera rig.
  98701. * Basically only one eye is rendered corresponding to the camera.
  98702. */
  98703. static readonly RIG_MODE_NONE: number;
  98704. /**
  98705. * Simulates a camera Rig with one blue eye and one red eye.
  98706. * This can be use with 3d blue and red glasses.
  98707. */
  98708. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98709. /**
  98710. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98711. */
  98712. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98713. /**
  98714. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98715. */
  98716. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98717. /**
  98718. * Defines that both eyes of the camera will be rendered over under each other.
  98719. */
  98720. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98721. /**
  98722. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98723. */
  98724. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98725. /**
  98726. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98727. */
  98728. static readonly RIG_MODE_VR: number;
  98729. /**
  98730. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98731. */
  98732. static readonly RIG_MODE_WEBVR: number;
  98733. /**
  98734. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98735. */
  98736. static readonly RIG_MODE_CUSTOM: number;
  98737. /**
  98738. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98739. */
  98740. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98741. /**
  98742. * Define the input manager associated with the camera.
  98743. */
  98744. inputs: CameraInputsManager<Camera>;
  98745. /** @hidden */
  98746. _position: Vector3;
  98747. /**
  98748. * Define the current local position of the camera in the scene
  98749. */
  98750. get position(): Vector3;
  98751. set position(newPosition: Vector3);
  98752. /**
  98753. * The vector the camera should consider as up.
  98754. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98755. */
  98756. upVector: Vector3;
  98757. /**
  98758. * Define the current limit on the left side for an orthographic camera
  98759. * In scene unit
  98760. */
  98761. orthoLeft: Nullable<number>;
  98762. /**
  98763. * Define the current limit on the right side for an orthographic camera
  98764. * In scene unit
  98765. */
  98766. orthoRight: Nullable<number>;
  98767. /**
  98768. * Define the current limit on the bottom side for an orthographic camera
  98769. * In scene unit
  98770. */
  98771. orthoBottom: Nullable<number>;
  98772. /**
  98773. * Define the current limit on the top side for an orthographic camera
  98774. * In scene unit
  98775. */
  98776. orthoTop: Nullable<number>;
  98777. /**
  98778. * Field Of View is set in Radians. (default is 0.8)
  98779. */
  98780. fov: number;
  98781. /**
  98782. * Define the minimum distance the camera can see from.
  98783. * This is important to note that the depth buffer are not infinite and the closer it starts
  98784. * the more your scene might encounter depth fighting issue.
  98785. */
  98786. minZ: number;
  98787. /**
  98788. * Define the maximum distance the camera can see to.
  98789. * This is important to note that the depth buffer are not infinite and the further it end
  98790. * the more your scene might encounter depth fighting issue.
  98791. */
  98792. maxZ: number;
  98793. /**
  98794. * Define the default inertia of the camera.
  98795. * This helps giving a smooth feeling to the camera movement.
  98796. */
  98797. inertia: number;
  98798. /**
  98799. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98800. */
  98801. mode: number;
  98802. /**
  98803. * Define whether the camera is intermediate.
  98804. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98805. */
  98806. isIntermediate: boolean;
  98807. /**
  98808. * Define the viewport of the camera.
  98809. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98810. */
  98811. viewport: Viewport;
  98812. /**
  98813. * Restricts the camera to viewing objects with the same layerMask.
  98814. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98815. */
  98816. layerMask: number;
  98817. /**
  98818. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98819. */
  98820. fovMode: number;
  98821. /**
  98822. * Rig mode of the camera.
  98823. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98824. * This is normally controlled byt the camera themselves as internal use.
  98825. */
  98826. cameraRigMode: number;
  98827. /**
  98828. * Defines the distance between both "eyes" in case of a RIG
  98829. */
  98830. interaxialDistance: number;
  98831. /**
  98832. * Defines if stereoscopic rendering is done side by side or over under.
  98833. */
  98834. isStereoscopicSideBySide: boolean;
  98835. /**
  98836. * 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
  98837. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98838. * else in the scene. (Eg. security camera)
  98839. *
  98840. * 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)
  98841. */
  98842. customRenderTargets: RenderTargetTexture[];
  98843. /**
  98844. * When set, the camera will render to this render target instead of the default canvas
  98845. *
  98846. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98847. */
  98848. outputRenderTarget: Nullable<RenderTargetTexture>;
  98849. /**
  98850. * Observable triggered when the camera view matrix has changed.
  98851. */
  98852. onViewMatrixChangedObservable: Observable<Camera>;
  98853. /**
  98854. * Observable triggered when the camera Projection matrix has changed.
  98855. */
  98856. onProjectionMatrixChangedObservable: Observable<Camera>;
  98857. /**
  98858. * Observable triggered when the inputs have been processed.
  98859. */
  98860. onAfterCheckInputsObservable: Observable<Camera>;
  98861. /**
  98862. * Observable triggered when reset has been called and applied to the camera.
  98863. */
  98864. onRestoreStateObservable: Observable<Camera>;
  98865. /**
  98866. * Is this camera a part of a rig system?
  98867. */
  98868. isRigCamera: boolean;
  98869. /**
  98870. * If isRigCamera set to true this will be set with the parent camera.
  98871. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98872. */
  98873. rigParent?: Camera;
  98874. /** @hidden */
  98875. _cameraRigParams: any;
  98876. /** @hidden */
  98877. _rigCameras: Camera[];
  98878. /** @hidden */
  98879. _rigPostProcess: Nullable<PostProcess>;
  98880. protected _webvrViewMatrix: Matrix;
  98881. /** @hidden */
  98882. _skipRendering: boolean;
  98883. /** @hidden */
  98884. _projectionMatrix: Matrix;
  98885. /** @hidden */
  98886. _postProcesses: Nullable<PostProcess>[];
  98887. /** @hidden */
  98888. _activeMeshes: SmartArray<AbstractMesh>;
  98889. protected _globalPosition: Vector3;
  98890. /** @hidden */
  98891. _computedViewMatrix: Matrix;
  98892. private _doNotComputeProjectionMatrix;
  98893. private _transformMatrix;
  98894. private _frustumPlanes;
  98895. private _refreshFrustumPlanes;
  98896. private _storedFov;
  98897. private _stateStored;
  98898. /**
  98899. * Instantiates a new camera object.
  98900. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98901. * @see http://doc.babylonjs.com/features/cameras
  98902. * @param name Defines the name of the camera in the scene
  98903. * @param position Defines the position of the camera
  98904. * @param scene Defines the scene the camera belongs too
  98905. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98906. */
  98907. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98908. /**
  98909. * Store current camera state (fov, position, etc..)
  98910. * @returns the camera
  98911. */
  98912. storeState(): Camera;
  98913. /**
  98914. * Restores the camera state values if it has been stored. You must call storeState() first
  98915. */
  98916. protected _restoreStateValues(): boolean;
  98917. /**
  98918. * Restored camera state. You must call storeState() first.
  98919. * @returns true if restored and false otherwise
  98920. */
  98921. restoreState(): boolean;
  98922. /**
  98923. * Gets the class name of the camera.
  98924. * @returns the class name
  98925. */
  98926. getClassName(): string;
  98927. /** @hidden */
  98928. readonly _isCamera: boolean;
  98929. /**
  98930. * Gets a string representation of the camera useful for debug purpose.
  98931. * @param fullDetails Defines that a more verboe level of logging is required
  98932. * @returns the string representation
  98933. */
  98934. toString(fullDetails?: boolean): string;
  98935. /**
  98936. * Gets the current world space position of the camera.
  98937. */
  98938. get globalPosition(): Vector3;
  98939. /**
  98940. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98941. * @returns the active meshe list
  98942. */
  98943. getActiveMeshes(): SmartArray<AbstractMesh>;
  98944. /**
  98945. * Check whether a mesh is part of the current active mesh list of the camera
  98946. * @param mesh Defines the mesh to check
  98947. * @returns true if active, false otherwise
  98948. */
  98949. isActiveMesh(mesh: Mesh): boolean;
  98950. /**
  98951. * Is this camera ready to be used/rendered
  98952. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98953. * @return true if the camera is ready
  98954. */
  98955. isReady(completeCheck?: boolean): boolean;
  98956. /** @hidden */
  98957. _initCache(): void;
  98958. /** @hidden */
  98959. _updateCache(ignoreParentClass?: boolean): void;
  98960. /** @hidden */
  98961. _isSynchronized(): boolean;
  98962. /** @hidden */
  98963. _isSynchronizedViewMatrix(): boolean;
  98964. /** @hidden */
  98965. _isSynchronizedProjectionMatrix(): boolean;
  98966. /**
  98967. * Attach the input controls to a specific dom element to get the input from.
  98968. * @param element Defines the element the controls should be listened from
  98969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98970. */
  98971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98972. /**
  98973. * Detach the current controls from the specified dom element.
  98974. * @param element Defines the element to stop listening the inputs from
  98975. */
  98976. detachControl(element: HTMLElement): void;
  98977. /**
  98978. * Update the camera state according to the different inputs gathered during the frame.
  98979. */
  98980. update(): void;
  98981. /** @hidden */
  98982. _checkInputs(): void;
  98983. /** @hidden */
  98984. get rigCameras(): Camera[];
  98985. /**
  98986. * Gets the post process used by the rig cameras
  98987. */
  98988. get rigPostProcess(): Nullable<PostProcess>;
  98989. /**
  98990. * Internal, gets the first post proces.
  98991. * @returns the first post process to be run on this camera.
  98992. */
  98993. _getFirstPostProcess(): Nullable<PostProcess>;
  98994. private _cascadePostProcessesToRigCams;
  98995. /**
  98996. * Attach a post process to the camera.
  98997. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98998. * @param postProcess The post process to attach to the camera
  98999. * @param insertAt The position of the post process in case several of them are in use in the scene
  99000. * @returns the position the post process has been inserted at
  99001. */
  99002. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  99003. /**
  99004. * Detach a post process to the camera.
  99005. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99006. * @param postProcess The post process to detach from the camera
  99007. */
  99008. detachPostProcess(postProcess: PostProcess): void;
  99009. /**
  99010. * Gets the current world matrix of the camera
  99011. */
  99012. getWorldMatrix(): Matrix;
  99013. /** @hidden */
  99014. _getViewMatrix(): Matrix;
  99015. /**
  99016. * Gets the current view matrix of the camera.
  99017. * @param force forces the camera to recompute the matrix without looking at the cached state
  99018. * @returns the view matrix
  99019. */
  99020. getViewMatrix(force?: boolean): Matrix;
  99021. /**
  99022. * Freeze the projection matrix.
  99023. * It will prevent the cache check of the camera projection compute and can speed up perf
  99024. * if no parameter of the camera are meant to change
  99025. * @param projection Defines manually a projection if necessary
  99026. */
  99027. freezeProjectionMatrix(projection?: Matrix): void;
  99028. /**
  99029. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99030. */
  99031. unfreezeProjectionMatrix(): void;
  99032. /**
  99033. * Gets the current projection matrix of the camera.
  99034. * @param force forces the camera to recompute the matrix without looking at the cached state
  99035. * @returns the projection matrix
  99036. */
  99037. getProjectionMatrix(force?: boolean): Matrix;
  99038. /**
  99039. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99040. * @returns a Matrix
  99041. */
  99042. getTransformationMatrix(): Matrix;
  99043. private _updateFrustumPlanes;
  99044. /**
  99045. * Checks if a cullable object (mesh...) is in the camera frustum
  99046. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99047. * @param target The object to check
  99048. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99049. * @returns true if the object is in frustum otherwise false
  99050. */
  99051. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99052. /**
  99053. * Checks if a cullable object (mesh...) is in the camera frustum
  99054. * Unlike isInFrustum this cheks the full bounding box
  99055. * @param target The object to check
  99056. * @returns true if the object is in frustum otherwise false
  99057. */
  99058. isCompletelyInFrustum(target: ICullable): boolean;
  99059. /**
  99060. * Gets a ray in the forward direction from the camera.
  99061. * @param length Defines the length of the ray to create
  99062. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99063. * @param origin Defines the start point of the ray which defaults to the camera position
  99064. * @returns the forward ray
  99065. */
  99066. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99067. /**
  99068. * Releases resources associated with this node.
  99069. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99070. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99071. */
  99072. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99073. /** @hidden */
  99074. _isLeftCamera: boolean;
  99075. /**
  99076. * Gets the left camera of a rig setup in case of Rigged Camera
  99077. */
  99078. get isLeftCamera(): boolean;
  99079. /** @hidden */
  99080. _isRightCamera: boolean;
  99081. /**
  99082. * Gets the right camera of a rig setup in case of Rigged Camera
  99083. */
  99084. get isRightCamera(): boolean;
  99085. /**
  99086. * Gets the left camera of a rig setup in case of Rigged Camera
  99087. */
  99088. get leftCamera(): Nullable<FreeCamera>;
  99089. /**
  99090. * Gets the right camera of a rig setup in case of Rigged Camera
  99091. */
  99092. get rightCamera(): Nullable<FreeCamera>;
  99093. /**
  99094. * Gets the left camera target of a rig setup in case of Rigged Camera
  99095. * @returns the target position
  99096. */
  99097. getLeftTarget(): Nullable<Vector3>;
  99098. /**
  99099. * Gets the right camera target of a rig setup in case of Rigged Camera
  99100. * @returns the target position
  99101. */
  99102. getRightTarget(): Nullable<Vector3>;
  99103. /**
  99104. * @hidden
  99105. */
  99106. setCameraRigMode(mode: number, rigParams: any): void;
  99107. /** @hidden */
  99108. static _setStereoscopicRigMode(camera: Camera): void;
  99109. /** @hidden */
  99110. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99111. /** @hidden */
  99112. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99113. /** @hidden */
  99114. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99115. /** @hidden */
  99116. _getVRProjectionMatrix(): Matrix;
  99117. protected _updateCameraRotationMatrix(): void;
  99118. protected _updateWebVRCameraRotationMatrix(): void;
  99119. /**
  99120. * This function MUST be overwritten by the different WebVR cameras available.
  99121. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99122. * @hidden
  99123. */
  99124. _getWebVRProjectionMatrix(): Matrix;
  99125. /**
  99126. * This function MUST be overwritten by the different WebVR cameras available.
  99127. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99128. * @hidden
  99129. */
  99130. _getWebVRViewMatrix(): Matrix;
  99131. /** @hidden */
  99132. setCameraRigParameter(name: string, value: any): void;
  99133. /**
  99134. * needs to be overridden by children so sub has required properties to be copied
  99135. * @hidden
  99136. */
  99137. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99138. /**
  99139. * May need to be overridden by children
  99140. * @hidden
  99141. */
  99142. _updateRigCameras(): void;
  99143. /** @hidden */
  99144. _setupInputs(): void;
  99145. /**
  99146. * Serialiaze the camera setup to a json represention
  99147. * @returns the JSON representation
  99148. */
  99149. serialize(): any;
  99150. /**
  99151. * Clones the current camera.
  99152. * @param name The cloned camera name
  99153. * @returns the cloned camera
  99154. */
  99155. clone(name: string): Camera;
  99156. /**
  99157. * Gets the direction of the camera relative to a given local axis.
  99158. * @param localAxis Defines the reference axis to provide a relative direction.
  99159. * @return the direction
  99160. */
  99161. getDirection(localAxis: Vector3): Vector3;
  99162. /**
  99163. * Returns the current camera absolute rotation
  99164. */
  99165. get absoluteRotation(): Quaternion;
  99166. /**
  99167. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99168. * @param localAxis Defines the reference axis to provide a relative direction.
  99169. * @param result Defines the vector to store the result in
  99170. */
  99171. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99172. /**
  99173. * Gets a camera constructor for a given camera type
  99174. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99175. * @param name The name of the camera the result will be able to instantiate
  99176. * @param scene The scene the result will construct the camera in
  99177. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99178. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99179. * @returns a factory method to construc the camera
  99180. */
  99181. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99182. /**
  99183. * Compute the world matrix of the camera.
  99184. * @returns the camera world matrix
  99185. */
  99186. computeWorldMatrix(): Matrix;
  99187. /**
  99188. * Parse a JSON and creates the camera from the parsed information
  99189. * @param parsedCamera The JSON to parse
  99190. * @param scene The scene to instantiate the camera in
  99191. * @returns the newly constructed camera
  99192. */
  99193. static Parse(parsedCamera: any, scene: Scene): Camera;
  99194. }
  99195. }
  99196. declare module BABYLON {
  99197. /**
  99198. * Class containing static functions to help procedurally build meshes
  99199. */
  99200. export class DiscBuilder {
  99201. /**
  99202. * Creates a plane polygonal mesh. By default, this is a disc
  99203. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99204. * * 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
  99205. * * 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
  99206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99207. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99209. * @param name defines the name of the mesh
  99210. * @param options defines the options used to create the mesh
  99211. * @param scene defines the hosting scene
  99212. * @returns the plane polygonal mesh
  99213. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99214. */
  99215. static CreateDisc(name: string, options: {
  99216. radius?: number;
  99217. tessellation?: number;
  99218. arc?: number;
  99219. updatable?: boolean;
  99220. sideOrientation?: number;
  99221. frontUVs?: Vector4;
  99222. backUVs?: Vector4;
  99223. }, scene?: Nullable<Scene>): Mesh;
  99224. }
  99225. }
  99226. declare module BABYLON {
  99227. /**
  99228. * This represents all the required information to add a fresnel effect on a material:
  99229. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99230. */
  99231. export class FresnelParameters {
  99232. private _isEnabled;
  99233. /**
  99234. * Define if the fresnel effect is enable or not.
  99235. */
  99236. get isEnabled(): boolean;
  99237. set isEnabled(value: boolean);
  99238. /**
  99239. * Define the color used on edges (grazing angle)
  99240. */
  99241. leftColor: Color3;
  99242. /**
  99243. * Define the color used on center
  99244. */
  99245. rightColor: Color3;
  99246. /**
  99247. * Define bias applied to computed fresnel term
  99248. */
  99249. bias: number;
  99250. /**
  99251. * Defined the power exponent applied to fresnel term
  99252. */
  99253. power: number;
  99254. /**
  99255. * Clones the current fresnel and its valuues
  99256. * @returns a clone fresnel configuration
  99257. */
  99258. clone(): FresnelParameters;
  99259. /**
  99260. * Serializes the current fresnel parameters to a JSON representation.
  99261. * @return the JSON serialization
  99262. */
  99263. serialize(): any;
  99264. /**
  99265. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99266. * @param parsedFresnelParameters Define the JSON representation
  99267. * @returns the parsed parameters
  99268. */
  99269. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99270. }
  99271. }
  99272. declare module BABYLON {
  99273. /**
  99274. * Base class of materials working in push mode in babylon JS
  99275. * @hidden
  99276. */
  99277. export class PushMaterial extends Material {
  99278. protected _activeEffect: Effect;
  99279. protected _normalMatrix: Matrix;
  99280. /**
  99281. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99282. * This means that the material can keep using a previous shader while a new one is being compiled.
  99283. * This is mostly used when shader parallel compilation is supported (true by default)
  99284. */
  99285. allowShaderHotSwapping: boolean;
  99286. constructor(name: string, scene: Scene);
  99287. getEffect(): Effect;
  99288. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99289. /**
  99290. * Binds the given world matrix to the active effect
  99291. *
  99292. * @param world the matrix to bind
  99293. */
  99294. bindOnlyWorldMatrix(world: Matrix): void;
  99295. /**
  99296. * Binds the given normal matrix to the active effect
  99297. *
  99298. * @param normalMatrix the matrix to bind
  99299. */
  99300. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99301. bind(world: Matrix, mesh?: Mesh): void;
  99302. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99303. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99304. }
  99305. }
  99306. declare module BABYLON {
  99307. /**
  99308. * This groups all the flags used to control the materials channel.
  99309. */
  99310. export class MaterialFlags {
  99311. private static _DiffuseTextureEnabled;
  99312. /**
  99313. * Are diffuse textures enabled in the application.
  99314. */
  99315. static get DiffuseTextureEnabled(): boolean;
  99316. static set DiffuseTextureEnabled(value: boolean);
  99317. private static _AmbientTextureEnabled;
  99318. /**
  99319. * Are ambient textures enabled in the application.
  99320. */
  99321. static get AmbientTextureEnabled(): boolean;
  99322. static set AmbientTextureEnabled(value: boolean);
  99323. private static _OpacityTextureEnabled;
  99324. /**
  99325. * Are opacity textures enabled in the application.
  99326. */
  99327. static get OpacityTextureEnabled(): boolean;
  99328. static set OpacityTextureEnabled(value: boolean);
  99329. private static _ReflectionTextureEnabled;
  99330. /**
  99331. * Are reflection textures enabled in the application.
  99332. */
  99333. static get ReflectionTextureEnabled(): boolean;
  99334. static set ReflectionTextureEnabled(value: boolean);
  99335. private static _EmissiveTextureEnabled;
  99336. /**
  99337. * Are emissive textures enabled in the application.
  99338. */
  99339. static get EmissiveTextureEnabled(): boolean;
  99340. static set EmissiveTextureEnabled(value: boolean);
  99341. private static _SpecularTextureEnabled;
  99342. /**
  99343. * Are specular textures enabled in the application.
  99344. */
  99345. static get SpecularTextureEnabled(): boolean;
  99346. static set SpecularTextureEnabled(value: boolean);
  99347. private static _BumpTextureEnabled;
  99348. /**
  99349. * Are bump textures enabled in the application.
  99350. */
  99351. static get BumpTextureEnabled(): boolean;
  99352. static set BumpTextureEnabled(value: boolean);
  99353. private static _LightmapTextureEnabled;
  99354. /**
  99355. * Are lightmap textures enabled in the application.
  99356. */
  99357. static get LightmapTextureEnabled(): boolean;
  99358. static set LightmapTextureEnabled(value: boolean);
  99359. private static _RefractionTextureEnabled;
  99360. /**
  99361. * Are refraction textures enabled in the application.
  99362. */
  99363. static get RefractionTextureEnabled(): boolean;
  99364. static set RefractionTextureEnabled(value: boolean);
  99365. private static _ColorGradingTextureEnabled;
  99366. /**
  99367. * Are color grading textures enabled in the application.
  99368. */
  99369. static get ColorGradingTextureEnabled(): boolean;
  99370. static set ColorGradingTextureEnabled(value: boolean);
  99371. private static _FresnelEnabled;
  99372. /**
  99373. * Are fresnels enabled in the application.
  99374. */
  99375. static get FresnelEnabled(): boolean;
  99376. static set FresnelEnabled(value: boolean);
  99377. private static _ClearCoatTextureEnabled;
  99378. /**
  99379. * Are clear coat textures enabled in the application.
  99380. */
  99381. static get ClearCoatTextureEnabled(): boolean;
  99382. static set ClearCoatTextureEnabled(value: boolean);
  99383. private static _ClearCoatBumpTextureEnabled;
  99384. /**
  99385. * Are clear coat bump textures enabled in the application.
  99386. */
  99387. static get ClearCoatBumpTextureEnabled(): boolean;
  99388. static set ClearCoatBumpTextureEnabled(value: boolean);
  99389. private static _ClearCoatTintTextureEnabled;
  99390. /**
  99391. * Are clear coat tint textures enabled in the application.
  99392. */
  99393. static get ClearCoatTintTextureEnabled(): boolean;
  99394. static set ClearCoatTintTextureEnabled(value: boolean);
  99395. private static _SheenTextureEnabled;
  99396. /**
  99397. * Are sheen textures enabled in the application.
  99398. */
  99399. static get SheenTextureEnabled(): boolean;
  99400. static set SheenTextureEnabled(value: boolean);
  99401. private static _AnisotropicTextureEnabled;
  99402. /**
  99403. * Are anisotropic textures enabled in the application.
  99404. */
  99405. static get AnisotropicTextureEnabled(): boolean;
  99406. static set AnisotropicTextureEnabled(value: boolean);
  99407. private static _ThicknessTextureEnabled;
  99408. /**
  99409. * Are thickness textures enabled in the application.
  99410. */
  99411. static get ThicknessTextureEnabled(): boolean;
  99412. static set ThicknessTextureEnabled(value: boolean);
  99413. }
  99414. }
  99415. declare module BABYLON {
  99416. /** @hidden */
  99417. export var defaultFragmentDeclaration: {
  99418. name: string;
  99419. shader: string;
  99420. };
  99421. }
  99422. declare module BABYLON {
  99423. /** @hidden */
  99424. export var defaultUboDeclaration: {
  99425. name: string;
  99426. shader: string;
  99427. };
  99428. }
  99429. declare module BABYLON {
  99430. /** @hidden */
  99431. export var lightFragmentDeclaration: {
  99432. name: string;
  99433. shader: string;
  99434. };
  99435. }
  99436. declare module BABYLON {
  99437. /** @hidden */
  99438. export var lightUboDeclaration: {
  99439. name: string;
  99440. shader: string;
  99441. };
  99442. }
  99443. declare module BABYLON {
  99444. /** @hidden */
  99445. export var lightsFragmentFunctions: {
  99446. name: string;
  99447. shader: string;
  99448. };
  99449. }
  99450. declare module BABYLON {
  99451. /** @hidden */
  99452. export var shadowsFragmentFunctions: {
  99453. name: string;
  99454. shader: string;
  99455. };
  99456. }
  99457. declare module BABYLON {
  99458. /** @hidden */
  99459. export var fresnelFunction: {
  99460. name: string;
  99461. shader: string;
  99462. };
  99463. }
  99464. declare module BABYLON {
  99465. /** @hidden */
  99466. export var reflectionFunction: {
  99467. name: string;
  99468. shader: string;
  99469. };
  99470. }
  99471. declare module BABYLON {
  99472. /** @hidden */
  99473. export var bumpFragmentFunctions: {
  99474. name: string;
  99475. shader: string;
  99476. };
  99477. }
  99478. declare module BABYLON {
  99479. /** @hidden */
  99480. export var logDepthDeclaration: {
  99481. name: string;
  99482. shader: string;
  99483. };
  99484. }
  99485. declare module BABYLON {
  99486. /** @hidden */
  99487. export var bumpFragment: {
  99488. name: string;
  99489. shader: string;
  99490. };
  99491. }
  99492. declare module BABYLON {
  99493. /** @hidden */
  99494. export var depthPrePass: {
  99495. name: string;
  99496. shader: string;
  99497. };
  99498. }
  99499. declare module BABYLON {
  99500. /** @hidden */
  99501. export var lightFragment: {
  99502. name: string;
  99503. shader: string;
  99504. };
  99505. }
  99506. declare module BABYLON {
  99507. /** @hidden */
  99508. export var logDepthFragment: {
  99509. name: string;
  99510. shader: string;
  99511. };
  99512. }
  99513. declare module BABYLON {
  99514. /** @hidden */
  99515. export var defaultPixelShader: {
  99516. name: string;
  99517. shader: string;
  99518. };
  99519. }
  99520. declare module BABYLON {
  99521. /** @hidden */
  99522. export var defaultVertexDeclaration: {
  99523. name: string;
  99524. shader: string;
  99525. };
  99526. }
  99527. declare module BABYLON {
  99528. /** @hidden */
  99529. export var bumpVertexDeclaration: {
  99530. name: string;
  99531. shader: string;
  99532. };
  99533. }
  99534. declare module BABYLON {
  99535. /** @hidden */
  99536. export var bumpVertex: {
  99537. name: string;
  99538. shader: string;
  99539. };
  99540. }
  99541. declare module BABYLON {
  99542. /** @hidden */
  99543. export var fogVertex: {
  99544. name: string;
  99545. shader: string;
  99546. };
  99547. }
  99548. declare module BABYLON {
  99549. /** @hidden */
  99550. export var shadowsVertex: {
  99551. name: string;
  99552. shader: string;
  99553. };
  99554. }
  99555. declare module BABYLON {
  99556. /** @hidden */
  99557. export var pointCloudVertex: {
  99558. name: string;
  99559. shader: string;
  99560. };
  99561. }
  99562. declare module BABYLON {
  99563. /** @hidden */
  99564. export var logDepthVertex: {
  99565. name: string;
  99566. shader: string;
  99567. };
  99568. }
  99569. declare module BABYLON {
  99570. /** @hidden */
  99571. export var defaultVertexShader: {
  99572. name: string;
  99573. shader: string;
  99574. };
  99575. }
  99576. declare module BABYLON {
  99577. /** @hidden */
  99578. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99579. MAINUV1: boolean;
  99580. MAINUV2: boolean;
  99581. DIFFUSE: boolean;
  99582. DIFFUSEDIRECTUV: number;
  99583. AMBIENT: boolean;
  99584. AMBIENTDIRECTUV: number;
  99585. OPACITY: boolean;
  99586. OPACITYDIRECTUV: number;
  99587. OPACITYRGB: boolean;
  99588. REFLECTION: boolean;
  99589. EMISSIVE: boolean;
  99590. EMISSIVEDIRECTUV: number;
  99591. SPECULAR: boolean;
  99592. SPECULARDIRECTUV: number;
  99593. BUMP: boolean;
  99594. BUMPDIRECTUV: number;
  99595. PARALLAX: boolean;
  99596. PARALLAXOCCLUSION: boolean;
  99597. SPECULAROVERALPHA: boolean;
  99598. CLIPPLANE: boolean;
  99599. CLIPPLANE2: boolean;
  99600. CLIPPLANE3: boolean;
  99601. CLIPPLANE4: boolean;
  99602. CLIPPLANE5: boolean;
  99603. CLIPPLANE6: boolean;
  99604. ALPHATEST: boolean;
  99605. DEPTHPREPASS: boolean;
  99606. ALPHAFROMDIFFUSE: boolean;
  99607. POINTSIZE: boolean;
  99608. FOG: boolean;
  99609. SPECULARTERM: boolean;
  99610. DIFFUSEFRESNEL: boolean;
  99611. OPACITYFRESNEL: boolean;
  99612. REFLECTIONFRESNEL: boolean;
  99613. REFRACTIONFRESNEL: boolean;
  99614. EMISSIVEFRESNEL: boolean;
  99615. FRESNEL: boolean;
  99616. NORMAL: boolean;
  99617. UV1: boolean;
  99618. UV2: boolean;
  99619. VERTEXCOLOR: boolean;
  99620. VERTEXALPHA: boolean;
  99621. NUM_BONE_INFLUENCERS: number;
  99622. BonesPerMesh: number;
  99623. BONETEXTURE: boolean;
  99624. INSTANCES: boolean;
  99625. GLOSSINESS: boolean;
  99626. ROUGHNESS: boolean;
  99627. EMISSIVEASILLUMINATION: boolean;
  99628. LINKEMISSIVEWITHDIFFUSE: boolean;
  99629. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99630. LIGHTMAP: boolean;
  99631. LIGHTMAPDIRECTUV: number;
  99632. OBJECTSPACE_NORMALMAP: boolean;
  99633. USELIGHTMAPASSHADOWMAP: boolean;
  99634. REFLECTIONMAP_3D: boolean;
  99635. REFLECTIONMAP_SPHERICAL: boolean;
  99636. REFLECTIONMAP_PLANAR: boolean;
  99637. REFLECTIONMAP_CUBIC: boolean;
  99638. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99639. REFLECTIONMAP_PROJECTION: boolean;
  99640. REFLECTIONMAP_SKYBOX: boolean;
  99641. REFLECTIONMAP_EXPLICIT: boolean;
  99642. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99643. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99644. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99645. INVERTCUBICMAP: boolean;
  99646. LOGARITHMICDEPTH: boolean;
  99647. REFRACTION: boolean;
  99648. REFRACTIONMAP_3D: boolean;
  99649. REFLECTIONOVERALPHA: boolean;
  99650. TWOSIDEDLIGHTING: boolean;
  99651. SHADOWFLOAT: boolean;
  99652. MORPHTARGETS: boolean;
  99653. MORPHTARGETS_NORMAL: boolean;
  99654. MORPHTARGETS_TANGENT: boolean;
  99655. MORPHTARGETS_UV: boolean;
  99656. NUM_MORPH_INFLUENCERS: number;
  99657. NONUNIFORMSCALING: boolean;
  99658. PREMULTIPLYALPHA: boolean;
  99659. IMAGEPROCESSING: boolean;
  99660. VIGNETTE: boolean;
  99661. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99662. VIGNETTEBLENDMODEOPAQUE: boolean;
  99663. TONEMAPPING: boolean;
  99664. TONEMAPPING_ACES: boolean;
  99665. CONTRAST: boolean;
  99666. COLORCURVES: boolean;
  99667. COLORGRADING: boolean;
  99668. COLORGRADING3D: boolean;
  99669. SAMPLER3DGREENDEPTH: boolean;
  99670. SAMPLER3DBGRMAP: boolean;
  99671. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99672. MULTIVIEW: boolean;
  99673. /**
  99674. * If the reflection texture on this material is in linear color space
  99675. * @hidden
  99676. */
  99677. IS_REFLECTION_LINEAR: boolean;
  99678. /**
  99679. * If the refraction texture on this material is in linear color space
  99680. * @hidden
  99681. */
  99682. IS_REFRACTION_LINEAR: boolean;
  99683. EXPOSURE: boolean;
  99684. constructor();
  99685. setReflectionMode(modeToEnable: string): void;
  99686. }
  99687. /**
  99688. * This is the default material used in Babylon. It is the best trade off between quality
  99689. * and performances.
  99690. * @see http://doc.babylonjs.com/babylon101/materials
  99691. */
  99692. export class StandardMaterial extends PushMaterial {
  99693. private _diffuseTexture;
  99694. /**
  99695. * The basic texture of the material as viewed under a light.
  99696. */
  99697. diffuseTexture: Nullable<BaseTexture>;
  99698. private _ambientTexture;
  99699. /**
  99700. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99701. */
  99702. ambientTexture: Nullable<BaseTexture>;
  99703. private _opacityTexture;
  99704. /**
  99705. * Define the transparency of the material from a texture.
  99706. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99707. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99708. */
  99709. opacityTexture: Nullable<BaseTexture>;
  99710. private _reflectionTexture;
  99711. /**
  99712. * Define the texture used to display the reflection.
  99713. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99714. */
  99715. reflectionTexture: Nullable<BaseTexture>;
  99716. private _emissiveTexture;
  99717. /**
  99718. * Define texture of the material as if self lit.
  99719. * This will be mixed in the final result even in the absence of light.
  99720. */
  99721. emissiveTexture: Nullable<BaseTexture>;
  99722. private _specularTexture;
  99723. /**
  99724. * Define how the color and intensity of the highlight given by the light in the material.
  99725. */
  99726. specularTexture: Nullable<BaseTexture>;
  99727. private _bumpTexture;
  99728. /**
  99729. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99730. * 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.
  99731. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99732. */
  99733. bumpTexture: Nullable<BaseTexture>;
  99734. private _lightmapTexture;
  99735. /**
  99736. * Complex lighting can be computationally expensive to compute at runtime.
  99737. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99738. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99739. */
  99740. lightmapTexture: Nullable<BaseTexture>;
  99741. private _refractionTexture;
  99742. /**
  99743. * Define the texture used to display the refraction.
  99744. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99745. */
  99746. refractionTexture: Nullable<BaseTexture>;
  99747. /**
  99748. * The color of the material lit by the environmental background lighting.
  99749. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99750. */
  99751. ambientColor: Color3;
  99752. /**
  99753. * The basic color of the material as viewed under a light.
  99754. */
  99755. diffuseColor: Color3;
  99756. /**
  99757. * Define how the color and intensity of the highlight given by the light in the material.
  99758. */
  99759. specularColor: Color3;
  99760. /**
  99761. * Define the color of the material as if self lit.
  99762. * This will be mixed in the final result even in the absence of light.
  99763. */
  99764. emissiveColor: Color3;
  99765. /**
  99766. * Defines how sharp are the highlights in the material.
  99767. * The bigger the value the sharper giving a more glossy feeling to the result.
  99768. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99769. */
  99770. specularPower: number;
  99771. private _useAlphaFromDiffuseTexture;
  99772. /**
  99773. * Does the transparency come from the diffuse texture alpha channel.
  99774. */
  99775. useAlphaFromDiffuseTexture: boolean;
  99776. private _useEmissiveAsIllumination;
  99777. /**
  99778. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99779. */
  99780. useEmissiveAsIllumination: boolean;
  99781. private _linkEmissiveWithDiffuse;
  99782. /**
  99783. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99784. * the emissive level when the final color is close to one.
  99785. */
  99786. linkEmissiveWithDiffuse: boolean;
  99787. private _useSpecularOverAlpha;
  99788. /**
  99789. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99790. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99791. */
  99792. useSpecularOverAlpha: boolean;
  99793. private _useReflectionOverAlpha;
  99794. /**
  99795. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99796. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99797. */
  99798. useReflectionOverAlpha: boolean;
  99799. private _disableLighting;
  99800. /**
  99801. * Does lights from the scene impacts this material.
  99802. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99803. */
  99804. disableLighting: boolean;
  99805. private _useObjectSpaceNormalMap;
  99806. /**
  99807. * Allows using an object space normal map (instead of tangent space).
  99808. */
  99809. useObjectSpaceNormalMap: boolean;
  99810. private _useParallax;
  99811. /**
  99812. * Is parallax enabled or not.
  99813. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99814. */
  99815. useParallax: boolean;
  99816. private _useParallaxOcclusion;
  99817. /**
  99818. * Is parallax occlusion enabled or not.
  99819. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99820. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99821. */
  99822. useParallaxOcclusion: boolean;
  99823. /**
  99824. * 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.
  99825. */
  99826. parallaxScaleBias: number;
  99827. private _roughness;
  99828. /**
  99829. * Helps to define how blurry the reflections should appears in the material.
  99830. */
  99831. roughness: number;
  99832. /**
  99833. * In case of refraction, define the value of the index of refraction.
  99834. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99835. */
  99836. indexOfRefraction: number;
  99837. /**
  99838. * Invert the refraction texture alongside the y axis.
  99839. * It can be useful with procedural textures or probe for instance.
  99840. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99841. */
  99842. invertRefractionY: boolean;
  99843. /**
  99844. * Defines the alpha limits in alpha test mode.
  99845. */
  99846. alphaCutOff: number;
  99847. private _useLightmapAsShadowmap;
  99848. /**
  99849. * In case of light mapping, define whether the map contains light or shadow informations.
  99850. */
  99851. useLightmapAsShadowmap: boolean;
  99852. private _diffuseFresnelParameters;
  99853. /**
  99854. * Define the diffuse fresnel parameters of the material.
  99855. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99856. */
  99857. diffuseFresnelParameters: FresnelParameters;
  99858. private _opacityFresnelParameters;
  99859. /**
  99860. * Define the opacity fresnel parameters of the material.
  99861. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99862. */
  99863. opacityFresnelParameters: FresnelParameters;
  99864. private _reflectionFresnelParameters;
  99865. /**
  99866. * Define the reflection fresnel parameters of the material.
  99867. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99868. */
  99869. reflectionFresnelParameters: FresnelParameters;
  99870. private _refractionFresnelParameters;
  99871. /**
  99872. * Define the refraction fresnel parameters of the material.
  99873. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99874. */
  99875. refractionFresnelParameters: FresnelParameters;
  99876. private _emissiveFresnelParameters;
  99877. /**
  99878. * Define the emissive fresnel parameters of the material.
  99879. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99880. */
  99881. emissiveFresnelParameters: FresnelParameters;
  99882. private _useReflectionFresnelFromSpecular;
  99883. /**
  99884. * If true automatically deducts the fresnels values from the material specularity.
  99885. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99886. */
  99887. useReflectionFresnelFromSpecular: boolean;
  99888. private _useGlossinessFromSpecularMapAlpha;
  99889. /**
  99890. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99891. */
  99892. useGlossinessFromSpecularMapAlpha: boolean;
  99893. private _maxSimultaneousLights;
  99894. /**
  99895. * Defines the maximum number of lights that can be used in the material
  99896. */
  99897. maxSimultaneousLights: number;
  99898. private _invertNormalMapX;
  99899. /**
  99900. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99901. */
  99902. invertNormalMapX: boolean;
  99903. private _invertNormalMapY;
  99904. /**
  99905. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99906. */
  99907. invertNormalMapY: boolean;
  99908. private _twoSidedLighting;
  99909. /**
  99910. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99911. */
  99912. twoSidedLighting: boolean;
  99913. /**
  99914. * Default configuration related to image processing available in the standard Material.
  99915. */
  99916. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99917. /**
  99918. * Gets the image processing configuration used either in this material.
  99919. */
  99920. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99921. /**
  99922. * Sets the Default image processing configuration used either in the this material.
  99923. *
  99924. * If sets to null, the scene one is in use.
  99925. */
  99926. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99927. /**
  99928. * Keep track of the image processing observer to allow dispose and replace.
  99929. */
  99930. private _imageProcessingObserver;
  99931. /**
  99932. * Attaches a new image processing configuration to the Standard Material.
  99933. * @param configuration
  99934. */
  99935. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99936. /**
  99937. * Gets wether the color curves effect is enabled.
  99938. */
  99939. get cameraColorCurvesEnabled(): boolean;
  99940. /**
  99941. * Sets wether the color curves effect is enabled.
  99942. */
  99943. set cameraColorCurvesEnabled(value: boolean);
  99944. /**
  99945. * Gets wether the color grading effect is enabled.
  99946. */
  99947. get cameraColorGradingEnabled(): boolean;
  99948. /**
  99949. * Gets wether the color grading effect is enabled.
  99950. */
  99951. set cameraColorGradingEnabled(value: boolean);
  99952. /**
  99953. * Gets wether tonemapping is enabled or not.
  99954. */
  99955. get cameraToneMappingEnabled(): boolean;
  99956. /**
  99957. * Sets wether tonemapping is enabled or not
  99958. */
  99959. set cameraToneMappingEnabled(value: boolean);
  99960. /**
  99961. * The camera exposure used on this material.
  99962. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99963. * This corresponds to a photographic exposure.
  99964. */
  99965. get cameraExposure(): number;
  99966. /**
  99967. * The camera exposure used on this material.
  99968. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99969. * This corresponds to a photographic exposure.
  99970. */
  99971. set cameraExposure(value: number);
  99972. /**
  99973. * Gets The camera contrast used on this material.
  99974. */
  99975. get cameraContrast(): number;
  99976. /**
  99977. * Sets The camera contrast used on this material.
  99978. */
  99979. set cameraContrast(value: number);
  99980. /**
  99981. * Gets the Color Grading 2D Lookup Texture.
  99982. */
  99983. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99984. /**
  99985. * Sets the Color Grading 2D Lookup Texture.
  99986. */
  99987. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99988. /**
  99989. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99990. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99991. * 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;
  99992. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99993. */
  99994. get cameraColorCurves(): Nullable<ColorCurves>;
  99995. /**
  99996. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99997. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99998. * 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;
  99999. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100000. */
  100001. set cameraColorCurves(value: Nullable<ColorCurves>);
  100002. /**
  100003. * Custom callback helping to override the default shader used in the material.
  100004. */
  100005. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  100006. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100007. protected _worldViewProjectionMatrix: Matrix;
  100008. protected _globalAmbientColor: Color3;
  100009. protected _useLogarithmicDepth: boolean;
  100010. protected _rebuildInParallel: boolean;
  100011. /**
  100012. * Instantiates a new standard material.
  100013. * This is the default material used in Babylon. It is the best trade off between quality
  100014. * and performances.
  100015. * @see http://doc.babylonjs.com/babylon101/materials
  100016. * @param name Define the name of the material in the scene
  100017. * @param scene Define the scene the material belong to
  100018. */
  100019. constructor(name: string, scene: Scene);
  100020. /**
  100021. * Gets a boolean indicating that current material needs to register RTT
  100022. */
  100023. get hasRenderTargetTextures(): boolean;
  100024. /**
  100025. * Gets the current class name of the material e.g. "StandardMaterial"
  100026. * Mainly use in serialization.
  100027. * @returns the class name
  100028. */
  100029. getClassName(): string;
  100030. /**
  100031. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100032. * You can try switching to logarithmic depth.
  100033. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100034. */
  100035. get useLogarithmicDepth(): boolean;
  100036. set useLogarithmicDepth(value: boolean);
  100037. /**
  100038. * Specifies if the material will require alpha blending
  100039. * @returns a boolean specifying if alpha blending is needed
  100040. */
  100041. needAlphaBlending(): boolean;
  100042. /**
  100043. * Specifies if this material should be rendered in alpha test mode
  100044. * @returns a boolean specifying if an alpha test is needed.
  100045. */
  100046. needAlphaTesting(): boolean;
  100047. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100048. /**
  100049. * Get the texture used for alpha test purpose.
  100050. * @returns the diffuse texture in case of the standard material.
  100051. */
  100052. getAlphaTestTexture(): Nullable<BaseTexture>;
  100053. /**
  100054. * Get if the submesh is ready to be used and all its information available.
  100055. * Child classes can use it to update shaders
  100056. * @param mesh defines the mesh to check
  100057. * @param subMesh defines which submesh to check
  100058. * @param useInstances specifies that instances should be used
  100059. * @returns a boolean indicating that the submesh is ready or not
  100060. */
  100061. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100062. /**
  100063. * Builds the material UBO layouts.
  100064. * Used internally during the effect preparation.
  100065. */
  100066. buildUniformLayout(): void;
  100067. /**
  100068. * Unbinds the material from the mesh
  100069. */
  100070. unbind(): void;
  100071. /**
  100072. * Binds the submesh to this material by preparing the effect and shader to draw
  100073. * @param world defines the world transformation matrix
  100074. * @param mesh defines the mesh containing the submesh
  100075. * @param subMesh defines the submesh to bind the material to
  100076. */
  100077. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100078. /**
  100079. * Get the list of animatables in the material.
  100080. * @returns the list of animatables object used in the material
  100081. */
  100082. getAnimatables(): IAnimatable[];
  100083. /**
  100084. * Gets the active textures from the material
  100085. * @returns an array of textures
  100086. */
  100087. getActiveTextures(): BaseTexture[];
  100088. /**
  100089. * Specifies if the material uses a texture
  100090. * @param texture defines the texture to check against the material
  100091. * @returns a boolean specifying if the material uses the texture
  100092. */
  100093. hasTexture(texture: BaseTexture): boolean;
  100094. /**
  100095. * Disposes the material
  100096. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100097. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100098. */
  100099. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100100. /**
  100101. * Makes a duplicate of the material, and gives it a new name
  100102. * @param name defines the new name for the duplicated material
  100103. * @returns the cloned material
  100104. */
  100105. clone(name: string): StandardMaterial;
  100106. /**
  100107. * Serializes this material in a JSON representation
  100108. * @returns the serialized material object
  100109. */
  100110. serialize(): any;
  100111. /**
  100112. * Creates a standard material from parsed material data
  100113. * @param source defines the JSON representation of the material
  100114. * @param scene defines the hosting scene
  100115. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100116. * @returns a new standard material
  100117. */
  100118. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100119. /**
  100120. * Are diffuse textures enabled in the application.
  100121. */
  100122. static get DiffuseTextureEnabled(): boolean;
  100123. static set DiffuseTextureEnabled(value: boolean);
  100124. /**
  100125. * Are ambient textures enabled in the application.
  100126. */
  100127. static get AmbientTextureEnabled(): boolean;
  100128. static set AmbientTextureEnabled(value: boolean);
  100129. /**
  100130. * Are opacity textures enabled in the application.
  100131. */
  100132. static get OpacityTextureEnabled(): boolean;
  100133. static set OpacityTextureEnabled(value: boolean);
  100134. /**
  100135. * Are reflection textures enabled in the application.
  100136. */
  100137. static get ReflectionTextureEnabled(): boolean;
  100138. static set ReflectionTextureEnabled(value: boolean);
  100139. /**
  100140. * Are emissive textures enabled in the application.
  100141. */
  100142. static get EmissiveTextureEnabled(): boolean;
  100143. static set EmissiveTextureEnabled(value: boolean);
  100144. /**
  100145. * Are specular textures enabled in the application.
  100146. */
  100147. static get SpecularTextureEnabled(): boolean;
  100148. static set SpecularTextureEnabled(value: boolean);
  100149. /**
  100150. * Are bump textures enabled in the application.
  100151. */
  100152. static get BumpTextureEnabled(): boolean;
  100153. static set BumpTextureEnabled(value: boolean);
  100154. /**
  100155. * Are lightmap textures enabled in the application.
  100156. */
  100157. static get LightmapTextureEnabled(): boolean;
  100158. static set LightmapTextureEnabled(value: boolean);
  100159. /**
  100160. * Are refraction textures enabled in the application.
  100161. */
  100162. static get RefractionTextureEnabled(): boolean;
  100163. static set RefractionTextureEnabled(value: boolean);
  100164. /**
  100165. * Are color grading textures enabled in the application.
  100166. */
  100167. static get ColorGradingTextureEnabled(): boolean;
  100168. static set ColorGradingTextureEnabled(value: boolean);
  100169. /**
  100170. * Are fresnels enabled in the application.
  100171. */
  100172. static get FresnelEnabled(): boolean;
  100173. static set FresnelEnabled(value: boolean);
  100174. }
  100175. }
  100176. declare module BABYLON {
  100177. /**
  100178. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100179. *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.
  100180. * The SPS is also a particle system. It provides some methods to manage the particles.
  100181. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100182. *
  100183. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100184. */
  100185. export class SolidParticleSystem implements IDisposable {
  100186. /**
  100187. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100188. * Example : var p = SPS.particles[i];
  100189. */
  100190. particles: SolidParticle[];
  100191. /**
  100192. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100193. */
  100194. nbParticles: number;
  100195. /**
  100196. * If the particles must ever face the camera (default false). Useful for planar particles.
  100197. */
  100198. billboard: boolean;
  100199. /**
  100200. * Recompute normals when adding a shape
  100201. */
  100202. recomputeNormals: boolean;
  100203. /**
  100204. * This a counter ofr your own usage. It's not set by any SPS functions.
  100205. */
  100206. counter: number;
  100207. /**
  100208. * The SPS name. This name is also given to the underlying mesh.
  100209. */
  100210. name: string;
  100211. /**
  100212. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100213. */
  100214. mesh: Mesh;
  100215. /**
  100216. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100217. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100218. */
  100219. vars: any;
  100220. /**
  100221. * This array is populated when the SPS is set as 'pickable'.
  100222. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100223. * Each element of this array is an object `{idx: int, faceId: int}`.
  100224. * `idx` is the picked particle index in the `SPS.particles` array
  100225. * `faceId` is the picked face index counted within this particle.
  100226. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100227. */
  100228. pickedParticles: {
  100229. idx: number;
  100230. faceId: number;
  100231. }[];
  100232. /**
  100233. * This array is populated when `enableDepthSort` is set to true.
  100234. * Each element of this array is an instance of the class DepthSortedParticle.
  100235. */
  100236. depthSortedParticles: DepthSortedParticle[];
  100237. /**
  100238. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100239. * @hidden
  100240. */
  100241. _bSphereOnly: boolean;
  100242. /**
  100243. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100244. * @hidden
  100245. */
  100246. _bSphereRadiusFactor: number;
  100247. private _scene;
  100248. private _positions;
  100249. private _indices;
  100250. private _normals;
  100251. private _colors;
  100252. private _uvs;
  100253. private _indices32;
  100254. private _positions32;
  100255. private _normals32;
  100256. private _fixedNormal32;
  100257. private _colors32;
  100258. private _uvs32;
  100259. private _index;
  100260. private _updatable;
  100261. private _pickable;
  100262. private _isVisibilityBoxLocked;
  100263. private _alwaysVisible;
  100264. private _depthSort;
  100265. private _expandable;
  100266. private _shapeCounter;
  100267. private _copy;
  100268. private _color;
  100269. private _computeParticleColor;
  100270. private _computeParticleTexture;
  100271. private _computeParticleRotation;
  100272. private _computeParticleVertex;
  100273. private _computeBoundingBox;
  100274. private _depthSortParticles;
  100275. private _camera;
  100276. private _mustUnrotateFixedNormals;
  100277. private _particlesIntersect;
  100278. private _needs32Bits;
  100279. private _isNotBuilt;
  100280. private _lastParticleId;
  100281. private _idxOfId;
  100282. private _multimaterialEnabled;
  100283. private _useModelMaterial;
  100284. private _indicesByMaterial;
  100285. private _materialIndexes;
  100286. private _depthSortFunction;
  100287. private _materialSortFunction;
  100288. private _materials;
  100289. private _multimaterial;
  100290. private _materialIndexesById;
  100291. private _defaultMaterial;
  100292. private _autoUpdateSubMeshes;
  100293. /**
  100294. * Creates a SPS (Solid Particle System) object.
  100295. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100296. * @param scene (Scene) is the scene in which the SPS is added.
  100297. * @param options defines the options of the sps e.g.
  100298. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100299. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100300. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100301. * * 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.
  100302. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100303. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100304. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100305. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100306. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100307. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100308. */
  100309. constructor(name: string, scene: Scene, options?: {
  100310. updatable?: boolean;
  100311. isPickable?: boolean;
  100312. enableDepthSort?: boolean;
  100313. particleIntersection?: boolean;
  100314. boundingSphereOnly?: boolean;
  100315. bSphereRadiusFactor?: number;
  100316. expandable?: boolean;
  100317. useModelMaterial?: boolean;
  100318. enableMultiMaterial?: boolean;
  100319. });
  100320. /**
  100321. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100322. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100323. * @returns the created mesh
  100324. */
  100325. buildMesh(): Mesh;
  100326. /**
  100327. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100328. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100329. * Thus the particles generated from `digest()` have their property `position` set yet.
  100330. * @param mesh ( Mesh ) is the mesh to be digested
  100331. * @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
  100332. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100333. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100334. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100335. * @returns the current SPS
  100336. */
  100337. digest(mesh: Mesh, options?: {
  100338. facetNb?: number;
  100339. number?: number;
  100340. delta?: number;
  100341. storage?: [];
  100342. }): SolidParticleSystem;
  100343. /**
  100344. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100345. * @hidden
  100346. */
  100347. private _unrotateFixedNormals;
  100348. /**
  100349. * Resets the temporary working copy particle
  100350. * @hidden
  100351. */
  100352. private _resetCopy;
  100353. /**
  100354. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100355. * @param p the current index in the positions array to be updated
  100356. * @param ind the current index in the indices array
  100357. * @param shape a Vector3 array, the shape geometry
  100358. * @param positions the positions array to be updated
  100359. * @param meshInd the shape indices array
  100360. * @param indices the indices array to be updated
  100361. * @param meshUV the shape uv array
  100362. * @param uvs the uv array to be updated
  100363. * @param meshCol the shape color array
  100364. * @param colors the color array to be updated
  100365. * @param meshNor the shape normals array
  100366. * @param normals the normals array to be updated
  100367. * @param idx the particle index
  100368. * @param idxInShape the particle index in its shape
  100369. * @param options the addShape() method passed options
  100370. * @model the particle model
  100371. * @hidden
  100372. */
  100373. private _meshBuilder;
  100374. /**
  100375. * Returns a shape Vector3 array from positions float array
  100376. * @param positions float array
  100377. * @returns a vector3 array
  100378. * @hidden
  100379. */
  100380. private _posToShape;
  100381. /**
  100382. * Returns a shapeUV array from a float uvs (array deep copy)
  100383. * @param uvs as a float array
  100384. * @returns a shapeUV array
  100385. * @hidden
  100386. */
  100387. private _uvsToShapeUV;
  100388. /**
  100389. * Adds a new particle object in the particles array
  100390. * @param idx particle index in particles array
  100391. * @param id particle id
  100392. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100393. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100394. * @param model particle ModelShape object
  100395. * @param shapeId model shape identifier
  100396. * @param idxInShape index of the particle in the current model
  100397. * @param bInfo model bounding info object
  100398. * @param storage target storage array, if any
  100399. * @hidden
  100400. */
  100401. private _addParticle;
  100402. /**
  100403. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100404. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100405. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100406. * @param nb (positive integer) the number of particles to be created from this model
  100407. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100408. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100409. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100410. * @returns the number of shapes in the system
  100411. */
  100412. addShape(mesh: Mesh, nb: number, options?: {
  100413. positionFunction?: any;
  100414. vertexFunction?: any;
  100415. storage?: [];
  100416. }): number;
  100417. /**
  100418. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100419. * @hidden
  100420. */
  100421. private _rebuildParticle;
  100422. /**
  100423. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100424. * @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.
  100425. * @returns the SPS.
  100426. */
  100427. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100428. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100429. * Returns an array with the removed particles.
  100430. * 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.
  100431. * The SPS can't be empty so at least one particle needs to remain in place.
  100432. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100433. * @param start index of the first particle to remove
  100434. * @param end index of the last particle to remove (included)
  100435. * @returns an array populated with the removed particles
  100436. */
  100437. removeParticles(start: number, end: number): SolidParticle[];
  100438. /**
  100439. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100440. * @param solidParticleArray an array populated with Solid Particles objects
  100441. * @returns the SPS
  100442. */
  100443. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100444. /**
  100445. * Creates a new particle and modifies the SPS mesh geometry :
  100446. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100447. * - calls _addParticle() to populate the particle array
  100448. * factorized code from addShape() and insertParticlesFromArray()
  100449. * @param idx particle index in the particles array
  100450. * @param i particle index in its shape
  100451. * @param modelShape particle ModelShape object
  100452. * @param shape shape vertex array
  100453. * @param meshInd shape indices array
  100454. * @param meshUV shape uv array
  100455. * @param meshCol shape color array
  100456. * @param meshNor shape normals array
  100457. * @param bbInfo shape bounding info
  100458. * @param storage target particle storage
  100459. * @options addShape() passed options
  100460. * @hidden
  100461. */
  100462. private _insertNewParticle;
  100463. /**
  100464. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100465. * This method calls `updateParticle()` for each particle of the SPS.
  100466. * For an animated SPS, it is usually called within the render loop.
  100467. * 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.
  100468. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100469. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100470. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100471. * @returns the SPS.
  100472. */
  100473. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100474. /**
  100475. * Disposes the SPS.
  100476. */
  100477. dispose(): void;
  100478. /**
  100479. * Returns a SolidParticle object from its identifier : particle.id
  100480. * @param id (integer) the particle Id
  100481. * @returns the searched particle or null if not found in the SPS.
  100482. */
  100483. getParticleById(id: number): Nullable<SolidParticle>;
  100484. /**
  100485. * Returns a new array populated with the particles having the passed shapeId.
  100486. * @param shapeId (integer) the shape identifier
  100487. * @returns a new solid particle array
  100488. */
  100489. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100490. /**
  100491. * Populates the passed array "ref" with the particles having the passed shapeId.
  100492. * @param shapeId the shape identifier
  100493. * @returns the SPS
  100494. * @param ref
  100495. */
  100496. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100497. /**
  100498. * Computes the required SubMeshes according the materials assigned to the particles.
  100499. * @returns the solid particle system.
  100500. * Does nothing if called before the SPS mesh is built.
  100501. */
  100502. computeSubMeshes(): SolidParticleSystem;
  100503. /**
  100504. * Sorts the solid particles by material when MultiMaterial is enabled.
  100505. * Updates the indices32 array.
  100506. * Updates the indicesByMaterial array.
  100507. * Updates the mesh indices array.
  100508. * @returns the SPS
  100509. * @hidden
  100510. */
  100511. private _sortParticlesByMaterial;
  100512. /**
  100513. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100514. * @hidden
  100515. */
  100516. private _setMaterialIndexesById;
  100517. /**
  100518. * Returns an array with unique values of Materials from the passed array
  100519. * @param array the material array to be checked and filtered
  100520. * @hidden
  100521. */
  100522. private _filterUniqueMaterialId;
  100523. /**
  100524. * Sets a new Standard Material as _defaultMaterial if not already set.
  100525. * @hidden
  100526. */
  100527. private _setDefaultMaterial;
  100528. /**
  100529. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100530. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100531. * @returns the SPS.
  100532. */
  100533. refreshVisibleSize(): SolidParticleSystem;
  100534. /**
  100535. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100536. * @param size the size (float) of the visibility box
  100537. * note : this doesn't lock the SPS mesh bounding box.
  100538. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100539. */
  100540. setVisibilityBox(size: number): void;
  100541. /**
  100542. * Gets whether the SPS as always visible or not
  100543. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100544. */
  100545. get isAlwaysVisible(): boolean;
  100546. /**
  100547. * Sets the SPS as always visible or not
  100548. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100549. */
  100550. set isAlwaysVisible(val: boolean);
  100551. /**
  100552. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100553. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100554. */
  100555. set isVisibilityBoxLocked(val: boolean);
  100556. /**
  100557. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100558. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100559. */
  100560. get isVisibilityBoxLocked(): boolean;
  100561. /**
  100562. * Tells to `setParticles()` to compute the particle rotations or not.
  100563. * Default value : true. The SPS is faster when it's set to false.
  100564. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100565. */
  100566. set computeParticleRotation(val: boolean);
  100567. /**
  100568. * Tells to `setParticles()` to compute the particle colors or not.
  100569. * Default value : true. The SPS is faster when it's set to false.
  100570. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100571. */
  100572. set computeParticleColor(val: boolean);
  100573. set computeParticleTexture(val: boolean);
  100574. /**
  100575. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100576. * Default value : false. The SPS is faster when it's set to false.
  100577. * Note : the particle custom vertex positions aren't stored values.
  100578. */
  100579. set computeParticleVertex(val: boolean);
  100580. /**
  100581. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100582. */
  100583. set computeBoundingBox(val: boolean);
  100584. /**
  100585. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100586. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100587. * Default : `true`
  100588. */
  100589. set depthSortParticles(val: boolean);
  100590. /**
  100591. * Gets if `setParticles()` computes the particle rotations or not.
  100592. * Default value : true. The SPS is faster when it's set to false.
  100593. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100594. */
  100595. get computeParticleRotation(): boolean;
  100596. /**
  100597. * Gets if `setParticles()` computes the particle colors or not.
  100598. * Default value : true. The SPS is faster when it's set to false.
  100599. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100600. */
  100601. get computeParticleColor(): boolean;
  100602. /**
  100603. * Gets if `setParticles()` computes the particle textures or not.
  100604. * Default value : true. The SPS is faster when it's set to false.
  100605. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100606. */
  100607. get computeParticleTexture(): boolean;
  100608. /**
  100609. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100610. * Default value : false. The SPS is faster when it's set to false.
  100611. * Note : the particle custom vertex positions aren't stored values.
  100612. */
  100613. get computeParticleVertex(): boolean;
  100614. /**
  100615. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100616. */
  100617. get computeBoundingBox(): boolean;
  100618. /**
  100619. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100620. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100621. * Default : `true`
  100622. */
  100623. get depthSortParticles(): boolean;
  100624. /**
  100625. * Gets if the SPS is created as expandable at construction time.
  100626. * Default : `false`
  100627. */
  100628. get expandable(): boolean;
  100629. /**
  100630. * Gets if the SPS supports the Multi Materials
  100631. */
  100632. get multimaterialEnabled(): boolean;
  100633. /**
  100634. * Gets if the SPS uses the model materials for its own multimaterial.
  100635. */
  100636. get useModelMaterial(): boolean;
  100637. /**
  100638. * The SPS used material array.
  100639. */
  100640. get materials(): Material[];
  100641. /**
  100642. * Sets the SPS MultiMaterial from the passed materials.
  100643. * Note : the passed array is internally copied and not used then by reference.
  100644. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100645. */
  100646. setMultiMaterial(materials: Material[]): void;
  100647. /**
  100648. * The SPS computed multimaterial object
  100649. */
  100650. get multimaterial(): MultiMaterial;
  100651. set multimaterial(mm: MultiMaterial);
  100652. /**
  100653. * If the subMeshes must be updated on the next call to setParticles()
  100654. */
  100655. get autoUpdateSubMeshes(): boolean;
  100656. set autoUpdateSubMeshes(val: boolean);
  100657. /**
  100658. * This function does nothing. It may be overwritten to set all the particle first values.
  100659. * The SPS doesn't call this function, you may have to call it by your own.
  100660. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100661. */
  100662. initParticles(): void;
  100663. /**
  100664. * This function does nothing. It may be overwritten to recycle a particle.
  100665. * The SPS doesn't call this function, you may have to call it by your own.
  100666. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100667. * @param particle The particle to recycle
  100668. * @returns the recycled particle
  100669. */
  100670. recycleParticle(particle: SolidParticle): SolidParticle;
  100671. /**
  100672. * Updates a particle : this function should be overwritten by the user.
  100673. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100674. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100675. * @example : just set a particle position or velocity and recycle conditions
  100676. * @param particle The particle to update
  100677. * @returns the updated particle
  100678. */
  100679. updateParticle(particle: SolidParticle): SolidParticle;
  100680. /**
  100681. * Updates a vertex of a particle : it can be overwritten by the user.
  100682. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100683. * @param particle the current particle
  100684. * @param vertex the current index of the current particle
  100685. * @param pt the index of the current vertex in the particle shape
  100686. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100687. * @example : just set a vertex particle position
  100688. * @returns the updated vertex
  100689. */
  100690. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100691. /**
  100692. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100693. * This does nothing and may be overwritten by the user.
  100694. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100695. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100696. * @param update the boolean update value actually passed to setParticles()
  100697. */
  100698. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100699. /**
  100700. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100701. * This will be passed three parameters.
  100702. * This does nothing and may be overwritten by the user.
  100703. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100704. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100705. * @param update the boolean update value actually passed to setParticles()
  100706. */
  100707. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100708. }
  100709. }
  100710. declare module BABYLON {
  100711. /**
  100712. * Represents one particle of a solid particle system.
  100713. */
  100714. export class SolidParticle {
  100715. /**
  100716. * particle global index
  100717. */
  100718. idx: number;
  100719. /**
  100720. * particle identifier
  100721. */
  100722. id: number;
  100723. /**
  100724. * The color of the particle
  100725. */
  100726. color: Nullable<Color4>;
  100727. /**
  100728. * The world space position of the particle.
  100729. */
  100730. position: Vector3;
  100731. /**
  100732. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100733. */
  100734. rotation: Vector3;
  100735. /**
  100736. * The world space rotation quaternion of the particle.
  100737. */
  100738. rotationQuaternion: Nullable<Quaternion>;
  100739. /**
  100740. * The scaling of the particle.
  100741. */
  100742. scaling: Vector3;
  100743. /**
  100744. * The uvs of the particle.
  100745. */
  100746. uvs: Vector4;
  100747. /**
  100748. * The current speed of the particle.
  100749. */
  100750. velocity: Vector3;
  100751. /**
  100752. * The pivot point in the particle local space.
  100753. */
  100754. pivot: Vector3;
  100755. /**
  100756. * Must the particle be translated from its pivot point in its local space ?
  100757. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100758. * Default : false
  100759. */
  100760. translateFromPivot: boolean;
  100761. /**
  100762. * Is the particle active or not ?
  100763. */
  100764. alive: boolean;
  100765. /**
  100766. * Is the particle visible or not ?
  100767. */
  100768. isVisible: boolean;
  100769. /**
  100770. * Index of this particle in the global "positions" array (Internal use)
  100771. * @hidden
  100772. */
  100773. _pos: number;
  100774. /**
  100775. * @hidden Index of this particle in the global "indices" array (Internal use)
  100776. */
  100777. _ind: number;
  100778. /**
  100779. * @hidden ModelShape of this particle (Internal use)
  100780. */
  100781. _model: ModelShape;
  100782. /**
  100783. * ModelShape id of this particle
  100784. */
  100785. shapeId: number;
  100786. /**
  100787. * Index of the particle in its shape id
  100788. */
  100789. idxInShape: number;
  100790. /**
  100791. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100792. */
  100793. _modelBoundingInfo: BoundingInfo;
  100794. /**
  100795. * @hidden Particle BoundingInfo object (Internal use)
  100796. */
  100797. _boundingInfo: BoundingInfo;
  100798. /**
  100799. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100800. */
  100801. _sps: SolidParticleSystem;
  100802. /**
  100803. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100804. */
  100805. _stillInvisible: boolean;
  100806. /**
  100807. * @hidden Last computed particle rotation matrix
  100808. */
  100809. _rotationMatrix: number[];
  100810. /**
  100811. * Parent particle Id, if any.
  100812. * Default null.
  100813. */
  100814. parentId: Nullable<number>;
  100815. /**
  100816. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100817. */
  100818. materialIndex: Nullable<number>;
  100819. /**
  100820. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100821. * The possible values are :
  100822. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100823. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100824. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100825. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100826. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100827. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100828. * */
  100829. cullingStrategy: number;
  100830. /**
  100831. * @hidden Internal global position in the SPS.
  100832. */
  100833. _globalPosition: Vector3;
  100834. /**
  100835. * Creates a Solid Particle object.
  100836. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100837. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100838. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100839. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100840. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100841. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100842. * @param shapeId (integer) is the model shape identifier in the SPS.
  100843. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100844. * @param sps defines the sps it is associated to
  100845. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100846. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100847. */
  100848. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100849. /**
  100850. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100851. * @param target the particle target
  100852. * @returns the current particle
  100853. */
  100854. copyToRef(target: SolidParticle): SolidParticle;
  100855. /**
  100856. * Legacy support, changed scale to scaling
  100857. */
  100858. get scale(): Vector3;
  100859. /**
  100860. * Legacy support, changed scale to scaling
  100861. */
  100862. set scale(scale: Vector3);
  100863. /**
  100864. * Legacy support, changed quaternion to rotationQuaternion
  100865. */
  100866. get quaternion(): Nullable<Quaternion>;
  100867. /**
  100868. * Legacy support, changed quaternion to rotationQuaternion
  100869. */
  100870. set quaternion(q: Nullable<Quaternion>);
  100871. /**
  100872. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100873. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100874. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100875. * @returns true if it intersects
  100876. */
  100877. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100878. /**
  100879. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100880. * A particle is in the frustum if its bounding box intersects the frustum
  100881. * @param frustumPlanes defines the frustum to test
  100882. * @returns true if the particle is in the frustum planes
  100883. */
  100884. isInFrustum(frustumPlanes: Plane[]): boolean;
  100885. /**
  100886. * get the rotation matrix of the particle
  100887. * @hidden
  100888. */
  100889. getRotationMatrix(m: Matrix): void;
  100890. }
  100891. /**
  100892. * Represents the shape of the model used by one particle of a solid particle system.
  100893. * SPS internal tool, don't use it manually.
  100894. */
  100895. export class ModelShape {
  100896. /**
  100897. * The shape id
  100898. * @hidden
  100899. */
  100900. shapeID: number;
  100901. /**
  100902. * flat array of model positions (internal use)
  100903. * @hidden
  100904. */
  100905. _shape: Vector3[];
  100906. /**
  100907. * flat array of model UVs (internal use)
  100908. * @hidden
  100909. */
  100910. _shapeUV: number[];
  100911. /**
  100912. * color array of the model
  100913. * @hidden
  100914. */
  100915. _shapeColors: number[];
  100916. /**
  100917. * indices array of the model
  100918. * @hidden
  100919. */
  100920. _indices: number[];
  100921. /**
  100922. * normals array of the model
  100923. * @hidden
  100924. */
  100925. _normals: number[];
  100926. /**
  100927. * length of the shape in the model indices array (internal use)
  100928. * @hidden
  100929. */
  100930. _indicesLength: number;
  100931. /**
  100932. * Custom position function (internal use)
  100933. * @hidden
  100934. */
  100935. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100936. /**
  100937. * Custom vertex function (internal use)
  100938. * @hidden
  100939. */
  100940. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100941. /**
  100942. * Model material (internal use)
  100943. * @hidden
  100944. */
  100945. _material: Nullable<Material>;
  100946. /**
  100947. * 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.
  100948. * SPS internal tool, don't use it manually.
  100949. * @hidden
  100950. */
  100951. 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>);
  100952. }
  100953. /**
  100954. * Represents a Depth Sorted Particle in the solid particle system.
  100955. * @hidden
  100956. */
  100957. export class DepthSortedParticle {
  100958. /**
  100959. * Index of the particle in the "indices" array
  100960. */
  100961. ind: number;
  100962. /**
  100963. * Length of the particle shape in the "indices" array
  100964. */
  100965. indicesLength: number;
  100966. /**
  100967. * Squared distance from the particle to the camera
  100968. */
  100969. sqDistance: number;
  100970. /**
  100971. * Material index when used with MultiMaterials
  100972. */
  100973. materialIndex: number;
  100974. /**
  100975. * Creates a new sorted particle
  100976. * @param materialIndex
  100977. */
  100978. constructor(ind: number, indLength: number, materialIndex: number);
  100979. }
  100980. }
  100981. declare module BABYLON {
  100982. /**
  100983. * @hidden
  100984. */
  100985. export class _MeshCollisionData {
  100986. _checkCollisions: boolean;
  100987. _collisionMask: number;
  100988. _collisionGroup: number;
  100989. _collider: Nullable<Collider>;
  100990. _oldPositionForCollisions: Vector3;
  100991. _diffPositionForCollisions: Vector3;
  100992. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100993. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100994. }
  100995. }
  100996. declare module BABYLON {
  100997. /** @hidden */
  100998. class _FacetDataStorage {
  100999. facetPositions: Vector3[];
  101000. facetNormals: Vector3[];
  101001. facetPartitioning: number[][];
  101002. facetNb: number;
  101003. partitioningSubdivisions: number;
  101004. partitioningBBoxRatio: number;
  101005. facetDataEnabled: boolean;
  101006. facetParameters: any;
  101007. bbSize: Vector3;
  101008. subDiv: {
  101009. max: number;
  101010. X: number;
  101011. Y: number;
  101012. Z: number;
  101013. };
  101014. facetDepthSort: boolean;
  101015. facetDepthSortEnabled: boolean;
  101016. depthSortedIndices: IndicesArray;
  101017. depthSortedFacets: {
  101018. ind: number;
  101019. sqDistance: number;
  101020. }[];
  101021. facetDepthSortFunction: (f1: {
  101022. ind: number;
  101023. sqDistance: number;
  101024. }, f2: {
  101025. ind: number;
  101026. sqDistance: number;
  101027. }) => number;
  101028. facetDepthSortFrom: Vector3;
  101029. facetDepthSortOrigin: Vector3;
  101030. invertedMatrix: Matrix;
  101031. }
  101032. /**
  101033. * @hidden
  101034. **/
  101035. class _InternalAbstractMeshDataInfo {
  101036. _hasVertexAlpha: boolean;
  101037. _useVertexColors: boolean;
  101038. _numBoneInfluencers: number;
  101039. _applyFog: boolean;
  101040. _receiveShadows: boolean;
  101041. _facetData: _FacetDataStorage;
  101042. _visibility: number;
  101043. _skeleton: Nullable<Skeleton>;
  101044. _layerMask: number;
  101045. _computeBonesUsingShaders: boolean;
  101046. _isActive: boolean;
  101047. _onlyForInstances: boolean;
  101048. _isActiveIntermediate: boolean;
  101049. _onlyForInstancesIntermediate: boolean;
  101050. _actAsRegularMesh: boolean;
  101051. }
  101052. /**
  101053. * Class used to store all common mesh properties
  101054. */
  101055. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101056. /** No occlusion */
  101057. static OCCLUSION_TYPE_NONE: number;
  101058. /** Occlusion set to optimisitic */
  101059. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101060. /** Occlusion set to strict */
  101061. static OCCLUSION_TYPE_STRICT: number;
  101062. /** Use an accurante occlusion algorithm */
  101063. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101064. /** Use a conservative occlusion algorithm */
  101065. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101066. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101067. * Test order :
  101068. * Is the bounding sphere outside the frustum ?
  101069. * If not, are the bounding box vertices outside the frustum ?
  101070. * It not, then the cullable object is in the frustum.
  101071. */
  101072. static readonly CULLINGSTRATEGY_STANDARD: number;
  101073. /** Culling strategy : Bounding Sphere Only.
  101074. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101075. * It's also less accurate than the standard because some not visible objects can still be selected.
  101076. * Test : is the bounding sphere outside the frustum ?
  101077. * If not, then the cullable object is in the frustum.
  101078. */
  101079. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101080. /** Culling strategy : Optimistic Inclusion.
  101081. * This in an inclusion test first, then the standard exclusion test.
  101082. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101083. * 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.
  101084. * Anyway, it's as accurate as the standard strategy.
  101085. * Test :
  101086. * Is the cullable object bounding sphere center in the frustum ?
  101087. * If not, apply the default culling strategy.
  101088. */
  101089. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101090. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101091. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101092. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101093. * 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.
  101094. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101095. * Test :
  101096. * Is the cullable object bounding sphere center in the frustum ?
  101097. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101098. */
  101099. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101100. /**
  101101. * No billboard
  101102. */
  101103. static get BILLBOARDMODE_NONE(): number;
  101104. /** Billboard on X axis */
  101105. static get BILLBOARDMODE_X(): number;
  101106. /** Billboard on Y axis */
  101107. static get BILLBOARDMODE_Y(): number;
  101108. /** Billboard on Z axis */
  101109. static get BILLBOARDMODE_Z(): number;
  101110. /** Billboard on all axes */
  101111. static get BILLBOARDMODE_ALL(): number;
  101112. /** Billboard on using position instead of orientation */
  101113. static get BILLBOARDMODE_USE_POSITION(): number;
  101114. /** @hidden */
  101115. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101116. /**
  101117. * The culling strategy to use to check whether the mesh must be rendered or not.
  101118. * This value can be changed at any time and will be used on the next render mesh selection.
  101119. * The possible values are :
  101120. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101121. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101122. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101123. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101124. * Please read each static variable documentation to get details about the culling process.
  101125. * */
  101126. cullingStrategy: number;
  101127. /**
  101128. * Gets the number of facets in the mesh
  101129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101130. */
  101131. get facetNb(): number;
  101132. /**
  101133. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101134. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101135. */
  101136. get partitioningSubdivisions(): number;
  101137. set partitioningSubdivisions(nb: number);
  101138. /**
  101139. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101140. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101141. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101142. */
  101143. get partitioningBBoxRatio(): number;
  101144. set partitioningBBoxRatio(ratio: number);
  101145. /**
  101146. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101147. * Works only for updatable meshes.
  101148. * Doesn't work with multi-materials
  101149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101150. */
  101151. get mustDepthSortFacets(): boolean;
  101152. set mustDepthSortFacets(sort: boolean);
  101153. /**
  101154. * The location (Vector3) where the facet depth sort must be computed from.
  101155. * By default, the active camera position.
  101156. * Used only when facet depth sort is enabled
  101157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101158. */
  101159. get facetDepthSortFrom(): Vector3;
  101160. set facetDepthSortFrom(location: Vector3);
  101161. /**
  101162. * gets a boolean indicating if facetData is enabled
  101163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101164. */
  101165. get isFacetDataEnabled(): boolean;
  101166. /** @hidden */
  101167. _updateNonUniformScalingState(value: boolean): boolean;
  101168. /**
  101169. * An event triggered when this mesh collides with another one
  101170. */
  101171. onCollideObservable: Observable<AbstractMesh>;
  101172. /** Set a function to call when this mesh collides with another one */
  101173. set onCollide(callback: () => void);
  101174. /**
  101175. * An event triggered when the collision's position changes
  101176. */
  101177. onCollisionPositionChangeObservable: Observable<Vector3>;
  101178. /** Set a function to call when the collision's position changes */
  101179. set onCollisionPositionChange(callback: () => void);
  101180. /**
  101181. * An event triggered when material is changed
  101182. */
  101183. onMaterialChangedObservable: Observable<AbstractMesh>;
  101184. /**
  101185. * Gets or sets the orientation for POV movement & rotation
  101186. */
  101187. definedFacingForward: boolean;
  101188. /** @hidden */
  101189. _occlusionQuery: Nullable<WebGLQuery>;
  101190. /** @hidden */
  101191. _renderingGroup: Nullable<RenderingGroup>;
  101192. /**
  101193. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101194. */
  101195. get visibility(): number;
  101196. /**
  101197. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101198. */
  101199. set visibility(value: number);
  101200. /** Gets or sets the alpha index used to sort transparent meshes
  101201. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101202. */
  101203. alphaIndex: number;
  101204. /**
  101205. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101206. */
  101207. isVisible: boolean;
  101208. /**
  101209. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101210. */
  101211. isPickable: boolean;
  101212. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101213. showSubMeshesBoundingBox: boolean;
  101214. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101215. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101216. */
  101217. isBlocker: boolean;
  101218. /**
  101219. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101220. */
  101221. enablePointerMoveEvents: boolean;
  101222. /**
  101223. * Specifies the rendering group id for this mesh (0 by default)
  101224. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101225. */
  101226. renderingGroupId: number;
  101227. private _material;
  101228. /** Gets or sets current material */
  101229. get material(): Nullable<Material>;
  101230. set material(value: Nullable<Material>);
  101231. /**
  101232. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101233. * @see http://doc.babylonjs.com/babylon101/shadows
  101234. */
  101235. get receiveShadows(): boolean;
  101236. set receiveShadows(value: boolean);
  101237. /** Defines color to use when rendering outline */
  101238. outlineColor: Color3;
  101239. /** Define width to use when rendering outline */
  101240. outlineWidth: number;
  101241. /** Defines color to use when rendering overlay */
  101242. overlayColor: Color3;
  101243. /** Defines alpha to use when rendering overlay */
  101244. overlayAlpha: number;
  101245. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101246. get hasVertexAlpha(): boolean;
  101247. set hasVertexAlpha(value: boolean);
  101248. /** 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) */
  101249. get useVertexColors(): boolean;
  101250. set useVertexColors(value: boolean);
  101251. /**
  101252. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101253. */
  101254. get computeBonesUsingShaders(): boolean;
  101255. set computeBonesUsingShaders(value: boolean);
  101256. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101257. get numBoneInfluencers(): number;
  101258. set numBoneInfluencers(value: number);
  101259. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101260. get applyFog(): boolean;
  101261. set applyFog(value: boolean);
  101262. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101263. useOctreeForRenderingSelection: boolean;
  101264. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101265. useOctreeForPicking: boolean;
  101266. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101267. useOctreeForCollisions: boolean;
  101268. /**
  101269. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101270. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101271. */
  101272. get layerMask(): number;
  101273. set layerMask(value: number);
  101274. /**
  101275. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101276. */
  101277. alwaysSelectAsActiveMesh: boolean;
  101278. /**
  101279. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101280. */
  101281. doNotSyncBoundingInfo: boolean;
  101282. /**
  101283. * Gets or sets the current action manager
  101284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101285. */
  101286. actionManager: Nullable<AbstractActionManager>;
  101287. private _meshCollisionData;
  101288. /**
  101289. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101290. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101291. */
  101292. ellipsoid: Vector3;
  101293. /**
  101294. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101295. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101296. */
  101297. ellipsoidOffset: Vector3;
  101298. /**
  101299. * Gets or sets a collision mask used to mask collisions (default is -1).
  101300. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101301. */
  101302. get collisionMask(): number;
  101303. set collisionMask(mask: number);
  101304. /**
  101305. * Gets or sets the current collision group mask (-1 by default).
  101306. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101307. */
  101308. get collisionGroup(): number;
  101309. set collisionGroup(mask: number);
  101310. /**
  101311. * Defines edge width used when edgesRenderer is enabled
  101312. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101313. */
  101314. edgesWidth: number;
  101315. /**
  101316. * Defines edge color used when edgesRenderer is enabled
  101317. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101318. */
  101319. edgesColor: Color4;
  101320. /** @hidden */
  101321. _edgesRenderer: Nullable<IEdgesRenderer>;
  101322. /** @hidden */
  101323. _masterMesh: Nullable<AbstractMesh>;
  101324. /** @hidden */
  101325. _boundingInfo: Nullable<BoundingInfo>;
  101326. /** @hidden */
  101327. _renderId: number;
  101328. /**
  101329. * Gets or sets the list of subMeshes
  101330. * @see http://doc.babylonjs.com/how_to/multi_materials
  101331. */
  101332. subMeshes: SubMesh[];
  101333. /** @hidden */
  101334. _intersectionsInProgress: AbstractMesh[];
  101335. /** @hidden */
  101336. _unIndexed: boolean;
  101337. /** @hidden */
  101338. _lightSources: Light[];
  101339. /** Gets the list of lights affecting that mesh */
  101340. get lightSources(): Light[];
  101341. /** @hidden */
  101342. get _positions(): Nullable<Vector3[]>;
  101343. /** @hidden */
  101344. _waitingData: {
  101345. lods: Nullable<any>;
  101346. actions: Nullable<any>;
  101347. freezeWorldMatrix: Nullable<boolean>;
  101348. };
  101349. /** @hidden */
  101350. _bonesTransformMatrices: Nullable<Float32Array>;
  101351. /** @hidden */
  101352. _transformMatrixTexture: Nullable<RawTexture>;
  101353. /**
  101354. * Gets or sets a skeleton to apply skining transformations
  101355. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101356. */
  101357. set skeleton(value: Nullable<Skeleton>);
  101358. get skeleton(): Nullable<Skeleton>;
  101359. /**
  101360. * An event triggered when the mesh is rebuilt.
  101361. */
  101362. onRebuildObservable: Observable<AbstractMesh>;
  101363. /**
  101364. * Creates a new AbstractMesh
  101365. * @param name defines the name of the mesh
  101366. * @param scene defines the hosting scene
  101367. */
  101368. constructor(name: string, scene?: Nullable<Scene>);
  101369. /**
  101370. * Returns the string "AbstractMesh"
  101371. * @returns "AbstractMesh"
  101372. */
  101373. getClassName(): string;
  101374. /**
  101375. * Gets a string representation of the current mesh
  101376. * @param fullDetails defines a boolean indicating if full details must be included
  101377. * @returns a string representation of the current mesh
  101378. */
  101379. toString(fullDetails?: boolean): string;
  101380. /**
  101381. * @hidden
  101382. */
  101383. protected _getEffectiveParent(): Nullable<Node>;
  101384. /** @hidden */
  101385. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101386. /** @hidden */
  101387. _rebuild(): void;
  101388. /** @hidden */
  101389. _resyncLightSources(): void;
  101390. /** @hidden */
  101391. _resyncLightSource(light: Light): void;
  101392. /** @hidden */
  101393. _unBindEffect(): void;
  101394. /** @hidden */
  101395. _removeLightSource(light: Light, dispose: boolean): void;
  101396. private _markSubMeshesAsDirty;
  101397. /** @hidden */
  101398. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101399. /** @hidden */
  101400. _markSubMeshesAsAttributesDirty(): void;
  101401. /** @hidden */
  101402. _markSubMeshesAsMiscDirty(): void;
  101403. /**
  101404. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101405. */
  101406. get scaling(): Vector3;
  101407. set scaling(newScaling: Vector3);
  101408. /**
  101409. * Returns true if the mesh is blocked. Implemented by child classes
  101410. */
  101411. get isBlocked(): boolean;
  101412. /**
  101413. * Returns the mesh itself by default. Implemented by child classes
  101414. * @param camera defines the camera to use to pick the right LOD level
  101415. * @returns the currentAbstractMesh
  101416. */
  101417. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101418. /**
  101419. * Returns 0 by default. Implemented by child classes
  101420. * @returns an integer
  101421. */
  101422. getTotalVertices(): number;
  101423. /**
  101424. * Returns a positive integer : the total number of indices in this mesh geometry.
  101425. * @returns the numner of indices or zero if the mesh has no geometry.
  101426. */
  101427. getTotalIndices(): number;
  101428. /**
  101429. * Returns null by default. Implemented by child classes
  101430. * @returns null
  101431. */
  101432. getIndices(): Nullable<IndicesArray>;
  101433. /**
  101434. * Returns the array of the requested vertex data kind. Implemented by child classes
  101435. * @param kind defines the vertex data kind to use
  101436. * @returns null
  101437. */
  101438. getVerticesData(kind: string): Nullable<FloatArray>;
  101439. /**
  101440. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101441. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101442. * Note that a new underlying VertexBuffer object is created each call.
  101443. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101444. * @param kind defines vertex data kind:
  101445. * * VertexBuffer.PositionKind
  101446. * * VertexBuffer.UVKind
  101447. * * VertexBuffer.UV2Kind
  101448. * * VertexBuffer.UV3Kind
  101449. * * VertexBuffer.UV4Kind
  101450. * * VertexBuffer.UV5Kind
  101451. * * VertexBuffer.UV6Kind
  101452. * * VertexBuffer.ColorKind
  101453. * * VertexBuffer.MatricesIndicesKind
  101454. * * VertexBuffer.MatricesIndicesExtraKind
  101455. * * VertexBuffer.MatricesWeightsKind
  101456. * * VertexBuffer.MatricesWeightsExtraKind
  101457. * @param data defines the data source
  101458. * @param updatable defines if the data must be flagged as updatable (or static)
  101459. * @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
  101460. * @returns the current mesh
  101461. */
  101462. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101463. /**
  101464. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101465. * If the mesh has no geometry, it is simply returned as it is.
  101466. * @param kind defines vertex data kind:
  101467. * * VertexBuffer.PositionKind
  101468. * * VertexBuffer.UVKind
  101469. * * VertexBuffer.UV2Kind
  101470. * * VertexBuffer.UV3Kind
  101471. * * VertexBuffer.UV4Kind
  101472. * * VertexBuffer.UV5Kind
  101473. * * VertexBuffer.UV6Kind
  101474. * * VertexBuffer.ColorKind
  101475. * * VertexBuffer.MatricesIndicesKind
  101476. * * VertexBuffer.MatricesIndicesExtraKind
  101477. * * VertexBuffer.MatricesWeightsKind
  101478. * * VertexBuffer.MatricesWeightsExtraKind
  101479. * @param data defines the data source
  101480. * @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
  101481. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101482. * @returns the current mesh
  101483. */
  101484. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101485. /**
  101486. * Sets the mesh indices,
  101487. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101488. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101489. * @param totalVertices Defines the total number of vertices
  101490. * @returns the current mesh
  101491. */
  101492. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101493. /**
  101494. * Gets a boolean indicating if specific vertex data is present
  101495. * @param kind defines the vertex data kind to use
  101496. * @returns true is data kind is present
  101497. */
  101498. isVerticesDataPresent(kind: string): boolean;
  101499. /**
  101500. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101501. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101502. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101503. * @returns a BoundingInfo
  101504. */
  101505. getBoundingInfo(): BoundingInfo;
  101506. /**
  101507. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101508. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101509. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101510. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101511. * @returns the current mesh
  101512. */
  101513. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101514. /**
  101515. * Overwrite the current bounding info
  101516. * @param boundingInfo defines the new bounding info
  101517. * @returns the current mesh
  101518. */
  101519. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101520. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101521. get useBones(): boolean;
  101522. /** @hidden */
  101523. _preActivate(): void;
  101524. /** @hidden */
  101525. _preActivateForIntermediateRendering(renderId: number): void;
  101526. /** @hidden */
  101527. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101528. /** @hidden */
  101529. _postActivate(): void;
  101530. /** @hidden */
  101531. _freeze(): void;
  101532. /** @hidden */
  101533. _unFreeze(): void;
  101534. /**
  101535. * Gets the current world matrix
  101536. * @returns a Matrix
  101537. */
  101538. getWorldMatrix(): Matrix;
  101539. /** @hidden */
  101540. _getWorldMatrixDeterminant(): number;
  101541. /**
  101542. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101543. */
  101544. get isAnInstance(): boolean;
  101545. /**
  101546. * Gets a boolean indicating if this mesh has instances
  101547. */
  101548. get hasInstances(): boolean;
  101549. /**
  101550. * Perform relative position change from the point of view of behind the front of the mesh.
  101551. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101552. * Supports definition of mesh facing forward or backward
  101553. * @param amountRight defines the distance on the right axis
  101554. * @param amountUp defines the distance on the up axis
  101555. * @param amountForward defines the distance on the forward axis
  101556. * @returns the current mesh
  101557. */
  101558. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101559. /**
  101560. * Calculate relative position change from the point of view of behind the front of the mesh.
  101561. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101562. * Supports definition of mesh facing forward or backward
  101563. * @param amountRight defines the distance on the right axis
  101564. * @param amountUp defines the distance on the up axis
  101565. * @param amountForward defines the distance on the forward axis
  101566. * @returns the new displacement vector
  101567. */
  101568. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101569. /**
  101570. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101571. * Supports definition of mesh facing forward or backward
  101572. * @param flipBack defines the flip
  101573. * @param twirlClockwise defines the twirl
  101574. * @param tiltRight defines the tilt
  101575. * @returns the current mesh
  101576. */
  101577. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101578. /**
  101579. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101580. * Supports definition of mesh facing forward or backward.
  101581. * @param flipBack defines the flip
  101582. * @param twirlClockwise defines the twirl
  101583. * @param tiltRight defines the tilt
  101584. * @returns the new rotation vector
  101585. */
  101586. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101587. /**
  101588. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101589. * This means the mesh underlying bounding box and sphere are recomputed.
  101590. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101591. * @returns the current mesh
  101592. */
  101593. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101594. /** @hidden */
  101595. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101596. /** @hidden */
  101597. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101598. /** @hidden */
  101599. _updateBoundingInfo(): AbstractMesh;
  101600. /** @hidden */
  101601. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101602. /** @hidden */
  101603. protected _afterComputeWorldMatrix(): void;
  101604. /** @hidden */
  101605. get _effectiveMesh(): AbstractMesh;
  101606. /**
  101607. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101608. * A mesh is in the frustum if its bounding box intersects the frustum
  101609. * @param frustumPlanes defines the frustum to test
  101610. * @returns true if the mesh is in the frustum planes
  101611. */
  101612. isInFrustum(frustumPlanes: Plane[]): boolean;
  101613. /**
  101614. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101615. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101616. * @param frustumPlanes defines the frustum to test
  101617. * @returns true if the mesh is completely in the frustum planes
  101618. */
  101619. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101620. /**
  101621. * True if the mesh intersects another mesh or a SolidParticle object
  101622. * @param mesh defines a target mesh or SolidParticle to test
  101623. * @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)
  101624. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101625. * @returns true if there is an intersection
  101626. */
  101627. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101628. /**
  101629. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101630. * @param point defines the point to test
  101631. * @returns true if there is an intersection
  101632. */
  101633. intersectsPoint(point: Vector3): boolean;
  101634. /**
  101635. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101636. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101637. */
  101638. get checkCollisions(): boolean;
  101639. set checkCollisions(collisionEnabled: boolean);
  101640. /**
  101641. * Gets Collider object used to compute collisions (not physics)
  101642. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101643. */
  101644. get collider(): Nullable<Collider>;
  101645. /**
  101646. * Move the mesh using collision engine
  101647. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101648. * @param displacement defines the requested displacement vector
  101649. * @returns the current mesh
  101650. */
  101651. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101652. private _onCollisionPositionChange;
  101653. /** @hidden */
  101654. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101655. /** @hidden */
  101656. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101657. /** @hidden */
  101658. _checkCollision(collider: Collider): AbstractMesh;
  101659. /** @hidden */
  101660. _generatePointsArray(): boolean;
  101661. /**
  101662. * Checks if the passed Ray intersects with the mesh
  101663. * @param ray defines the ray to use
  101664. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101665. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101666. * @returns the picking info
  101667. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101668. */
  101669. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101670. /**
  101671. * Clones the current mesh
  101672. * @param name defines the mesh name
  101673. * @param newParent defines the new mesh parent
  101674. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101675. * @returns the new mesh
  101676. */
  101677. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101678. /**
  101679. * Disposes all the submeshes of the current meshnp
  101680. * @returns the current mesh
  101681. */
  101682. releaseSubMeshes(): AbstractMesh;
  101683. /**
  101684. * Releases resources associated with this abstract mesh.
  101685. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101686. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101687. */
  101688. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101689. /**
  101690. * Adds the passed mesh as a child to the current mesh
  101691. * @param mesh defines the child mesh
  101692. * @returns the current mesh
  101693. */
  101694. addChild(mesh: AbstractMesh): AbstractMesh;
  101695. /**
  101696. * Removes the passed mesh from the current mesh children list
  101697. * @param mesh defines the child mesh
  101698. * @returns the current mesh
  101699. */
  101700. removeChild(mesh: AbstractMesh): AbstractMesh;
  101701. /** @hidden */
  101702. private _initFacetData;
  101703. /**
  101704. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101705. * This method can be called within the render loop.
  101706. * 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
  101707. * @returns the current mesh
  101708. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101709. */
  101710. updateFacetData(): AbstractMesh;
  101711. /**
  101712. * Returns the facetLocalNormals array.
  101713. * The normals are expressed in the mesh local spac
  101714. * @returns an array of Vector3
  101715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101716. */
  101717. getFacetLocalNormals(): Vector3[];
  101718. /**
  101719. * Returns the facetLocalPositions array.
  101720. * The facet positions are expressed in the mesh local space
  101721. * @returns an array of Vector3
  101722. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101723. */
  101724. getFacetLocalPositions(): Vector3[];
  101725. /**
  101726. * Returns the facetLocalPartioning array
  101727. * @returns an array of array of numbers
  101728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101729. */
  101730. getFacetLocalPartitioning(): number[][];
  101731. /**
  101732. * Returns the i-th facet position in the world system.
  101733. * This method allocates a new Vector3 per call
  101734. * @param i defines the facet index
  101735. * @returns a new Vector3
  101736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101737. */
  101738. getFacetPosition(i: number): Vector3;
  101739. /**
  101740. * Sets the reference Vector3 with the i-th facet position in the world system
  101741. * @param i defines the facet index
  101742. * @param ref defines the target vector
  101743. * @returns the current mesh
  101744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101745. */
  101746. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101747. /**
  101748. * Returns the i-th facet normal in the world system.
  101749. * This method allocates a new Vector3 per call
  101750. * @param i defines the facet index
  101751. * @returns a new Vector3
  101752. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101753. */
  101754. getFacetNormal(i: number): Vector3;
  101755. /**
  101756. * Sets the reference Vector3 with the i-th facet normal in the world system
  101757. * @param i defines the facet index
  101758. * @param ref defines the target vector
  101759. * @returns the current mesh
  101760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101761. */
  101762. getFacetNormalToRef(i: number, ref: Vector3): this;
  101763. /**
  101764. * 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)
  101765. * @param x defines x coordinate
  101766. * @param y defines y coordinate
  101767. * @param z defines z coordinate
  101768. * @returns the array of facet indexes
  101769. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101770. */
  101771. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101772. /**
  101773. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101774. * @param projected sets as the (x,y,z) world projection on the facet
  101775. * @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
  101776. * @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
  101777. * @param x defines x coordinate
  101778. * @param y defines y coordinate
  101779. * @param z defines z coordinate
  101780. * @returns the face index if found (or null instead)
  101781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101782. */
  101783. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101784. /**
  101785. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101786. * @param projected sets as the (x,y,z) local projection on the facet
  101787. * @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
  101788. * @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
  101789. * @param x defines x coordinate
  101790. * @param y defines y coordinate
  101791. * @param z defines z coordinate
  101792. * @returns the face index if found (or null instead)
  101793. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101794. */
  101795. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101796. /**
  101797. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101798. * @returns the parameters
  101799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101800. */
  101801. getFacetDataParameters(): any;
  101802. /**
  101803. * Disables the feature FacetData and frees the related memory
  101804. * @returns the current mesh
  101805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101806. */
  101807. disableFacetData(): AbstractMesh;
  101808. /**
  101809. * Updates the AbstractMesh indices array
  101810. * @param indices defines the data source
  101811. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101812. * @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)
  101813. * @returns the current mesh
  101814. */
  101815. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101816. /**
  101817. * Creates new normals data for the mesh
  101818. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101819. * @returns the current mesh
  101820. */
  101821. createNormals(updatable: boolean): AbstractMesh;
  101822. /**
  101823. * Align the mesh with a normal
  101824. * @param normal defines the normal to use
  101825. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101826. * @returns the current mesh
  101827. */
  101828. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101829. /** @hidden */
  101830. _checkOcclusionQuery(): boolean;
  101831. /**
  101832. * Disables the mesh edge rendering mode
  101833. * @returns the currentAbstractMesh
  101834. */
  101835. disableEdgesRendering(): AbstractMesh;
  101836. /**
  101837. * Enables the edge rendering mode on the mesh.
  101838. * This mode makes the mesh edges visible
  101839. * @param epsilon defines the maximal distance between two angles to detect a face
  101840. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101841. * @returns the currentAbstractMesh
  101842. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101843. */
  101844. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101845. }
  101846. }
  101847. declare module BABYLON {
  101848. /**
  101849. * Interface used to define ActionEvent
  101850. */
  101851. export interface IActionEvent {
  101852. /** The mesh or sprite that triggered the action */
  101853. source: any;
  101854. /** The X mouse cursor position at the time of the event */
  101855. pointerX: number;
  101856. /** The Y mouse cursor position at the time of the event */
  101857. pointerY: number;
  101858. /** The mesh that is currently pointed at (can be null) */
  101859. meshUnderPointer: Nullable<AbstractMesh>;
  101860. /** the original (browser) event that triggered the ActionEvent */
  101861. sourceEvent?: any;
  101862. /** additional data for the event */
  101863. additionalData?: any;
  101864. }
  101865. /**
  101866. * ActionEvent is the event being sent when an action is triggered.
  101867. */
  101868. export class ActionEvent implements IActionEvent {
  101869. /** The mesh or sprite that triggered the action */
  101870. source: any;
  101871. /** The X mouse cursor position at the time of the event */
  101872. pointerX: number;
  101873. /** The Y mouse cursor position at the time of the event */
  101874. pointerY: number;
  101875. /** The mesh that is currently pointed at (can be null) */
  101876. meshUnderPointer: Nullable<AbstractMesh>;
  101877. /** the original (browser) event that triggered the ActionEvent */
  101878. sourceEvent?: any;
  101879. /** additional data for the event */
  101880. additionalData?: any;
  101881. /**
  101882. * Creates a new ActionEvent
  101883. * @param source The mesh or sprite that triggered the action
  101884. * @param pointerX The X mouse cursor position at the time of the event
  101885. * @param pointerY The Y mouse cursor position at the time of the event
  101886. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101887. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101888. * @param additionalData additional data for the event
  101889. */
  101890. constructor(
  101891. /** The mesh or sprite that triggered the action */
  101892. source: any,
  101893. /** The X mouse cursor position at the time of the event */
  101894. pointerX: number,
  101895. /** The Y mouse cursor position at the time of the event */
  101896. pointerY: number,
  101897. /** The mesh that is currently pointed at (can be null) */
  101898. meshUnderPointer: Nullable<AbstractMesh>,
  101899. /** the original (browser) event that triggered the ActionEvent */
  101900. sourceEvent?: any,
  101901. /** additional data for the event */
  101902. additionalData?: any);
  101903. /**
  101904. * Helper function to auto-create an ActionEvent from a source mesh.
  101905. * @param source The source mesh that triggered the event
  101906. * @param evt The original (browser) event
  101907. * @param additionalData additional data for the event
  101908. * @returns the new ActionEvent
  101909. */
  101910. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101911. /**
  101912. * Helper function to auto-create an ActionEvent from a source sprite
  101913. * @param source The source sprite that triggered the event
  101914. * @param scene Scene associated with the sprite
  101915. * @param evt The original (browser) event
  101916. * @param additionalData additional data for the event
  101917. * @returns the new ActionEvent
  101918. */
  101919. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101920. /**
  101921. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101922. * @param scene the scene where the event occurred
  101923. * @param evt The original (browser) event
  101924. * @returns the new ActionEvent
  101925. */
  101926. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101927. /**
  101928. * Helper function to auto-create an ActionEvent from a primitive
  101929. * @param prim defines the target primitive
  101930. * @param pointerPos defines the pointer position
  101931. * @param evt The original (browser) event
  101932. * @param additionalData additional data for the event
  101933. * @returns the new ActionEvent
  101934. */
  101935. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101936. }
  101937. }
  101938. declare module BABYLON {
  101939. /**
  101940. * Abstract class used to decouple action Manager from scene and meshes.
  101941. * Do not instantiate.
  101942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101943. */
  101944. export abstract class AbstractActionManager implements IDisposable {
  101945. /** Gets the list of active triggers */
  101946. static Triggers: {
  101947. [key: string]: number;
  101948. };
  101949. /** Gets the cursor to use when hovering items */
  101950. hoverCursor: string;
  101951. /** Gets the list of actions */
  101952. actions: IAction[];
  101953. /**
  101954. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101955. */
  101956. isRecursive: boolean;
  101957. /**
  101958. * Releases all associated resources
  101959. */
  101960. abstract dispose(): void;
  101961. /**
  101962. * Does this action manager has pointer triggers
  101963. */
  101964. abstract get hasPointerTriggers(): boolean;
  101965. /**
  101966. * Does this action manager has pick triggers
  101967. */
  101968. abstract get hasPickTriggers(): boolean;
  101969. /**
  101970. * Process a specific trigger
  101971. * @param trigger defines the trigger to process
  101972. * @param evt defines the event details to be processed
  101973. */
  101974. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101975. /**
  101976. * Does this action manager handles actions of any of the given triggers
  101977. * @param triggers defines the triggers to be tested
  101978. * @return a boolean indicating whether one (or more) of the triggers is handled
  101979. */
  101980. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101981. /**
  101982. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101983. * speed.
  101984. * @param triggerA defines the trigger to be tested
  101985. * @param triggerB defines the trigger to be tested
  101986. * @return a boolean indicating whether one (or more) of the triggers is handled
  101987. */
  101988. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101989. /**
  101990. * Does this action manager handles actions of a given trigger
  101991. * @param trigger defines the trigger to be tested
  101992. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101993. * @return whether the trigger is handled
  101994. */
  101995. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101996. /**
  101997. * Serialize this manager to a JSON object
  101998. * @param name defines the property name to store this manager
  101999. * @returns a JSON representation of this manager
  102000. */
  102001. abstract serialize(name: string): any;
  102002. /**
  102003. * Registers an action to this action manager
  102004. * @param action defines the action to be registered
  102005. * @return the action amended (prepared) after registration
  102006. */
  102007. abstract registerAction(action: IAction): Nullable<IAction>;
  102008. /**
  102009. * Unregisters an action to this action manager
  102010. * @param action defines the action to be unregistered
  102011. * @return a boolean indicating whether the action has been unregistered
  102012. */
  102013. abstract unregisterAction(action: IAction): Boolean;
  102014. /**
  102015. * Does exist one action manager with at least one trigger
  102016. **/
  102017. static get HasTriggers(): boolean;
  102018. /**
  102019. * Does exist one action manager with at least one pick trigger
  102020. **/
  102021. static get HasPickTriggers(): boolean;
  102022. /**
  102023. * Does exist one action manager that handles actions of a given trigger
  102024. * @param trigger defines the trigger to be tested
  102025. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102026. **/
  102027. static HasSpecificTrigger(trigger: number): boolean;
  102028. }
  102029. }
  102030. declare module BABYLON {
  102031. /**
  102032. * Defines how a node can be built from a string name.
  102033. */
  102034. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102035. /**
  102036. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102037. */
  102038. export class Node implements IBehaviorAware<Node> {
  102039. /** @hidden */
  102040. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102041. private static _NodeConstructors;
  102042. /**
  102043. * Add a new node constructor
  102044. * @param type defines the type name of the node to construct
  102045. * @param constructorFunc defines the constructor function
  102046. */
  102047. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102048. /**
  102049. * Returns a node constructor based on type name
  102050. * @param type defines the type name
  102051. * @param name defines the new node name
  102052. * @param scene defines the hosting scene
  102053. * @param options defines optional options to transmit to constructors
  102054. * @returns the new constructor or null
  102055. */
  102056. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102057. /**
  102058. * Gets or sets the name of the node
  102059. */
  102060. name: string;
  102061. /**
  102062. * Gets or sets the id of the node
  102063. */
  102064. id: string;
  102065. /**
  102066. * Gets or sets the unique id of the node
  102067. */
  102068. uniqueId: number;
  102069. /**
  102070. * Gets or sets a string used to store user defined state for the node
  102071. */
  102072. state: string;
  102073. /**
  102074. * Gets or sets an object used to store user defined information for the node
  102075. */
  102076. metadata: any;
  102077. /**
  102078. * For internal use only. Please do not use.
  102079. */
  102080. reservedDataStore: any;
  102081. /**
  102082. * List of inspectable custom properties (used by the Inspector)
  102083. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102084. */
  102085. inspectableCustomProperties: IInspectable[];
  102086. private _doNotSerialize;
  102087. /**
  102088. * Gets or sets a boolean used to define if the node must be serialized
  102089. */
  102090. get doNotSerialize(): boolean;
  102091. set doNotSerialize(value: boolean);
  102092. /** @hidden */
  102093. _isDisposed: boolean;
  102094. /**
  102095. * Gets a list of Animations associated with the node
  102096. */
  102097. animations: Animation[];
  102098. protected _ranges: {
  102099. [name: string]: Nullable<AnimationRange>;
  102100. };
  102101. /**
  102102. * Callback raised when the node is ready to be used
  102103. */
  102104. onReady: Nullable<(node: Node) => void>;
  102105. private _isEnabled;
  102106. private _isParentEnabled;
  102107. private _isReady;
  102108. /** @hidden */
  102109. _currentRenderId: number;
  102110. private _parentUpdateId;
  102111. /** @hidden */
  102112. _childUpdateId: number;
  102113. /** @hidden */
  102114. _waitingParentId: Nullable<string>;
  102115. /** @hidden */
  102116. _scene: Scene;
  102117. /** @hidden */
  102118. _cache: any;
  102119. private _parentNode;
  102120. private _children;
  102121. /** @hidden */
  102122. _worldMatrix: Matrix;
  102123. /** @hidden */
  102124. _worldMatrixDeterminant: number;
  102125. /** @hidden */
  102126. _worldMatrixDeterminantIsDirty: boolean;
  102127. /** @hidden */
  102128. private _sceneRootNodesIndex;
  102129. /**
  102130. * Gets a boolean indicating if the node has been disposed
  102131. * @returns true if the node was disposed
  102132. */
  102133. isDisposed(): boolean;
  102134. /**
  102135. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102136. * @see https://doc.babylonjs.com/how_to/parenting
  102137. */
  102138. set parent(parent: Nullable<Node>);
  102139. get parent(): Nullable<Node>;
  102140. /** @hidden */
  102141. _addToSceneRootNodes(): void;
  102142. /** @hidden */
  102143. _removeFromSceneRootNodes(): void;
  102144. private _animationPropertiesOverride;
  102145. /**
  102146. * Gets or sets the animation properties override
  102147. */
  102148. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102149. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102150. /**
  102151. * Gets a string idenfifying the name of the class
  102152. * @returns "Node" string
  102153. */
  102154. getClassName(): string;
  102155. /** @hidden */
  102156. readonly _isNode: boolean;
  102157. /**
  102158. * An event triggered when the mesh is disposed
  102159. */
  102160. onDisposeObservable: Observable<Node>;
  102161. private _onDisposeObserver;
  102162. /**
  102163. * Sets a callback that will be raised when the node will be disposed
  102164. */
  102165. set onDispose(callback: () => void);
  102166. /**
  102167. * Creates a new Node
  102168. * @param name the name and id to be given to this node
  102169. * @param scene the scene this node will be added to
  102170. */
  102171. constructor(name: string, scene?: Nullable<Scene>);
  102172. /**
  102173. * Gets the scene of the node
  102174. * @returns a scene
  102175. */
  102176. getScene(): Scene;
  102177. /**
  102178. * Gets the engine of the node
  102179. * @returns a Engine
  102180. */
  102181. getEngine(): Engine;
  102182. private _behaviors;
  102183. /**
  102184. * Attach a behavior to the node
  102185. * @see http://doc.babylonjs.com/features/behaviour
  102186. * @param behavior defines the behavior to attach
  102187. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102188. * @returns the current Node
  102189. */
  102190. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102191. /**
  102192. * Remove an attached behavior
  102193. * @see http://doc.babylonjs.com/features/behaviour
  102194. * @param behavior defines the behavior to attach
  102195. * @returns the current Node
  102196. */
  102197. removeBehavior(behavior: Behavior<Node>): Node;
  102198. /**
  102199. * Gets the list of attached behaviors
  102200. * @see http://doc.babylonjs.com/features/behaviour
  102201. */
  102202. get behaviors(): Behavior<Node>[];
  102203. /**
  102204. * Gets an attached behavior by name
  102205. * @param name defines the name of the behavior to look for
  102206. * @see http://doc.babylonjs.com/features/behaviour
  102207. * @returns null if behavior was not found else the requested behavior
  102208. */
  102209. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102210. /**
  102211. * Returns the latest update of the World matrix
  102212. * @returns a Matrix
  102213. */
  102214. getWorldMatrix(): Matrix;
  102215. /** @hidden */
  102216. _getWorldMatrixDeterminant(): number;
  102217. /**
  102218. * Returns directly the latest state of the mesh World matrix.
  102219. * A Matrix is returned.
  102220. */
  102221. get worldMatrixFromCache(): Matrix;
  102222. /** @hidden */
  102223. _initCache(): void;
  102224. /** @hidden */
  102225. updateCache(force?: boolean): void;
  102226. /** @hidden */
  102227. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102228. /** @hidden */
  102229. _updateCache(ignoreParentClass?: boolean): void;
  102230. /** @hidden */
  102231. _isSynchronized(): boolean;
  102232. /** @hidden */
  102233. _markSyncedWithParent(): void;
  102234. /** @hidden */
  102235. isSynchronizedWithParent(): boolean;
  102236. /** @hidden */
  102237. isSynchronized(): boolean;
  102238. /**
  102239. * Is this node ready to be used/rendered
  102240. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102241. * @return true if the node is ready
  102242. */
  102243. isReady(completeCheck?: boolean): boolean;
  102244. /**
  102245. * Is this node enabled?
  102246. * 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
  102247. * @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
  102248. * @return whether this node (and its parent) is enabled
  102249. */
  102250. isEnabled(checkAncestors?: boolean): boolean;
  102251. /** @hidden */
  102252. protected _syncParentEnabledState(): void;
  102253. /**
  102254. * Set the enabled state of this node
  102255. * @param value defines the new enabled state
  102256. */
  102257. setEnabled(value: boolean): void;
  102258. /**
  102259. * Is this node a descendant of the given node?
  102260. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102261. * @param ancestor defines the parent node to inspect
  102262. * @returns a boolean indicating if this node is a descendant of the given node
  102263. */
  102264. isDescendantOf(ancestor: Node): boolean;
  102265. /** @hidden */
  102266. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102267. /**
  102268. * Will return all nodes that have this node as ascendant
  102269. * @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
  102270. * @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
  102271. * @return all children nodes of all types
  102272. */
  102273. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102274. /**
  102275. * Get all child-meshes of this node
  102276. * @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)
  102277. * @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
  102278. * @returns an array of AbstractMesh
  102279. */
  102280. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102281. /**
  102282. * Get all direct children of this node
  102283. * @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
  102284. * @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)
  102285. * @returns an array of Node
  102286. */
  102287. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102288. /** @hidden */
  102289. _setReady(state: boolean): void;
  102290. /**
  102291. * Get an animation by name
  102292. * @param name defines the name of the animation to look for
  102293. * @returns null if not found else the requested animation
  102294. */
  102295. getAnimationByName(name: string): Nullable<Animation>;
  102296. /**
  102297. * Creates an animation range for this node
  102298. * @param name defines the name of the range
  102299. * @param from defines the starting key
  102300. * @param to defines the end key
  102301. */
  102302. createAnimationRange(name: string, from: number, to: number): void;
  102303. /**
  102304. * Delete a specific animation range
  102305. * @param name defines the name of the range to delete
  102306. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102307. */
  102308. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102309. /**
  102310. * Get an animation range by name
  102311. * @param name defines the name of the animation range to look for
  102312. * @returns null if not found else the requested animation range
  102313. */
  102314. getAnimationRange(name: string): Nullable<AnimationRange>;
  102315. /**
  102316. * Gets the list of all animation ranges defined on this node
  102317. * @returns an array
  102318. */
  102319. getAnimationRanges(): Nullable<AnimationRange>[];
  102320. /**
  102321. * Will start the animation sequence
  102322. * @param name defines the range frames for animation sequence
  102323. * @param loop defines if the animation should loop (false by default)
  102324. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102325. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102326. * @returns the object created for this animation. If range does not exist, it will return null
  102327. */
  102328. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102329. /**
  102330. * Serialize animation ranges into a JSON compatible object
  102331. * @returns serialization object
  102332. */
  102333. serializeAnimationRanges(): any;
  102334. /**
  102335. * Computes the world matrix of the node
  102336. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102337. * @returns the world matrix
  102338. */
  102339. computeWorldMatrix(force?: boolean): Matrix;
  102340. /**
  102341. * Releases resources associated with this node.
  102342. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102343. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102344. */
  102345. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102346. /**
  102347. * Parse animation range data from a serialization object and store them into a given node
  102348. * @param node defines where to store the animation ranges
  102349. * @param parsedNode defines the serialization object to read data from
  102350. * @param scene defines the hosting scene
  102351. */
  102352. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102353. /**
  102354. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102355. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102356. * @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
  102357. * @returns the new bounding vectors
  102358. */
  102359. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102360. min: Vector3;
  102361. max: Vector3;
  102362. };
  102363. }
  102364. }
  102365. declare module BABYLON {
  102366. /**
  102367. * @hidden
  102368. */
  102369. export class _IAnimationState {
  102370. key: number;
  102371. repeatCount: number;
  102372. workValue?: any;
  102373. loopMode?: number;
  102374. offsetValue?: any;
  102375. highLimitValue?: any;
  102376. }
  102377. /**
  102378. * Class used to store any kind of animation
  102379. */
  102380. export class Animation {
  102381. /**Name of the animation */
  102382. name: string;
  102383. /**Property to animate */
  102384. targetProperty: string;
  102385. /**The frames per second of the animation */
  102386. framePerSecond: number;
  102387. /**The data type of the animation */
  102388. dataType: number;
  102389. /**The loop mode of the animation */
  102390. loopMode?: number | undefined;
  102391. /**Specifies if blending should be enabled */
  102392. enableBlending?: boolean | undefined;
  102393. /**
  102394. * Use matrix interpolation instead of using direct key value when animating matrices
  102395. */
  102396. static AllowMatricesInterpolation: boolean;
  102397. /**
  102398. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102399. */
  102400. static AllowMatrixDecomposeForInterpolation: boolean;
  102401. /**
  102402. * Stores the key frames of the animation
  102403. */
  102404. private _keys;
  102405. /**
  102406. * Stores the easing function of the animation
  102407. */
  102408. private _easingFunction;
  102409. /**
  102410. * @hidden Internal use only
  102411. */
  102412. _runtimeAnimations: RuntimeAnimation[];
  102413. /**
  102414. * The set of event that will be linked to this animation
  102415. */
  102416. private _events;
  102417. /**
  102418. * Stores an array of target property paths
  102419. */
  102420. targetPropertyPath: string[];
  102421. /**
  102422. * Stores the blending speed of the animation
  102423. */
  102424. blendingSpeed: number;
  102425. /**
  102426. * Stores the animation ranges for the animation
  102427. */
  102428. private _ranges;
  102429. /**
  102430. * @hidden Internal use
  102431. */
  102432. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102433. /**
  102434. * Sets up an animation
  102435. * @param property The property to animate
  102436. * @param animationType The animation type to apply
  102437. * @param framePerSecond The frames per second of the animation
  102438. * @param easingFunction The easing function used in the animation
  102439. * @returns The created animation
  102440. */
  102441. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102442. /**
  102443. * Create and start an animation on a node
  102444. * @param name defines the name of the global animation that will be run on all nodes
  102445. * @param node defines the root node where the animation will take place
  102446. * @param targetProperty defines property to animate
  102447. * @param framePerSecond defines the number of frame per second yo use
  102448. * @param totalFrame defines the number of frames in total
  102449. * @param from defines the initial value
  102450. * @param to defines the final value
  102451. * @param loopMode defines which loop mode you want to use (off by default)
  102452. * @param easingFunction defines the easing function to use (linear by default)
  102453. * @param onAnimationEnd defines the callback to call when animation end
  102454. * @returns the animatable created for this animation
  102455. */
  102456. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102457. /**
  102458. * Create and start an animation on a node and its descendants
  102459. * @param name defines the name of the global animation that will be run on all nodes
  102460. * @param node defines the root node where the animation will take place
  102461. * @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
  102462. * @param targetProperty defines property to animate
  102463. * @param framePerSecond defines the number of frame per second to use
  102464. * @param totalFrame defines the number of frames in total
  102465. * @param from defines the initial value
  102466. * @param to defines the final value
  102467. * @param loopMode defines which loop mode you want to use (off by default)
  102468. * @param easingFunction defines the easing function to use (linear by default)
  102469. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102470. * @returns the list of animatables created for all nodes
  102471. * @example https://www.babylonjs-playground.com/#MH0VLI
  102472. */
  102473. 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[]>;
  102474. /**
  102475. * Creates a new animation, merges it with the existing animations and starts it
  102476. * @param name Name of the animation
  102477. * @param node Node which contains the scene that begins the animations
  102478. * @param targetProperty Specifies which property to animate
  102479. * @param framePerSecond The frames per second of the animation
  102480. * @param totalFrame The total number of frames
  102481. * @param from The frame at the beginning of the animation
  102482. * @param to The frame at the end of the animation
  102483. * @param loopMode Specifies the loop mode of the animation
  102484. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102485. * @param onAnimationEnd Callback to run once the animation is complete
  102486. * @returns Nullable animation
  102487. */
  102488. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102489. /**
  102490. * Transition property of an host to the target Value
  102491. * @param property The property to transition
  102492. * @param targetValue The target Value of the property
  102493. * @param host The object where the property to animate belongs
  102494. * @param scene Scene used to run the animation
  102495. * @param frameRate Framerate (in frame/s) to use
  102496. * @param transition The transition type we want to use
  102497. * @param duration The duration of the animation, in milliseconds
  102498. * @param onAnimationEnd Callback trigger at the end of the animation
  102499. * @returns Nullable animation
  102500. */
  102501. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102502. /**
  102503. * Return the array of runtime animations currently using this animation
  102504. */
  102505. get runtimeAnimations(): RuntimeAnimation[];
  102506. /**
  102507. * Specifies if any of the runtime animations are currently running
  102508. */
  102509. get hasRunningRuntimeAnimations(): boolean;
  102510. /**
  102511. * Initializes the animation
  102512. * @param name Name of the animation
  102513. * @param targetProperty Property to animate
  102514. * @param framePerSecond The frames per second of the animation
  102515. * @param dataType The data type of the animation
  102516. * @param loopMode The loop mode of the animation
  102517. * @param enableBlending Specifies if blending should be enabled
  102518. */
  102519. constructor(
  102520. /**Name of the animation */
  102521. name: string,
  102522. /**Property to animate */
  102523. targetProperty: string,
  102524. /**The frames per second of the animation */
  102525. framePerSecond: number,
  102526. /**The data type of the animation */
  102527. dataType: number,
  102528. /**The loop mode of the animation */
  102529. loopMode?: number | undefined,
  102530. /**Specifies if blending should be enabled */
  102531. enableBlending?: boolean | undefined);
  102532. /**
  102533. * Converts the animation to a string
  102534. * @param fullDetails support for multiple levels of logging within scene loading
  102535. * @returns String form of the animation
  102536. */
  102537. toString(fullDetails?: boolean): string;
  102538. /**
  102539. * Add an event to this animation
  102540. * @param event Event to add
  102541. */
  102542. addEvent(event: AnimationEvent): void;
  102543. /**
  102544. * Remove all events found at the given frame
  102545. * @param frame The frame to remove events from
  102546. */
  102547. removeEvents(frame: number): void;
  102548. /**
  102549. * Retrieves all the events from the animation
  102550. * @returns Events from the animation
  102551. */
  102552. getEvents(): AnimationEvent[];
  102553. /**
  102554. * Creates an animation range
  102555. * @param name Name of the animation range
  102556. * @param from Starting frame of the animation range
  102557. * @param to Ending frame of the animation
  102558. */
  102559. createRange(name: string, from: number, to: number): void;
  102560. /**
  102561. * Deletes an animation range by name
  102562. * @param name Name of the animation range to delete
  102563. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102564. */
  102565. deleteRange(name: string, deleteFrames?: boolean): void;
  102566. /**
  102567. * Gets the animation range by name, or null if not defined
  102568. * @param name Name of the animation range
  102569. * @returns Nullable animation range
  102570. */
  102571. getRange(name: string): Nullable<AnimationRange>;
  102572. /**
  102573. * Gets the key frames from the animation
  102574. * @returns The key frames of the animation
  102575. */
  102576. getKeys(): Array<IAnimationKey>;
  102577. /**
  102578. * Gets the highest frame rate of the animation
  102579. * @returns Highest frame rate of the animation
  102580. */
  102581. getHighestFrame(): number;
  102582. /**
  102583. * Gets the easing function of the animation
  102584. * @returns Easing function of the animation
  102585. */
  102586. getEasingFunction(): IEasingFunction;
  102587. /**
  102588. * Sets the easing function of the animation
  102589. * @param easingFunction A custom mathematical formula for animation
  102590. */
  102591. setEasingFunction(easingFunction: EasingFunction): void;
  102592. /**
  102593. * Interpolates a scalar linearly
  102594. * @param startValue Start value of the animation curve
  102595. * @param endValue End value of the animation curve
  102596. * @param gradient Scalar amount to interpolate
  102597. * @returns Interpolated scalar value
  102598. */
  102599. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102600. /**
  102601. * Interpolates a scalar cubically
  102602. * @param startValue Start value of the animation curve
  102603. * @param outTangent End tangent of the animation
  102604. * @param endValue End value of the animation curve
  102605. * @param inTangent Start tangent of the animation curve
  102606. * @param gradient Scalar amount to interpolate
  102607. * @returns Interpolated scalar value
  102608. */
  102609. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102610. /**
  102611. * Interpolates a quaternion using a spherical linear interpolation
  102612. * @param startValue Start value of the animation curve
  102613. * @param endValue End value of the animation curve
  102614. * @param gradient Scalar amount to interpolate
  102615. * @returns Interpolated quaternion value
  102616. */
  102617. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102618. /**
  102619. * Interpolates a quaternion cubically
  102620. * @param startValue Start value of the animation curve
  102621. * @param outTangent End tangent of the animation curve
  102622. * @param endValue End value of the animation curve
  102623. * @param inTangent Start tangent of the animation curve
  102624. * @param gradient Scalar amount to interpolate
  102625. * @returns Interpolated quaternion value
  102626. */
  102627. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102628. /**
  102629. * Interpolates a Vector3 linearl
  102630. * @param startValue Start value of the animation curve
  102631. * @param endValue End value of the animation curve
  102632. * @param gradient Scalar amount to interpolate
  102633. * @returns Interpolated scalar value
  102634. */
  102635. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102636. /**
  102637. * Interpolates a Vector3 cubically
  102638. * @param startValue Start value of the animation curve
  102639. * @param outTangent End tangent of the animation
  102640. * @param endValue End value of the animation curve
  102641. * @param inTangent Start tangent of the animation curve
  102642. * @param gradient Scalar amount to interpolate
  102643. * @returns InterpolatedVector3 value
  102644. */
  102645. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102646. /**
  102647. * Interpolates a Vector2 linearly
  102648. * @param startValue Start value of the animation curve
  102649. * @param endValue End value of the animation curve
  102650. * @param gradient Scalar amount to interpolate
  102651. * @returns Interpolated Vector2 value
  102652. */
  102653. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102654. /**
  102655. * Interpolates a Vector2 cubically
  102656. * @param startValue Start value of the animation curve
  102657. * @param outTangent End tangent of the animation
  102658. * @param endValue End value of the animation curve
  102659. * @param inTangent Start tangent of the animation curve
  102660. * @param gradient Scalar amount to interpolate
  102661. * @returns Interpolated Vector2 value
  102662. */
  102663. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102664. /**
  102665. * Interpolates a size linearly
  102666. * @param startValue Start value of the animation curve
  102667. * @param endValue End value of the animation curve
  102668. * @param gradient Scalar amount to interpolate
  102669. * @returns Interpolated Size value
  102670. */
  102671. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102672. /**
  102673. * Interpolates a Color3 linearly
  102674. * @param startValue Start value of the animation curve
  102675. * @param endValue End value of the animation curve
  102676. * @param gradient Scalar amount to interpolate
  102677. * @returns Interpolated Color3 value
  102678. */
  102679. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102680. /**
  102681. * Interpolates a Color4 linearly
  102682. * @param startValue Start value of the animation curve
  102683. * @param endValue End value of the animation curve
  102684. * @param gradient Scalar amount to interpolate
  102685. * @returns Interpolated Color3 value
  102686. */
  102687. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102688. /**
  102689. * @hidden Internal use only
  102690. */
  102691. _getKeyValue(value: any): any;
  102692. /**
  102693. * @hidden Internal use only
  102694. */
  102695. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102696. /**
  102697. * Defines the function to use to interpolate matrices
  102698. * @param startValue defines the start matrix
  102699. * @param endValue defines the end matrix
  102700. * @param gradient defines the gradient between both matrices
  102701. * @param result defines an optional target matrix where to store the interpolation
  102702. * @returns the interpolated matrix
  102703. */
  102704. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102705. /**
  102706. * Makes a copy of the animation
  102707. * @returns Cloned animation
  102708. */
  102709. clone(): Animation;
  102710. /**
  102711. * Sets the key frames of the animation
  102712. * @param values The animation key frames to set
  102713. */
  102714. setKeys(values: Array<IAnimationKey>): void;
  102715. /**
  102716. * Serializes the animation to an object
  102717. * @returns Serialized object
  102718. */
  102719. serialize(): any;
  102720. /**
  102721. * Float animation type
  102722. */
  102723. static readonly ANIMATIONTYPE_FLOAT: number;
  102724. /**
  102725. * Vector3 animation type
  102726. */
  102727. static readonly ANIMATIONTYPE_VECTOR3: number;
  102728. /**
  102729. * Quaternion animation type
  102730. */
  102731. static readonly ANIMATIONTYPE_QUATERNION: number;
  102732. /**
  102733. * Matrix animation type
  102734. */
  102735. static readonly ANIMATIONTYPE_MATRIX: number;
  102736. /**
  102737. * Color3 animation type
  102738. */
  102739. static readonly ANIMATIONTYPE_COLOR3: number;
  102740. /**
  102741. * Color3 animation type
  102742. */
  102743. static readonly ANIMATIONTYPE_COLOR4: number;
  102744. /**
  102745. * Vector2 animation type
  102746. */
  102747. static readonly ANIMATIONTYPE_VECTOR2: number;
  102748. /**
  102749. * Size animation type
  102750. */
  102751. static readonly ANIMATIONTYPE_SIZE: number;
  102752. /**
  102753. * Relative Loop Mode
  102754. */
  102755. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102756. /**
  102757. * Cycle Loop Mode
  102758. */
  102759. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102760. /**
  102761. * Constant Loop Mode
  102762. */
  102763. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102764. /** @hidden */
  102765. static _UniversalLerp(left: any, right: any, amount: number): any;
  102766. /**
  102767. * Parses an animation object and creates an animation
  102768. * @param parsedAnimation Parsed animation object
  102769. * @returns Animation object
  102770. */
  102771. static Parse(parsedAnimation: any): Animation;
  102772. /**
  102773. * Appends the serialized animations from the source animations
  102774. * @param source Source containing the animations
  102775. * @param destination Target to store the animations
  102776. */
  102777. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102778. }
  102779. }
  102780. declare module BABYLON {
  102781. /**
  102782. * Interface containing an array of animations
  102783. */
  102784. export interface IAnimatable {
  102785. /**
  102786. * Array of animations
  102787. */
  102788. animations: Nullable<Array<Animation>>;
  102789. }
  102790. }
  102791. declare module BABYLON {
  102792. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102793. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102794. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102795. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102796. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102797. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102798. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102799. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102800. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102801. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102802. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102803. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102804. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102805. /**
  102806. * Decorator used to define property that can be serialized as reference to a camera
  102807. * @param sourceName defines the name of the property to decorate
  102808. */
  102809. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102810. /**
  102811. * Class used to help serialization objects
  102812. */
  102813. export class SerializationHelper {
  102814. /** @hidden */
  102815. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102816. /** @hidden */
  102817. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102818. /** @hidden */
  102819. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102820. /** @hidden */
  102821. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102822. /**
  102823. * Appends the serialized animations from the source animations
  102824. * @param source Source containing the animations
  102825. * @param destination Target to store the animations
  102826. */
  102827. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102828. /**
  102829. * Static function used to serialized a specific entity
  102830. * @param entity defines the entity to serialize
  102831. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102832. * @returns a JSON compatible object representing the serialization of the entity
  102833. */
  102834. static Serialize<T>(entity: T, serializationObject?: any): any;
  102835. /**
  102836. * Creates a new entity from a serialization data object
  102837. * @param creationFunction defines a function used to instanciated the new entity
  102838. * @param source defines the source serialization data
  102839. * @param scene defines the hosting scene
  102840. * @param rootUrl defines the root url for resources
  102841. * @returns a new entity
  102842. */
  102843. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102844. /**
  102845. * Clones an object
  102846. * @param creationFunction defines the function used to instanciate the new object
  102847. * @param source defines the source object
  102848. * @returns the cloned object
  102849. */
  102850. static Clone<T>(creationFunction: () => T, source: T): T;
  102851. /**
  102852. * Instanciates a new object based on a source one (some data will be shared between both object)
  102853. * @param creationFunction defines the function used to instanciate the new object
  102854. * @param source defines the source object
  102855. * @returns the new object
  102856. */
  102857. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102858. }
  102859. }
  102860. declare module BABYLON {
  102861. /**
  102862. * Class used to manipulate GUIDs
  102863. */
  102864. export class GUID {
  102865. /**
  102866. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102867. * Be aware Math.random() could cause collisions, but:
  102868. * "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"
  102869. * @returns a pseudo random id
  102870. */
  102871. static RandomId(): string;
  102872. }
  102873. }
  102874. declare module BABYLON {
  102875. /**
  102876. * Base class of all the textures in babylon.
  102877. * It groups all the common properties the materials, post process, lights... might need
  102878. * in order to make a correct use of the texture.
  102879. */
  102880. export class BaseTexture implements IAnimatable {
  102881. /**
  102882. * Default anisotropic filtering level for the application.
  102883. * It is set to 4 as a good tradeoff between perf and quality.
  102884. */
  102885. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102886. /**
  102887. * Gets or sets the unique id of the texture
  102888. */
  102889. uniqueId: number;
  102890. /**
  102891. * Define the name of the texture.
  102892. */
  102893. name: string;
  102894. /**
  102895. * Gets or sets an object used to store user defined information.
  102896. */
  102897. metadata: any;
  102898. /**
  102899. * For internal use only. Please do not use.
  102900. */
  102901. reservedDataStore: any;
  102902. private _hasAlpha;
  102903. /**
  102904. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102905. */
  102906. set hasAlpha(value: boolean);
  102907. get hasAlpha(): boolean;
  102908. /**
  102909. * Defines if the alpha value should be determined via the rgb values.
  102910. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102911. */
  102912. getAlphaFromRGB: boolean;
  102913. /**
  102914. * Intensity or strength of the texture.
  102915. * It is commonly used by materials to fine tune the intensity of the texture
  102916. */
  102917. level: number;
  102918. /**
  102919. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102920. * This is part of the texture as textures usually maps to one uv set.
  102921. */
  102922. coordinatesIndex: number;
  102923. private _coordinatesMode;
  102924. /**
  102925. * How a texture is mapped.
  102926. *
  102927. * | Value | Type | Description |
  102928. * | ----- | ----------------------------------- | ----------- |
  102929. * | 0 | EXPLICIT_MODE | |
  102930. * | 1 | SPHERICAL_MODE | |
  102931. * | 2 | PLANAR_MODE | |
  102932. * | 3 | CUBIC_MODE | |
  102933. * | 4 | PROJECTION_MODE | |
  102934. * | 5 | SKYBOX_MODE | |
  102935. * | 6 | INVCUBIC_MODE | |
  102936. * | 7 | EQUIRECTANGULAR_MODE | |
  102937. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102938. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102939. */
  102940. set coordinatesMode(value: number);
  102941. get coordinatesMode(): number;
  102942. /**
  102943. * | Value | Type | Description |
  102944. * | ----- | ------------------ | ----------- |
  102945. * | 0 | CLAMP_ADDRESSMODE | |
  102946. * | 1 | WRAP_ADDRESSMODE | |
  102947. * | 2 | MIRROR_ADDRESSMODE | |
  102948. */
  102949. wrapU: number;
  102950. /**
  102951. * | Value | Type | Description |
  102952. * | ----- | ------------------ | ----------- |
  102953. * | 0 | CLAMP_ADDRESSMODE | |
  102954. * | 1 | WRAP_ADDRESSMODE | |
  102955. * | 2 | MIRROR_ADDRESSMODE | |
  102956. */
  102957. wrapV: number;
  102958. /**
  102959. * | Value | Type | Description |
  102960. * | ----- | ------------------ | ----------- |
  102961. * | 0 | CLAMP_ADDRESSMODE | |
  102962. * | 1 | WRAP_ADDRESSMODE | |
  102963. * | 2 | MIRROR_ADDRESSMODE | |
  102964. */
  102965. wrapR: number;
  102966. /**
  102967. * With compliant hardware and browser (supporting anisotropic filtering)
  102968. * this defines the level of anisotropic filtering in the texture.
  102969. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102970. */
  102971. anisotropicFilteringLevel: number;
  102972. /**
  102973. * Define if the texture is a cube texture or if false a 2d texture.
  102974. */
  102975. get isCube(): boolean;
  102976. set isCube(value: boolean);
  102977. /**
  102978. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102979. */
  102980. get is3D(): boolean;
  102981. set is3D(value: boolean);
  102982. /**
  102983. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102984. */
  102985. get is2DArray(): boolean;
  102986. set is2DArray(value: boolean);
  102987. /**
  102988. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102989. * HDR texture are usually stored in linear space.
  102990. * This only impacts the PBR and Background materials
  102991. */
  102992. gammaSpace: boolean;
  102993. /**
  102994. * Gets or sets whether or not the texture contains RGBD data.
  102995. */
  102996. get isRGBD(): boolean;
  102997. set isRGBD(value: boolean);
  102998. /**
  102999. * Is Z inverted in the texture (useful in a cube texture).
  103000. */
  103001. invertZ: boolean;
  103002. /**
  103003. * Are mip maps generated for this texture or not.
  103004. */
  103005. get noMipmap(): boolean;
  103006. /**
  103007. * @hidden
  103008. */
  103009. lodLevelInAlpha: boolean;
  103010. /**
  103011. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103012. */
  103013. get lodGenerationOffset(): number;
  103014. set lodGenerationOffset(value: number);
  103015. /**
  103016. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103017. */
  103018. get lodGenerationScale(): number;
  103019. set lodGenerationScale(value: number);
  103020. /**
  103021. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103022. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103023. * average roughness values.
  103024. */
  103025. get linearSpecularLOD(): boolean;
  103026. set linearSpecularLOD(value: boolean);
  103027. /**
  103028. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103029. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103030. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103031. */
  103032. get irradianceTexture(): Nullable<BaseTexture>;
  103033. set irradianceTexture(value: Nullable<BaseTexture>);
  103034. /**
  103035. * Define if the texture is a render target.
  103036. */
  103037. isRenderTarget: boolean;
  103038. /**
  103039. * Define the unique id of the texture in the scene.
  103040. */
  103041. get uid(): string;
  103042. /**
  103043. * Return a string representation of the texture.
  103044. * @returns the texture as a string
  103045. */
  103046. toString(): string;
  103047. /**
  103048. * Get the class name of the texture.
  103049. * @returns "BaseTexture"
  103050. */
  103051. getClassName(): string;
  103052. /**
  103053. * Define the list of animation attached to the texture.
  103054. */
  103055. animations: Animation[];
  103056. /**
  103057. * An event triggered when the texture is disposed.
  103058. */
  103059. onDisposeObservable: Observable<BaseTexture>;
  103060. private _onDisposeObserver;
  103061. /**
  103062. * Callback triggered when the texture has been disposed.
  103063. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103064. */
  103065. set onDispose(callback: () => void);
  103066. /**
  103067. * Define the current state of the loading sequence when in delayed load mode.
  103068. */
  103069. delayLoadState: number;
  103070. private _scene;
  103071. /** @hidden */
  103072. _texture: Nullable<InternalTexture>;
  103073. private _uid;
  103074. /**
  103075. * Define if the texture is preventinga material to render or not.
  103076. * If not and the texture is not ready, the engine will use a default black texture instead.
  103077. */
  103078. get isBlocking(): boolean;
  103079. /**
  103080. * Instantiates a new BaseTexture.
  103081. * Base class of all the textures in babylon.
  103082. * It groups all the common properties the materials, post process, lights... might need
  103083. * in order to make a correct use of the texture.
  103084. * @param scene Define the scene the texture blongs to
  103085. */
  103086. constructor(scene: Nullable<Scene>);
  103087. /**
  103088. * Get the scene the texture belongs to.
  103089. * @returns the scene or null if undefined
  103090. */
  103091. getScene(): Nullable<Scene>;
  103092. /**
  103093. * Get the texture transform matrix used to offset tile the texture for istance.
  103094. * @returns the transformation matrix
  103095. */
  103096. getTextureMatrix(): Matrix;
  103097. /**
  103098. * Get the texture reflection matrix used to rotate/transform the reflection.
  103099. * @returns the reflection matrix
  103100. */
  103101. getReflectionTextureMatrix(): Matrix;
  103102. /**
  103103. * Get the underlying lower level texture from Babylon.
  103104. * @returns the insternal texture
  103105. */
  103106. getInternalTexture(): Nullable<InternalTexture>;
  103107. /**
  103108. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103109. * @returns true if ready or not blocking
  103110. */
  103111. isReadyOrNotBlocking(): boolean;
  103112. /**
  103113. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103114. * @returns true if fully ready
  103115. */
  103116. isReady(): boolean;
  103117. private _cachedSize;
  103118. /**
  103119. * Get the size of the texture.
  103120. * @returns the texture size.
  103121. */
  103122. getSize(): ISize;
  103123. /**
  103124. * Get the base size of the texture.
  103125. * It can be different from the size if the texture has been resized for POT for instance
  103126. * @returns the base size
  103127. */
  103128. getBaseSize(): ISize;
  103129. /**
  103130. * Update the sampling mode of the texture.
  103131. * Default is Trilinear mode.
  103132. *
  103133. * | Value | Type | Description |
  103134. * | ----- | ------------------ | ----------- |
  103135. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103136. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103137. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103138. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103139. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103140. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103141. * | 7 | NEAREST_LINEAR | |
  103142. * | 8 | NEAREST_NEAREST | |
  103143. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103144. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103145. * | 11 | LINEAR_LINEAR | |
  103146. * | 12 | LINEAR_NEAREST | |
  103147. *
  103148. * > _mag_: magnification filter (close to the viewer)
  103149. * > _min_: minification filter (far from the viewer)
  103150. * > _mip_: filter used between mip map levels
  103151. *@param samplingMode Define the new sampling mode of the texture
  103152. */
  103153. updateSamplingMode(samplingMode: number): void;
  103154. /**
  103155. * Scales the texture if is `canRescale()`
  103156. * @param ratio the resize factor we want to use to rescale
  103157. */
  103158. scale(ratio: number): void;
  103159. /**
  103160. * Get if the texture can rescale.
  103161. */
  103162. get canRescale(): boolean;
  103163. /** @hidden */
  103164. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103165. /** @hidden */
  103166. _rebuild(): void;
  103167. /**
  103168. * Triggers the load sequence in delayed load mode.
  103169. */
  103170. delayLoad(): void;
  103171. /**
  103172. * Clones the texture.
  103173. * @returns the cloned texture
  103174. */
  103175. clone(): Nullable<BaseTexture>;
  103176. /**
  103177. * Get the texture underlying type (INT, FLOAT...)
  103178. */
  103179. get textureType(): number;
  103180. /**
  103181. * Get the texture underlying format (RGB, RGBA...)
  103182. */
  103183. get textureFormat(): number;
  103184. /**
  103185. * Indicates that textures need to be re-calculated for all materials
  103186. */
  103187. protected _markAllSubMeshesAsTexturesDirty(): void;
  103188. /**
  103189. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103190. * This will returns an RGBA array buffer containing either in values (0-255) or
  103191. * float values (0-1) depending of the underlying buffer type.
  103192. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103193. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103194. * @param buffer defines a user defined buffer to fill with data (can be null)
  103195. * @returns The Array buffer containing the pixels data.
  103196. */
  103197. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103198. /**
  103199. * Release and destroy the underlying lower level texture aka internalTexture.
  103200. */
  103201. releaseInternalTexture(): void;
  103202. /** @hidden */
  103203. get _lodTextureHigh(): Nullable<BaseTexture>;
  103204. /** @hidden */
  103205. get _lodTextureMid(): Nullable<BaseTexture>;
  103206. /** @hidden */
  103207. get _lodTextureLow(): Nullable<BaseTexture>;
  103208. /**
  103209. * Dispose the texture and release its associated resources.
  103210. */
  103211. dispose(): void;
  103212. /**
  103213. * Serialize the texture into a JSON representation that can be parsed later on.
  103214. * @returns the JSON representation of the texture
  103215. */
  103216. serialize(): any;
  103217. /**
  103218. * Helper function to be called back once a list of texture contains only ready textures.
  103219. * @param textures Define the list of textures to wait for
  103220. * @param callback Define the callback triggered once the entire list will be ready
  103221. */
  103222. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103223. }
  103224. }
  103225. declare module BABYLON {
  103226. /**
  103227. * Options to be used when creating an effect.
  103228. */
  103229. export interface IEffectCreationOptions {
  103230. /**
  103231. * Atrributes that will be used in the shader.
  103232. */
  103233. attributes: string[];
  103234. /**
  103235. * Uniform varible names that will be set in the shader.
  103236. */
  103237. uniformsNames: string[];
  103238. /**
  103239. * Uniform buffer variable names that will be set in the shader.
  103240. */
  103241. uniformBuffersNames: string[];
  103242. /**
  103243. * Sampler texture variable names that will be set in the shader.
  103244. */
  103245. samplers: string[];
  103246. /**
  103247. * Define statements that will be set in the shader.
  103248. */
  103249. defines: any;
  103250. /**
  103251. * Possible fallbacks for this effect to improve performance when needed.
  103252. */
  103253. fallbacks: Nullable<IEffectFallbacks>;
  103254. /**
  103255. * Callback that will be called when the shader is compiled.
  103256. */
  103257. onCompiled: Nullable<(effect: Effect) => void>;
  103258. /**
  103259. * Callback that will be called if an error occurs during shader compilation.
  103260. */
  103261. onError: Nullable<(effect: Effect, errors: string) => void>;
  103262. /**
  103263. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103264. */
  103265. indexParameters?: any;
  103266. /**
  103267. * Max number of lights that can be used in the shader.
  103268. */
  103269. maxSimultaneousLights?: number;
  103270. /**
  103271. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103272. */
  103273. transformFeedbackVaryings?: Nullable<string[]>;
  103274. }
  103275. /**
  103276. * Effect containing vertex and fragment shader that can be executed on an object.
  103277. */
  103278. export class Effect implements IDisposable {
  103279. /**
  103280. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103281. */
  103282. static ShadersRepository: string;
  103283. /**
  103284. * Name of the effect.
  103285. */
  103286. name: any;
  103287. /**
  103288. * String container all the define statements that should be set on the shader.
  103289. */
  103290. defines: string;
  103291. /**
  103292. * Callback that will be called when the shader is compiled.
  103293. */
  103294. onCompiled: Nullable<(effect: Effect) => void>;
  103295. /**
  103296. * Callback that will be called if an error occurs during shader compilation.
  103297. */
  103298. onError: Nullable<(effect: Effect, errors: string) => void>;
  103299. /**
  103300. * Callback that will be called when effect is bound.
  103301. */
  103302. onBind: Nullable<(effect: Effect) => void>;
  103303. /**
  103304. * Unique ID of the effect.
  103305. */
  103306. uniqueId: number;
  103307. /**
  103308. * Observable that will be called when the shader is compiled.
  103309. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103310. */
  103311. onCompileObservable: Observable<Effect>;
  103312. /**
  103313. * Observable that will be called if an error occurs during shader compilation.
  103314. */
  103315. onErrorObservable: Observable<Effect>;
  103316. /** @hidden */
  103317. _onBindObservable: Nullable<Observable<Effect>>;
  103318. /**
  103319. * @hidden
  103320. * Specifies if the effect was previously ready
  103321. */
  103322. _wasPreviouslyReady: boolean;
  103323. /**
  103324. * Observable that will be called when effect is bound.
  103325. */
  103326. get onBindObservable(): Observable<Effect>;
  103327. /** @hidden */
  103328. _bonesComputationForcedToCPU: boolean;
  103329. private static _uniqueIdSeed;
  103330. private _engine;
  103331. private _uniformBuffersNames;
  103332. private _uniformsNames;
  103333. private _samplerList;
  103334. private _samplers;
  103335. private _isReady;
  103336. private _compilationError;
  103337. private _allFallbacksProcessed;
  103338. private _attributesNames;
  103339. private _attributes;
  103340. private _attributeLocationByName;
  103341. private _uniforms;
  103342. /**
  103343. * Key for the effect.
  103344. * @hidden
  103345. */
  103346. _key: string;
  103347. private _indexParameters;
  103348. private _fallbacks;
  103349. private _vertexSourceCode;
  103350. private _fragmentSourceCode;
  103351. private _vertexSourceCodeOverride;
  103352. private _fragmentSourceCodeOverride;
  103353. private _transformFeedbackVaryings;
  103354. /**
  103355. * Compiled shader to webGL program.
  103356. * @hidden
  103357. */
  103358. _pipelineContext: Nullable<IPipelineContext>;
  103359. private _valueCache;
  103360. private static _baseCache;
  103361. /**
  103362. * Instantiates an effect.
  103363. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103364. * @param baseName Name of the effect.
  103365. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103366. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103367. * @param samplers List of sampler variables that will be passed to the shader.
  103368. * @param engine Engine to be used to render the effect
  103369. * @param defines Define statements to be added to the shader.
  103370. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103371. * @param onCompiled Callback that will be called when the shader is compiled.
  103372. * @param onError Callback that will be called if an error occurs during shader compilation.
  103373. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103374. */
  103375. 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);
  103376. private _useFinalCode;
  103377. /**
  103378. * Unique key for this effect
  103379. */
  103380. get key(): string;
  103381. /**
  103382. * If the effect has been compiled and prepared.
  103383. * @returns if the effect is compiled and prepared.
  103384. */
  103385. isReady(): boolean;
  103386. private _isReadyInternal;
  103387. /**
  103388. * The engine the effect was initialized with.
  103389. * @returns the engine.
  103390. */
  103391. getEngine(): Engine;
  103392. /**
  103393. * The pipeline context for this effect
  103394. * @returns the associated pipeline context
  103395. */
  103396. getPipelineContext(): Nullable<IPipelineContext>;
  103397. /**
  103398. * The set of names of attribute variables for the shader.
  103399. * @returns An array of attribute names.
  103400. */
  103401. getAttributesNames(): string[];
  103402. /**
  103403. * Returns the attribute at the given index.
  103404. * @param index The index of the attribute.
  103405. * @returns The location of the attribute.
  103406. */
  103407. getAttributeLocation(index: number): number;
  103408. /**
  103409. * Returns the attribute based on the name of the variable.
  103410. * @param name of the attribute to look up.
  103411. * @returns the attribute location.
  103412. */
  103413. getAttributeLocationByName(name: string): number;
  103414. /**
  103415. * The number of attributes.
  103416. * @returns the numnber of attributes.
  103417. */
  103418. getAttributesCount(): number;
  103419. /**
  103420. * Gets the index of a uniform variable.
  103421. * @param uniformName of the uniform to look up.
  103422. * @returns the index.
  103423. */
  103424. getUniformIndex(uniformName: string): number;
  103425. /**
  103426. * Returns the attribute based on the name of the variable.
  103427. * @param uniformName of the uniform to look up.
  103428. * @returns the location of the uniform.
  103429. */
  103430. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103431. /**
  103432. * Returns an array of sampler variable names
  103433. * @returns The array of sampler variable neames.
  103434. */
  103435. getSamplers(): string[];
  103436. /**
  103437. * The error from the last compilation.
  103438. * @returns the error string.
  103439. */
  103440. getCompilationError(): string;
  103441. /**
  103442. * Gets a boolean indicating that all fallbacks were used during compilation
  103443. * @returns true if all fallbacks were used
  103444. */
  103445. allFallbacksProcessed(): boolean;
  103446. /**
  103447. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103448. * @param func The callback to be used.
  103449. */
  103450. executeWhenCompiled(func: (effect: Effect) => void): void;
  103451. private _checkIsReady;
  103452. private _loadShader;
  103453. /**
  103454. * Recompiles the webGL program
  103455. * @param vertexSourceCode The source code for the vertex shader.
  103456. * @param fragmentSourceCode The source code for the fragment shader.
  103457. * @param onCompiled Callback called when completed.
  103458. * @param onError Callback called on error.
  103459. * @hidden
  103460. */
  103461. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103462. /**
  103463. * Prepares the effect
  103464. * @hidden
  103465. */
  103466. _prepareEffect(): void;
  103467. private _processCompilationErrors;
  103468. /**
  103469. * Checks if the effect is supported. (Must be called after compilation)
  103470. */
  103471. get isSupported(): boolean;
  103472. /**
  103473. * Binds a texture to the engine to be used as output of the shader.
  103474. * @param channel Name of the output variable.
  103475. * @param texture Texture to bind.
  103476. * @hidden
  103477. */
  103478. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103479. /**
  103480. * Sets a texture on the engine to be used in the shader.
  103481. * @param channel Name of the sampler variable.
  103482. * @param texture Texture to set.
  103483. */
  103484. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103485. /**
  103486. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103487. * @param channel Name of the sampler variable.
  103488. * @param texture Texture to set.
  103489. */
  103490. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103491. /**
  103492. * Sets an array of textures on the engine to be used in the shader.
  103493. * @param channel Name of the variable.
  103494. * @param textures Textures to set.
  103495. */
  103496. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103497. /**
  103498. * 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)
  103499. * @param channel Name of the sampler variable.
  103500. * @param postProcess Post process to get the input texture from.
  103501. */
  103502. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103503. /**
  103504. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103505. * 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)
  103506. * @param channel Name of the sampler variable.
  103507. * @param postProcess Post process to get the output texture from.
  103508. */
  103509. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103510. /** @hidden */
  103511. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103512. /** @hidden */
  103513. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103514. /** @hidden */
  103515. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103516. /** @hidden */
  103517. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103518. /**
  103519. * Binds a buffer to a uniform.
  103520. * @param buffer Buffer to bind.
  103521. * @param name Name of the uniform variable to bind to.
  103522. */
  103523. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103524. /**
  103525. * Binds block to a uniform.
  103526. * @param blockName Name of the block to bind.
  103527. * @param index Index to bind.
  103528. */
  103529. bindUniformBlock(blockName: string, index: number): void;
  103530. /**
  103531. * Sets an interger value on a uniform variable.
  103532. * @param uniformName Name of the variable.
  103533. * @param value Value to be set.
  103534. * @returns this effect.
  103535. */
  103536. setInt(uniformName: string, value: number): Effect;
  103537. /**
  103538. * Sets an int array on a uniform variable.
  103539. * @param uniformName Name of the variable.
  103540. * @param array array to be set.
  103541. * @returns this effect.
  103542. */
  103543. setIntArray(uniformName: string, array: Int32Array): Effect;
  103544. /**
  103545. * 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)
  103546. * @param uniformName Name of the variable.
  103547. * @param array array to be set.
  103548. * @returns this effect.
  103549. */
  103550. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103551. /**
  103552. * 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)
  103553. * @param uniformName Name of the variable.
  103554. * @param array array to be set.
  103555. * @returns this effect.
  103556. */
  103557. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103558. /**
  103559. * 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)
  103560. * @param uniformName Name of the variable.
  103561. * @param array array to be set.
  103562. * @returns this effect.
  103563. */
  103564. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103565. /**
  103566. * Sets an float array on a uniform variable.
  103567. * @param uniformName Name of the variable.
  103568. * @param array array to be set.
  103569. * @returns this effect.
  103570. */
  103571. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103572. /**
  103573. * 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)
  103574. * @param uniformName Name of the variable.
  103575. * @param array array to be set.
  103576. * @returns this effect.
  103577. */
  103578. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103579. /**
  103580. * 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)
  103581. * @param uniformName Name of the variable.
  103582. * @param array array to be set.
  103583. * @returns this effect.
  103584. */
  103585. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103586. /**
  103587. * 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)
  103588. * @param uniformName Name of the variable.
  103589. * @param array array to be set.
  103590. * @returns this effect.
  103591. */
  103592. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103593. /**
  103594. * Sets an array on a uniform variable.
  103595. * @param uniformName Name of the variable.
  103596. * @param array array to be set.
  103597. * @returns this effect.
  103598. */
  103599. setArray(uniformName: string, array: number[]): Effect;
  103600. /**
  103601. * 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)
  103602. * @param uniformName Name of the variable.
  103603. * @param array array to be set.
  103604. * @returns this effect.
  103605. */
  103606. setArray2(uniformName: string, array: number[]): Effect;
  103607. /**
  103608. * 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)
  103609. * @param uniformName Name of the variable.
  103610. * @param array array to be set.
  103611. * @returns this effect.
  103612. */
  103613. setArray3(uniformName: string, array: number[]): Effect;
  103614. /**
  103615. * 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)
  103616. * @param uniformName Name of the variable.
  103617. * @param array array to be set.
  103618. * @returns this effect.
  103619. */
  103620. setArray4(uniformName: string, array: number[]): Effect;
  103621. /**
  103622. * Sets matrices on a uniform variable.
  103623. * @param uniformName Name of the variable.
  103624. * @param matrices matrices to be set.
  103625. * @returns this effect.
  103626. */
  103627. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103628. /**
  103629. * Sets matrix on a uniform variable.
  103630. * @param uniformName Name of the variable.
  103631. * @param matrix matrix to be set.
  103632. * @returns this effect.
  103633. */
  103634. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103635. /**
  103636. * 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)
  103637. * @param uniformName Name of the variable.
  103638. * @param matrix matrix to be set.
  103639. * @returns this effect.
  103640. */
  103641. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103642. /**
  103643. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103644. * @param uniformName Name of the variable.
  103645. * @param matrix matrix to be set.
  103646. * @returns this effect.
  103647. */
  103648. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103649. /**
  103650. * Sets a float on a uniform variable.
  103651. * @param uniformName Name of the variable.
  103652. * @param value value to be set.
  103653. * @returns this effect.
  103654. */
  103655. setFloat(uniformName: string, value: number): Effect;
  103656. /**
  103657. * Sets a boolean on a uniform variable.
  103658. * @param uniformName Name of the variable.
  103659. * @param bool value to be set.
  103660. * @returns this effect.
  103661. */
  103662. setBool(uniformName: string, bool: boolean): Effect;
  103663. /**
  103664. * Sets a Vector2 on a uniform variable.
  103665. * @param uniformName Name of the variable.
  103666. * @param vector2 vector2 to be set.
  103667. * @returns this effect.
  103668. */
  103669. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103670. /**
  103671. * Sets a float2 on a uniform variable.
  103672. * @param uniformName Name of the variable.
  103673. * @param x First float in float2.
  103674. * @param y Second float in float2.
  103675. * @returns this effect.
  103676. */
  103677. setFloat2(uniformName: string, x: number, y: number): Effect;
  103678. /**
  103679. * Sets a Vector3 on a uniform variable.
  103680. * @param uniformName Name of the variable.
  103681. * @param vector3 Value to be set.
  103682. * @returns this effect.
  103683. */
  103684. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103685. /**
  103686. * Sets a float3 on a uniform variable.
  103687. * @param uniformName Name of the variable.
  103688. * @param x First float in float3.
  103689. * @param y Second float in float3.
  103690. * @param z Third float in float3.
  103691. * @returns this effect.
  103692. */
  103693. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103694. /**
  103695. * Sets a Vector4 on a uniform variable.
  103696. * @param uniformName Name of the variable.
  103697. * @param vector4 Value to be set.
  103698. * @returns this effect.
  103699. */
  103700. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103701. /**
  103702. * Sets a float4 on a uniform variable.
  103703. * @param uniformName Name of the variable.
  103704. * @param x First float in float4.
  103705. * @param y Second float in float4.
  103706. * @param z Third float in float4.
  103707. * @param w Fourth float in float4.
  103708. * @returns this effect.
  103709. */
  103710. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103711. /**
  103712. * Sets a Color3 on a uniform variable.
  103713. * @param uniformName Name of the variable.
  103714. * @param color3 Value to be set.
  103715. * @returns this effect.
  103716. */
  103717. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103718. /**
  103719. * Sets a Color4 on a uniform variable.
  103720. * @param uniformName Name of the variable.
  103721. * @param color3 Value to be set.
  103722. * @param alpha Alpha value to be set.
  103723. * @returns this effect.
  103724. */
  103725. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103726. /**
  103727. * Sets a Color4 on a uniform variable
  103728. * @param uniformName defines the name of the variable
  103729. * @param color4 defines the value to be set
  103730. * @returns this effect.
  103731. */
  103732. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103733. /** Release all associated resources */
  103734. dispose(): void;
  103735. /**
  103736. * This function will add a new shader to the shader store
  103737. * @param name the name of the shader
  103738. * @param pixelShader optional pixel shader content
  103739. * @param vertexShader optional vertex shader content
  103740. */
  103741. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103742. /**
  103743. * Store of each shader (The can be looked up using effect.key)
  103744. */
  103745. static ShadersStore: {
  103746. [key: string]: string;
  103747. };
  103748. /**
  103749. * Store of each included file for a shader (The can be looked up using effect.key)
  103750. */
  103751. static IncludesShadersStore: {
  103752. [key: string]: string;
  103753. };
  103754. /**
  103755. * Resets the cache of effects.
  103756. */
  103757. static ResetCache(): void;
  103758. }
  103759. }
  103760. declare module BABYLON {
  103761. /**
  103762. * Interface used to describe the capabilities of the engine relatively to the current browser
  103763. */
  103764. export interface EngineCapabilities {
  103765. /** Maximum textures units per fragment shader */
  103766. maxTexturesImageUnits: number;
  103767. /** Maximum texture units per vertex shader */
  103768. maxVertexTextureImageUnits: number;
  103769. /** Maximum textures units in the entire pipeline */
  103770. maxCombinedTexturesImageUnits: number;
  103771. /** Maximum texture size */
  103772. maxTextureSize: number;
  103773. /** Maximum texture samples */
  103774. maxSamples?: number;
  103775. /** Maximum cube texture size */
  103776. maxCubemapTextureSize: number;
  103777. /** Maximum render texture size */
  103778. maxRenderTextureSize: number;
  103779. /** Maximum number of vertex attributes */
  103780. maxVertexAttribs: number;
  103781. /** Maximum number of varyings */
  103782. maxVaryingVectors: number;
  103783. /** Maximum number of uniforms per vertex shader */
  103784. maxVertexUniformVectors: number;
  103785. /** Maximum number of uniforms per fragment shader */
  103786. maxFragmentUniformVectors: number;
  103787. /** Defines if standard derivates (dx/dy) are supported */
  103788. standardDerivatives: boolean;
  103789. /** Defines if s3tc texture compression is supported */
  103790. s3tc?: WEBGL_compressed_texture_s3tc;
  103791. /** Defines if pvrtc texture compression is supported */
  103792. pvrtc: any;
  103793. /** Defines if etc1 texture compression is supported */
  103794. etc1: any;
  103795. /** Defines if etc2 texture compression is supported */
  103796. etc2: any;
  103797. /** Defines if astc texture compression is supported */
  103798. astc: any;
  103799. /** Defines if float textures are supported */
  103800. textureFloat: boolean;
  103801. /** Defines if vertex array objects are supported */
  103802. vertexArrayObject: boolean;
  103803. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103804. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103805. /** Gets the maximum level of anisotropy supported */
  103806. maxAnisotropy: number;
  103807. /** Defines if instancing is supported */
  103808. instancedArrays: boolean;
  103809. /** Defines if 32 bits indices are supported */
  103810. uintIndices: boolean;
  103811. /** Defines if high precision shaders are supported */
  103812. highPrecisionShaderSupported: boolean;
  103813. /** Defines if depth reading in the fragment shader is supported */
  103814. fragmentDepthSupported: boolean;
  103815. /** Defines if float texture linear filtering is supported*/
  103816. textureFloatLinearFiltering: boolean;
  103817. /** Defines if rendering to float textures is supported */
  103818. textureFloatRender: boolean;
  103819. /** Defines if half float textures are supported*/
  103820. textureHalfFloat: boolean;
  103821. /** Defines if half float texture linear filtering is supported*/
  103822. textureHalfFloatLinearFiltering: boolean;
  103823. /** Defines if rendering to half float textures is supported */
  103824. textureHalfFloatRender: boolean;
  103825. /** Defines if textureLOD shader command is supported */
  103826. textureLOD: boolean;
  103827. /** Defines if draw buffers extension is supported */
  103828. drawBuffersExtension: boolean;
  103829. /** Defines if depth textures are supported */
  103830. depthTextureExtension: boolean;
  103831. /** Defines if float color buffer are supported */
  103832. colorBufferFloat: boolean;
  103833. /** Gets disjoint timer query extension (null if not supported) */
  103834. timerQuery?: EXT_disjoint_timer_query;
  103835. /** Defines if timestamp can be used with timer query */
  103836. canUseTimestampForTimerQuery: boolean;
  103837. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103838. multiview?: any;
  103839. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103840. oculusMultiview?: any;
  103841. /** Function used to let the system compiles shaders in background */
  103842. parallelShaderCompile?: {
  103843. COMPLETION_STATUS_KHR: number;
  103844. };
  103845. /** Max number of texture samples for MSAA */
  103846. maxMSAASamples: number;
  103847. /** Defines if the blend min max extension is supported */
  103848. blendMinMax: boolean;
  103849. }
  103850. }
  103851. declare module BABYLON {
  103852. /**
  103853. * @hidden
  103854. **/
  103855. export class DepthCullingState {
  103856. private _isDepthTestDirty;
  103857. private _isDepthMaskDirty;
  103858. private _isDepthFuncDirty;
  103859. private _isCullFaceDirty;
  103860. private _isCullDirty;
  103861. private _isZOffsetDirty;
  103862. private _isFrontFaceDirty;
  103863. private _depthTest;
  103864. private _depthMask;
  103865. private _depthFunc;
  103866. private _cull;
  103867. private _cullFace;
  103868. private _zOffset;
  103869. private _frontFace;
  103870. /**
  103871. * Initializes the state.
  103872. */
  103873. constructor();
  103874. get isDirty(): boolean;
  103875. get zOffset(): number;
  103876. set zOffset(value: number);
  103877. get cullFace(): Nullable<number>;
  103878. set cullFace(value: Nullable<number>);
  103879. get cull(): Nullable<boolean>;
  103880. set cull(value: Nullable<boolean>);
  103881. get depthFunc(): Nullable<number>;
  103882. set depthFunc(value: Nullable<number>);
  103883. get depthMask(): boolean;
  103884. set depthMask(value: boolean);
  103885. get depthTest(): boolean;
  103886. set depthTest(value: boolean);
  103887. get frontFace(): Nullable<number>;
  103888. set frontFace(value: Nullable<number>);
  103889. reset(): void;
  103890. apply(gl: WebGLRenderingContext): void;
  103891. }
  103892. }
  103893. declare module BABYLON {
  103894. /**
  103895. * @hidden
  103896. **/
  103897. export class StencilState {
  103898. /** 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 */
  103899. static readonly ALWAYS: number;
  103900. /** Passed to stencilOperation to specify that stencil value must be kept */
  103901. static readonly KEEP: number;
  103902. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103903. static readonly REPLACE: number;
  103904. private _isStencilTestDirty;
  103905. private _isStencilMaskDirty;
  103906. private _isStencilFuncDirty;
  103907. private _isStencilOpDirty;
  103908. private _stencilTest;
  103909. private _stencilMask;
  103910. private _stencilFunc;
  103911. private _stencilFuncRef;
  103912. private _stencilFuncMask;
  103913. private _stencilOpStencilFail;
  103914. private _stencilOpDepthFail;
  103915. private _stencilOpStencilDepthPass;
  103916. get isDirty(): boolean;
  103917. get stencilFunc(): number;
  103918. set stencilFunc(value: number);
  103919. get stencilFuncRef(): number;
  103920. set stencilFuncRef(value: number);
  103921. get stencilFuncMask(): number;
  103922. set stencilFuncMask(value: number);
  103923. get stencilOpStencilFail(): number;
  103924. set stencilOpStencilFail(value: number);
  103925. get stencilOpDepthFail(): number;
  103926. set stencilOpDepthFail(value: number);
  103927. get stencilOpStencilDepthPass(): number;
  103928. set stencilOpStencilDepthPass(value: number);
  103929. get stencilMask(): number;
  103930. set stencilMask(value: number);
  103931. get stencilTest(): boolean;
  103932. set stencilTest(value: boolean);
  103933. constructor();
  103934. reset(): void;
  103935. apply(gl: WebGLRenderingContext): void;
  103936. }
  103937. }
  103938. declare module BABYLON {
  103939. /**
  103940. * @hidden
  103941. **/
  103942. export class AlphaState {
  103943. private _isAlphaBlendDirty;
  103944. private _isBlendFunctionParametersDirty;
  103945. private _isBlendEquationParametersDirty;
  103946. private _isBlendConstantsDirty;
  103947. private _alphaBlend;
  103948. private _blendFunctionParameters;
  103949. private _blendEquationParameters;
  103950. private _blendConstants;
  103951. /**
  103952. * Initializes the state.
  103953. */
  103954. constructor();
  103955. get isDirty(): boolean;
  103956. get alphaBlend(): boolean;
  103957. set alphaBlend(value: boolean);
  103958. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103959. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103960. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103961. reset(): void;
  103962. apply(gl: WebGLRenderingContext): void;
  103963. }
  103964. }
  103965. declare module BABYLON {
  103966. /** @hidden */
  103967. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103968. attributeProcessor(attribute: string): string;
  103969. varyingProcessor(varying: string, isFragment: boolean): string;
  103970. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103971. }
  103972. }
  103973. declare module BABYLON {
  103974. /**
  103975. * Interface for attribute information associated with buffer instanciation
  103976. */
  103977. export interface InstancingAttributeInfo {
  103978. /**
  103979. * Name of the GLSL attribute
  103980. * if attribute index is not specified, this is used to retrieve the index from the effect
  103981. */
  103982. attributeName: string;
  103983. /**
  103984. * Index/offset of the attribute in the vertex shader
  103985. * if not specified, this will be computes from the name.
  103986. */
  103987. index?: number;
  103988. /**
  103989. * size of the attribute, 1, 2, 3 or 4
  103990. */
  103991. attributeSize: number;
  103992. /**
  103993. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103994. */
  103995. offset: number;
  103996. /**
  103997. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103998. * default to 1
  103999. */
  104000. divisor?: number;
  104001. /**
  104002. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  104003. * default is FLOAT
  104004. */
  104005. attributeType?: number;
  104006. /**
  104007. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  104008. */
  104009. normalized?: boolean;
  104010. }
  104011. }
  104012. declare module BABYLON {
  104013. interface ThinEngine {
  104014. /**
  104015. * Update a video texture
  104016. * @param texture defines the texture to update
  104017. * @param video defines the video element to use
  104018. * @param invertY defines if data must be stored with Y axis inverted
  104019. */
  104020. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104021. }
  104022. }
  104023. declare module BABYLON {
  104024. /**
  104025. * Settings for finer control over video usage
  104026. */
  104027. export interface VideoTextureSettings {
  104028. /**
  104029. * Applies `autoplay` to video, if specified
  104030. */
  104031. autoPlay?: boolean;
  104032. /**
  104033. * Applies `loop` to video, if specified
  104034. */
  104035. loop?: boolean;
  104036. /**
  104037. * Automatically updates internal texture from video at every frame in the render loop
  104038. */
  104039. autoUpdateTexture: boolean;
  104040. /**
  104041. * Image src displayed during the video loading or until the user interacts with the video.
  104042. */
  104043. poster?: string;
  104044. }
  104045. /**
  104046. * If you want to display a video in your scene, this is the special texture for that.
  104047. * This special texture works similar to other textures, with the exception of a few parameters.
  104048. * @see https://doc.babylonjs.com/how_to/video_texture
  104049. */
  104050. export class VideoTexture extends Texture {
  104051. /**
  104052. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104053. */
  104054. readonly autoUpdateTexture: boolean;
  104055. /**
  104056. * The video instance used by the texture internally
  104057. */
  104058. readonly video: HTMLVideoElement;
  104059. private _onUserActionRequestedObservable;
  104060. /**
  104061. * Event triggerd when a dom action is required by the user to play the video.
  104062. * This happens due to recent changes in browser policies preventing video to auto start.
  104063. */
  104064. get onUserActionRequestedObservable(): Observable<Texture>;
  104065. private _generateMipMaps;
  104066. private _engine;
  104067. private _stillImageCaptured;
  104068. private _displayingPosterTexture;
  104069. private _settings;
  104070. private _createInternalTextureOnEvent;
  104071. private _frameId;
  104072. private _currentSrc;
  104073. /**
  104074. * Creates a video texture.
  104075. * If you want to display a video in your scene, this is the special texture for that.
  104076. * This special texture works similar to other textures, with the exception of a few parameters.
  104077. * @see https://doc.babylonjs.com/how_to/video_texture
  104078. * @param name optional name, will detect from video source, if not defined
  104079. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104080. * @param scene is obviously the current scene.
  104081. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104082. * @param invertY is false by default but can be used to invert video on Y axis
  104083. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104084. * @param settings allows finer control over video usage
  104085. */
  104086. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104087. private _getName;
  104088. private _getVideo;
  104089. private _createInternalTexture;
  104090. private reset;
  104091. /**
  104092. * @hidden Internal method to initiate `update`.
  104093. */
  104094. _rebuild(): void;
  104095. /**
  104096. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104097. */
  104098. update(): void;
  104099. /**
  104100. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104101. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104102. */
  104103. updateTexture(isVisible: boolean): void;
  104104. protected _updateInternalTexture: () => void;
  104105. /**
  104106. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104107. * @param url New url.
  104108. */
  104109. updateURL(url: string): void;
  104110. /**
  104111. * Clones the texture.
  104112. * @returns the cloned texture
  104113. */
  104114. clone(): VideoTexture;
  104115. /**
  104116. * Dispose the texture and release its associated resources.
  104117. */
  104118. dispose(): void;
  104119. /**
  104120. * Creates a video texture straight from a stream.
  104121. * @param scene Define the scene the texture should be created in
  104122. * @param stream Define the stream the texture should be created from
  104123. * @returns The created video texture as a promise
  104124. */
  104125. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104126. /**
  104127. * Creates a video texture straight from your WebCam video feed.
  104128. * @param scene Define the scene the texture should be created in
  104129. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104130. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104131. * @returns The created video texture as a promise
  104132. */
  104133. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104134. minWidth: number;
  104135. maxWidth: number;
  104136. minHeight: number;
  104137. maxHeight: number;
  104138. deviceId: string;
  104139. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104140. /**
  104141. * Creates a video texture straight from your WebCam video feed.
  104142. * @param scene Define the scene the texture should be created in
  104143. * @param onReady Define a callback to triggered once the texture will be ready
  104144. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104145. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104146. */
  104147. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104148. minWidth: number;
  104149. maxWidth: number;
  104150. minHeight: number;
  104151. maxHeight: number;
  104152. deviceId: string;
  104153. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104154. }
  104155. }
  104156. declare module BABYLON {
  104157. /**
  104158. * Defines the interface used by objects working like Scene
  104159. * @hidden
  104160. */
  104161. export interface ISceneLike {
  104162. _addPendingData(data: any): void;
  104163. _removePendingData(data: any): void;
  104164. offlineProvider: IOfflineProvider;
  104165. }
  104166. /** Interface defining initialization parameters for Engine class */
  104167. export interface EngineOptions extends WebGLContextAttributes {
  104168. /**
  104169. * Defines if the engine should no exceed a specified device ratio
  104170. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104171. */
  104172. limitDeviceRatio?: number;
  104173. /**
  104174. * Defines if webvr should be enabled automatically
  104175. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104176. */
  104177. autoEnableWebVR?: boolean;
  104178. /**
  104179. * Defines if webgl2 should be turned off even if supported
  104180. * @see http://doc.babylonjs.com/features/webgl2
  104181. */
  104182. disableWebGL2Support?: boolean;
  104183. /**
  104184. * Defines if webaudio should be initialized as well
  104185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104186. */
  104187. audioEngine?: boolean;
  104188. /**
  104189. * Defines if animations should run using a deterministic lock step
  104190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104191. */
  104192. deterministicLockstep?: boolean;
  104193. /** Defines the maximum steps to use with deterministic lock step mode */
  104194. lockstepMaxSteps?: number;
  104195. /** Defines the seconds between each deterministic lock step */
  104196. timeStep?: number;
  104197. /**
  104198. * Defines that engine should ignore context lost events
  104199. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104200. */
  104201. doNotHandleContextLost?: boolean;
  104202. /**
  104203. * Defines that engine should ignore modifying touch action attribute and style
  104204. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104205. */
  104206. doNotHandleTouchAction?: boolean;
  104207. /**
  104208. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104209. */
  104210. useHighPrecisionFloats?: boolean;
  104211. }
  104212. /**
  104213. * The base engine class (root of all engines)
  104214. */
  104215. export class ThinEngine {
  104216. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104217. static ExceptionList: ({
  104218. key: string;
  104219. capture: string;
  104220. captureConstraint: number;
  104221. targets: string[];
  104222. } | {
  104223. key: string;
  104224. capture: null;
  104225. captureConstraint: null;
  104226. targets: string[];
  104227. })[];
  104228. /** @hidden */
  104229. static _TextureLoaders: IInternalTextureLoader[];
  104230. /**
  104231. * Returns the current npm package of the sdk
  104232. */
  104233. static get NpmPackage(): string;
  104234. /**
  104235. * Returns the current version of the framework
  104236. */
  104237. static get Version(): string;
  104238. /**
  104239. * Returns a string describing the current engine
  104240. */
  104241. get description(): string;
  104242. /**
  104243. * Gets or sets the epsilon value used by collision engine
  104244. */
  104245. static CollisionsEpsilon: number;
  104246. /**
  104247. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104248. */
  104249. static get ShadersRepository(): string;
  104250. static set ShadersRepository(value: string);
  104251. /** @hidden */
  104252. _shaderProcessor: IShaderProcessor;
  104253. /**
  104254. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104255. */
  104256. forcePOTTextures: boolean;
  104257. /**
  104258. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104259. */
  104260. isFullscreen: boolean;
  104261. /**
  104262. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104263. */
  104264. cullBackFaces: boolean;
  104265. /**
  104266. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104267. */
  104268. renderEvenInBackground: boolean;
  104269. /**
  104270. * Gets or sets a boolean indicating that cache can be kept between frames
  104271. */
  104272. preventCacheWipeBetweenFrames: boolean;
  104273. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104274. validateShaderPrograms: boolean;
  104275. /**
  104276. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104277. * This can provide greater z depth for distant objects.
  104278. */
  104279. useReverseDepthBuffer: boolean;
  104280. /**
  104281. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104282. */
  104283. disableUniformBuffers: boolean;
  104284. /** @hidden */
  104285. _uniformBuffers: UniformBuffer[];
  104286. /**
  104287. * Gets a boolean indicating that the engine supports uniform buffers
  104288. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104289. */
  104290. get supportsUniformBuffers(): boolean;
  104291. /** @hidden */
  104292. _gl: WebGLRenderingContext;
  104293. /** @hidden */
  104294. _webGLVersion: number;
  104295. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104296. protected _windowIsBackground: boolean;
  104297. protected _creationOptions: EngineOptions;
  104298. protected _highPrecisionShadersAllowed: boolean;
  104299. /** @hidden */
  104300. get _shouldUseHighPrecisionShader(): boolean;
  104301. /**
  104302. * Gets a boolean indicating that only power of 2 textures are supported
  104303. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104304. */
  104305. get needPOTTextures(): boolean;
  104306. /** @hidden */
  104307. _badOS: boolean;
  104308. /** @hidden */
  104309. _badDesktopOS: boolean;
  104310. private _hardwareScalingLevel;
  104311. /** @hidden */
  104312. _caps: EngineCapabilities;
  104313. private _isStencilEnable;
  104314. private _glVersion;
  104315. private _glRenderer;
  104316. private _glVendor;
  104317. /** @hidden */
  104318. _videoTextureSupported: boolean;
  104319. protected _renderingQueueLaunched: boolean;
  104320. protected _activeRenderLoops: (() => void)[];
  104321. /**
  104322. * Observable signaled when a context lost event is raised
  104323. */
  104324. onContextLostObservable: Observable<ThinEngine>;
  104325. /**
  104326. * Observable signaled when a context restored event is raised
  104327. */
  104328. onContextRestoredObservable: Observable<ThinEngine>;
  104329. private _onContextLost;
  104330. private _onContextRestored;
  104331. protected _contextWasLost: boolean;
  104332. /** @hidden */
  104333. _doNotHandleContextLost: boolean;
  104334. /**
  104335. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104336. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104337. */
  104338. get doNotHandleContextLost(): boolean;
  104339. set doNotHandleContextLost(value: boolean);
  104340. /**
  104341. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104342. */
  104343. disableVertexArrayObjects: boolean;
  104344. /** @hidden */
  104345. protected _colorWrite: boolean;
  104346. /** @hidden */
  104347. protected _colorWriteChanged: boolean;
  104348. /** @hidden */
  104349. protected _depthCullingState: DepthCullingState;
  104350. /** @hidden */
  104351. protected _stencilState: StencilState;
  104352. /** @hidden */
  104353. _alphaState: AlphaState;
  104354. /** @hidden */
  104355. _alphaMode: number;
  104356. /** @hidden */
  104357. _alphaEquation: number;
  104358. /** @hidden */
  104359. _internalTexturesCache: InternalTexture[];
  104360. /** @hidden */
  104361. protected _activeChannel: number;
  104362. private _currentTextureChannel;
  104363. /** @hidden */
  104364. protected _boundTexturesCache: {
  104365. [key: string]: Nullable<InternalTexture>;
  104366. };
  104367. /** @hidden */
  104368. protected _currentEffect: Nullable<Effect>;
  104369. /** @hidden */
  104370. protected _currentProgram: Nullable<WebGLProgram>;
  104371. private _compiledEffects;
  104372. private _vertexAttribArraysEnabled;
  104373. /** @hidden */
  104374. protected _cachedViewport: Nullable<IViewportLike>;
  104375. private _cachedVertexArrayObject;
  104376. /** @hidden */
  104377. protected _cachedVertexBuffers: any;
  104378. /** @hidden */
  104379. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104380. /** @hidden */
  104381. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104382. /** @hidden */
  104383. _currentRenderTarget: Nullable<InternalTexture>;
  104384. private _uintIndicesCurrentlySet;
  104385. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104386. /** @hidden */
  104387. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104388. private _currentBufferPointers;
  104389. private _currentInstanceLocations;
  104390. private _currentInstanceBuffers;
  104391. private _textureUnits;
  104392. /** @hidden */
  104393. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104394. /** @hidden */
  104395. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104396. /** @hidden */
  104397. _boundRenderFunction: any;
  104398. private _vaoRecordInProgress;
  104399. private _mustWipeVertexAttributes;
  104400. private _emptyTexture;
  104401. private _emptyCubeTexture;
  104402. private _emptyTexture3D;
  104403. private _emptyTexture2DArray;
  104404. /** @hidden */
  104405. _frameHandler: number;
  104406. private _nextFreeTextureSlots;
  104407. private _maxSimultaneousTextures;
  104408. private _activeRequests;
  104409. protected _texturesSupported: string[];
  104410. /** @hidden */
  104411. _textureFormatInUse: Nullable<string>;
  104412. protected get _supportsHardwareTextureRescaling(): boolean;
  104413. private _framebufferDimensionsObject;
  104414. /**
  104415. * sets the object from which width and height will be taken from when getting render width and height
  104416. * Will fallback to the gl object
  104417. * @param dimensions the framebuffer width and height that will be used.
  104418. */
  104419. set framebufferDimensionsObject(dimensions: Nullable<{
  104420. framebufferWidth: number;
  104421. framebufferHeight: number;
  104422. }>);
  104423. /**
  104424. * Gets the list of texture formats supported
  104425. */
  104426. get texturesSupported(): Array<string>;
  104427. /**
  104428. * Gets the list of texture formats in use
  104429. */
  104430. get textureFormatInUse(): Nullable<string>;
  104431. /**
  104432. * Gets the current viewport
  104433. */
  104434. get currentViewport(): Nullable<IViewportLike>;
  104435. /**
  104436. * Gets the default empty texture
  104437. */
  104438. get emptyTexture(): InternalTexture;
  104439. /**
  104440. * Gets the default empty 3D texture
  104441. */
  104442. get emptyTexture3D(): InternalTexture;
  104443. /**
  104444. * Gets the default empty 2D array texture
  104445. */
  104446. get emptyTexture2DArray(): InternalTexture;
  104447. /**
  104448. * Gets the default empty cube texture
  104449. */
  104450. get emptyCubeTexture(): InternalTexture;
  104451. /**
  104452. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104453. */
  104454. readonly premultipliedAlpha: boolean;
  104455. /**
  104456. * Observable event triggered before each texture is initialized
  104457. */
  104458. onBeforeTextureInitObservable: Observable<Texture>;
  104459. /**
  104460. * Creates a new engine
  104461. * @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
  104462. * @param antialias defines enable antialiasing (default: false)
  104463. * @param options defines further options to be sent to the getContext() function
  104464. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104465. */
  104466. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104467. private _rebuildInternalTextures;
  104468. private _rebuildEffects;
  104469. /**
  104470. * Gets a boolean indicating if all created effects are ready
  104471. * @returns true if all effects are ready
  104472. */
  104473. areAllEffectsReady(): boolean;
  104474. protected _rebuildBuffers(): void;
  104475. private _initGLContext;
  104476. /**
  104477. * Gets version of the current webGL context
  104478. */
  104479. get webGLVersion(): number;
  104480. /**
  104481. * Gets a string idenfifying the name of the class
  104482. * @returns "Engine" string
  104483. */
  104484. getClassName(): string;
  104485. /**
  104486. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104487. */
  104488. get isStencilEnable(): boolean;
  104489. /** @hidden */
  104490. _prepareWorkingCanvas(): void;
  104491. /**
  104492. * Reset the texture cache to empty state
  104493. */
  104494. resetTextureCache(): void;
  104495. /**
  104496. * Gets an object containing information about the current webGL context
  104497. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104498. */
  104499. getGlInfo(): {
  104500. vendor: string;
  104501. renderer: string;
  104502. version: string;
  104503. };
  104504. /**
  104505. * Defines the hardware scaling level.
  104506. * By default the hardware scaling level is computed from the window device ratio.
  104507. * 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.
  104508. * @param level defines the level to use
  104509. */
  104510. setHardwareScalingLevel(level: number): void;
  104511. /**
  104512. * Gets the current hardware scaling level.
  104513. * By default the hardware scaling level is computed from the window device ratio.
  104514. * 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.
  104515. * @returns a number indicating the current hardware scaling level
  104516. */
  104517. getHardwareScalingLevel(): number;
  104518. /**
  104519. * Gets the list of loaded textures
  104520. * @returns an array containing all loaded textures
  104521. */
  104522. getLoadedTexturesCache(): InternalTexture[];
  104523. /**
  104524. * Gets the object containing all engine capabilities
  104525. * @returns the EngineCapabilities object
  104526. */
  104527. getCaps(): EngineCapabilities;
  104528. /**
  104529. * stop executing a render loop function and remove it from the execution array
  104530. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104531. */
  104532. stopRenderLoop(renderFunction?: () => void): void;
  104533. /** @hidden */
  104534. _renderLoop(): void;
  104535. /**
  104536. * Gets the HTML canvas attached with the current webGL context
  104537. * @returns a HTML canvas
  104538. */
  104539. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104540. /**
  104541. * Gets host window
  104542. * @returns the host window object
  104543. */
  104544. getHostWindow(): Nullable<Window>;
  104545. /**
  104546. * Gets the current render width
  104547. * @param useScreen defines if screen size must be used (or the current render target if any)
  104548. * @returns a number defining the current render width
  104549. */
  104550. getRenderWidth(useScreen?: boolean): number;
  104551. /**
  104552. * Gets the current render height
  104553. * @param useScreen defines if screen size must be used (or the current render target if any)
  104554. * @returns a number defining the current render height
  104555. */
  104556. getRenderHeight(useScreen?: boolean): number;
  104557. /**
  104558. * Can be used to override the current requestAnimationFrame requester.
  104559. * @hidden
  104560. */
  104561. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104562. /**
  104563. * Register and execute a render loop. The engine can have more than one render function
  104564. * @param renderFunction defines the function to continuously execute
  104565. */
  104566. runRenderLoop(renderFunction: () => void): void;
  104567. /**
  104568. * Clear the current render buffer or the current render target (if any is set up)
  104569. * @param color defines the color to use
  104570. * @param backBuffer defines if the back buffer must be cleared
  104571. * @param depth defines if the depth buffer must be cleared
  104572. * @param stencil defines if the stencil buffer must be cleared
  104573. */
  104574. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104575. private _viewportCached;
  104576. /** @hidden */
  104577. _viewport(x: number, y: number, width: number, height: number): void;
  104578. /**
  104579. * Set the WebGL's viewport
  104580. * @param viewport defines the viewport element to be used
  104581. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104582. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104583. */
  104584. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104585. /**
  104586. * Begin a new frame
  104587. */
  104588. beginFrame(): void;
  104589. /**
  104590. * Enf the current frame
  104591. */
  104592. endFrame(): void;
  104593. /**
  104594. * Resize the view according to the canvas' size
  104595. */
  104596. resize(): void;
  104597. /**
  104598. * Force a specific size of the canvas
  104599. * @param width defines the new canvas' width
  104600. * @param height defines the new canvas' height
  104601. */
  104602. setSize(width: number, height: number): void;
  104603. /**
  104604. * Binds the frame buffer to the specified texture.
  104605. * @param texture The texture to render to or null for the default canvas
  104606. * @param faceIndex The face of the texture to render to in case of cube texture
  104607. * @param requiredWidth The width of the target to render to
  104608. * @param requiredHeight The height of the target to render to
  104609. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104610. * @param lodLevel defines the lod level to bind to the frame buffer
  104611. * @param layer defines the 2d array index to bind to frame buffer to
  104612. */
  104613. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104614. /** @hidden */
  104615. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104616. /**
  104617. * Unbind the current render target texture from the webGL context
  104618. * @param texture defines the render target texture to unbind
  104619. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104620. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104621. */
  104622. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104623. /**
  104624. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104625. */
  104626. flushFramebuffer(): void;
  104627. /**
  104628. * Unbind the current render target and bind the default framebuffer
  104629. */
  104630. restoreDefaultFramebuffer(): void;
  104631. /** @hidden */
  104632. protected _resetVertexBufferBinding(): void;
  104633. /**
  104634. * Creates a vertex buffer
  104635. * @param data the data for the vertex buffer
  104636. * @returns the new WebGL static buffer
  104637. */
  104638. createVertexBuffer(data: DataArray): DataBuffer;
  104639. private _createVertexBuffer;
  104640. /**
  104641. * Creates a dynamic vertex buffer
  104642. * @param data the data for the dynamic vertex buffer
  104643. * @returns the new WebGL dynamic buffer
  104644. */
  104645. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104646. protected _resetIndexBufferBinding(): void;
  104647. /**
  104648. * Creates a new index buffer
  104649. * @param indices defines the content of the index buffer
  104650. * @param updatable defines if the index buffer must be updatable
  104651. * @returns a new webGL buffer
  104652. */
  104653. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104654. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104655. /**
  104656. * Bind a webGL buffer to the webGL context
  104657. * @param buffer defines the buffer to bind
  104658. */
  104659. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104660. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104661. private bindBuffer;
  104662. /**
  104663. * update the bound buffer with the given data
  104664. * @param data defines the data to update
  104665. */
  104666. updateArrayBuffer(data: Float32Array): void;
  104667. private _vertexAttribPointer;
  104668. /** @hidden */
  104669. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104670. private _bindVertexBuffersAttributes;
  104671. /**
  104672. * Records a vertex array object
  104673. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104674. * @param vertexBuffers defines the list of vertex buffers to store
  104675. * @param indexBuffer defines the index buffer to store
  104676. * @param effect defines the effect to store
  104677. * @returns the new vertex array object
  104678. */
  104679. recordVertexArrayObject(vertexBuffers: {
  104680. [key: string]: VertexBuffer;
  104681. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104682. /**
  104683. * Bind a specific vertex array object
  104684. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104685. * @param vertexArrayObject defines the vertex array object to bind
  104686. * @param indexBuffer defines the index buffer to bind
  104687. */
  104688. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104689. /**
  104690. * Bind webGl buffers directly to the webGL context
  104691. * @param vertexBuffer defines the vertex buffer to bind
  104692. * @param indexBuffer defines the index buffer to bind
  104693. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104694. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104695. * @param effect defines the effect associated with the vertex buffer
  104696. */
  104697. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104698. private _unbindVertexArrayObject;
  104699. /**
  104700. * Bind a list of vertex buffers to the webGL context
  104701. * @param vertexBuffers defines the list of vertex buffers to bind
  104702. * @param indexBuffer defines the index buffer to bind
  104703. * @param effect defines the effect associated with the vertex buffers
  104704. */
  104705. bindBuffers(vertexBuffers: {
  104706. [key: string]: Nullable<VertexBuffer>;
  104707. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104708. /**
  104709. * Unbind all instance attributes
  104710. */
  104711. unbindInstanceAttributes(): void;
  104712. /**
  104713. * Release and free the memory of a vertex array object
  104714. * @param vao defines the vertex array object to delete
  104715. */
  104716. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104717. /** @hidden */
  104718. _releaseBuffer(buffer: DataBuffer): boolean;
  104719. protected _deleteBuffer(buffer: DataBuffer): void;
  104720. /**
  104721. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104722. * @param instancesBuffer defines the webGL buffer to update and bind
  104723. * @param data defines the data to store in the buffer
  104724. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104725. */
  104726. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104727. /**
  104728. * Bind the content of a webGL buffer used with instantiation
  104729. * @param instancesBuffer defines the webGL buffer to bind
  104730. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104731. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104732. */
  104733. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104734. /**
  104735. * Disable the instance attribute corresponding to the name in parameter
  104736. * @param name defines the name of the attribute to disable
  104737. */
  104738. disableInstanceAttributeByName(name: string): void;
  104739. /**
  104740. * Disable the instance attribute corresponding to the location in parameter
  104741. * @param attributeLocation defines the attribute location of the attribute to disable
  104742. */
  104743. disableInstanceAttribute(attributeLocation: number): void;
  104744. /**
  104745. * Disable the attribute corresponding to the location in parameter
  104746. * @param attributeLocation defines the attribute location of the attribute to disable
  104747. */
  104748. disableAttributeByIndex(attributeLocation: number): void;
  104749. /**
  104750. * Send a draw order
  104751. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104752. * @param indexStart defines the starting index
  104753. * @param indexCount defines the number of index to draw
  104754. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104755. */
  104756. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104757. /**
  104758. * Draw a list of points
  104759. * @param verticesStart defines the index of first vertex to draw
  104760. * @param verticesCount defines the count of vertices to draw
  104761. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104762. */
  104763. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104764. /**
  104765. * Draw a list of unindexed primitives
  104766. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104767. * @param verticesStart defines the index of first vertex to draw
  104768. * @param verticesCount defines the count of vertices to draw
  104769. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104770. */
  104771. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104772. /**
  104773. * Draw a list of indexed primitives
  104774. * @param fillMode defines the primitive to use
  104775. * @param indexStart defines the starting index
  104776. * @param indexCount defines the number of index to draw
  104777. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104778. */
  104779. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104780. /**
  104781. * Draw a list of unindexed primitives
  104782. * @param fillMode defines the primitive to use
  104783. * @param verticesStart defines the index of first vertex to draw
  104784. * @param verticesCount defines the count of vertices to draw
  104785. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104786. */
  104787. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104788. private _drawMode;
  104789. /** @hidden */
  104790. protected _reportDrawCall(): void;
  104791. /** @hidden */
  104792. _releaseEffect(effect: Effect): void;
  104793. /** @hidden */
  104794. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104795. /**
  104796. * Create a new effect (used to store vertex/fragment shaders)
  104797. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104798. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104799. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104800. * @param samplers defines an array of string used to represent textures
  104801. * @param defines defines the string containing the defines to use to compile the shaders
  104802. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104803. * @param onCompiled defines a function to call when the effect creation is successful
  104804. * @param onError defines a function to call when the effect creation has failed
  104805. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104806. * @returns the new Effect
  104807. */
  104808. 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;
  104809. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104810. private _compileShader;
  104811. private _compileRawShader;
  104812. /**
  104813. * Directly creates a webGL program
  104814. * @param pipelineContext defines the pipeline context to attach to
  104815. * @param vertexCode defines the vertex shader code to use
  104816. * @param fragmentCode defines the fragment shader code to use
  104817. * @param context defines the webGL context to use (if not set, the current one will be used)
  104818. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104819. * @returns the new webGL program
  104820. */
  104821. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104822. /**
  104823. * Creates a webGL program
  104824. * @param pipelineContext defines the pipeline context to attach to
  104825. * @param vertexCode defines the vertex shader code to use
  104826. * @param fragmentCode defines the fragment shader code to use
  104827. * @param defines defines the string containing the defines to use to compile the shaders
  104828. * @param context defines the webGL context to use (if not set, the current one will be used)
  104829. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104830. * @returns the new webGL program
  104831. */
  104832. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104833. /**
  104834. * Creates a new pipeline context
  104835. * @returns the new pipeline
  104836. */
  104837. createPipelineContext(): IPipelineContext;
  104838. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104839. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104840. /** @hidden */
  104841. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104842. /** @hidden */
  104843. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104844. /** @hidden */
  104845. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104846. /**
  104847. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104848. * @param pipelineContext defines the pipeline context to use
  104849. * @param uniformsNames defines the list of uniform names
  104850. * @returns an array of webGL uniform locations
  104851. */
  104852. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104853. /**
  104854. * Gets the lsit of active attributes for a given webGL program
  104855. * @param pipelineContext defines the pipeline context to use
  104856. * @param attributesNames defines the list of attribute names to get
  104857. * @returns an array of indices indicating the offset of each attribute
  104858. */
  104859. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104860. /**
  104861. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104862. * @param effect defines the effect to activate
  104863. */
  104864. enableEffect(effect: Nullable<Effect>): void;
  104865. /**
  104866. * Set the value of an uniform to a number (int)
  104867. * @param uniform defines the webGL uniform location where to store the value
  104868. * @param value defines the int number to store
  104869. */
  104870. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104871. /**
  104872. * Set the value of an uniform to an array of int32
  104873. * @param uniform defines the webGL uniform location where to store the value
  104874. * @param array defines the array of int32 to store
  104875. */
  104876. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104877. /**
  104878. * Set the value of an uniform to an array of int32 (stored as vec2)
  104879. * @param uniform defines the webGL uniform location where to store the value
  104880. * @param array defines the array of int32 to store
  104881. */
  104882. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104883. /**
  104884. * Set the value of an uniform to an array of int32 (stored as vec3)
  104885. * @param uniform defines the webGL uniform location where to store the value
  104886. * @param array defines the array of int32 to store
  104887. */
  104888. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104889. /**
  104890. * Set the value of an uniform to an array of int32 (stored as vec4)
  104891. * @param uniform defines the webGL uniform location where to store the value
  104892. * @param array defines the array of int32 to store
  104893. */
  104894. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104895. /**
  104896. * Set the value of an uniform to an array of number
  104897. * @param uniform defines the webGL uniform location where to store the value
  104898. * @param array defines the array of number to store
  104899. */
  104900. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104901. /**
  104902. * Set the value of an uniform to an array of number (stored as vec2)
  104903. * @param uniform defines the webGL uniform location where to store the value
  104904. * @param array defines the array of number to store
  104905. */
  104906. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104907. /**
  104908. * Set the value of an uniform to an array of number (stored as vec3)
  104909. * @param uniform defines the webGL uniform location where to store the value
  104910. * @param array defines the array of number to store
  104911. */
  104912. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104913. /**
  104914. * Set the value of an uniform to an array of number (stored as vec4)
  104915. * @param uniform defines the webGL uniform location where to store the value
  104916. * @param array defines the array of number to store
  104917. */
  104918. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104919. /**
  104920. * Set the value of an uniform to an array of float32 (stored as matrices)
  104921. * @param uniform defines the webGL uniform location where to store the value
  104922. * @param matrices defines the array of float32 to store
  104923. */
  104924. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104925. /**
  104926. * Set the value of an uniform to a matrix (3x3)
  104927. * @param uniform defines the webGL uniform location where to store the value
  104928. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104929. */
  104930. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104931. /**
  104932. * Set the value of an uniform to a matrix (2x2)
  104933. * @param uniform defines the webGL uniform location where to store the value
  104934. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104935. */
  104936. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104937. /**
  104938. * Set the value of an uniform to a number (float)
  104939. * @param uniform defines the webGL uniform location where to store the value
  104940. * @param value defines the float number to store
  104941. */
  104942. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104943. /**
  104944. * Set the value of an uniform to a vec2
  104945. * @param uniform defines the webGL uniform location where to store the value
  104946. * @param x defines the 1st component of the value
  104947. * @param y defines the 2nd component of the value
  104948. */
  104949. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104950. /**
  104951. * Set the value of an uniform to a vec3
  104952. * @param uniform defines the webGL uniform location where to store the value
  104953. * @param x defines the 1st component of the value
  104954. * @param y defines the 2nd component of the value
  104955. * @param z defines the 3rd component of the value
  104956. */
  104957. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104958. /**
  104959. * Set the value of an uniform to a vec4
  104960. * @param uniform defines the webGL uniform location where to store the value
  104961. * @param x defines the 1st component of the value
  104962. * @param y defines the 2nd component of the value
  104963. * @param z defines the 3rd component of the value
  104964. * @param w defines the 4th component of the value
  104965. */
  104966. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104967. /**
  104968. * Apply all cached states (depth, culling, stencil and alpha)
  104969. */
  104970. applyStates(): void;
  104971. /**
  104972. * Enable or disable color writing
  104973. * @param enable defines the state to set
  104974. */
  104975. setColorWrite(enable: boolean): void;
  104976. /**
  104977. * Gets a boolean indicating if color writing is enabled
  104978. * @returns the current color writing state
  104979. */
  104980. getColorWrite(): boolean;
  104981. /**
  104982. * Gets the depth culling state manager
  104983. */
  104984. get depthCullingState(): DepthCullingState;
  104985. /**
  104986. * Gets the alpha state manager
  104987. */
  104988. get alphaState(): AlphaState;
  104989. /**
  104990. * Gets the stencil state manager
  104991. */
  104992. get stencilState(): StencilState;
  104993. /**
  104994. * Clears the list of texture accessible through engine.
  104995. * This can help preventing texture load conflict due to name collision.
  104996. */
  104997. clearInternalTexturesCache(): void;
  104998. /**
  104999. * Force the entire cache to be cleared
  105000. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  105001. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  105002. */
  105003. wipeCaches(bruteForce?: boolean): void;
  105004. /** @hidden */
  105005. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  105006. min: number;
  105007. mag: number;
  105008. };
  105009. /** @hidden */
  105010. _createTexture(): WebGLTexture;
  105011. /**
  105012. * Usually called from Texture.ts.
  105013. * Passed information to create a WebGLTexture
  105014. * @param urlArg defines a value which contains one of the following:
  105015. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  105016. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  105017. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  105018. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  105019. * @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)
  105020. * @param scene needed for loading to the correct scene
  105021. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105022. * @param onLoad optional callback to be called upon successful completion
  105023. * @param onError optional callback to be called upon failure
  105024. * @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
  105025. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105026. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105027. * @param forcedExtension defines the extension to use to pick the right loader
  105028. * @param mimeType defines an optional mime type
  105029. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105030. */
  105031. 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;
  105032. /**
  105033. * Loads an image as an HTMLImageElement.
  105034. * @param input url string, ArrayBuffer, or Blob to load
  105035. * @param onLoad callback called when the image successfully loads
  105036. * @param onError callback called when the image fails to load
  105037. * @param offlineProvider offline provider for caching
  105038. * @param mimeType optional mime type
  105039. * @returns the HTMLImageElement of the loaded image
  105040. * @hidden
  105041. */
  105042. 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>;
  105043. /**
  105044. * @hidden
  105045. */
  105046. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105047. /**
  105048. * Creates a raw texture
  105049. * @param data defines the data to store in the texture
  105050. * @param width defines the width of the texture
  105051. * @param height defines the height of the texture
  105052. * @param format defines the format of the data
  105053. * @param generateMipMaps defines if the engine should generate the mip levels
  105054. * @param invertY defines if data must be stored with Y axis inverted
  105055. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105056. * @param compression defines the compression used (null by default)
  105057. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105058. * @returns the raw texture inside an InternalTexture
  105059. */
  105060. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105061. /**
  105062. * Creates a new raw cube texture
  105063. * @param data defines the array of data to use to create each face
  105064. * @param size defines the size of the textures
  105065. * @param format defines the format of the data
  105066. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105067. * @param generateMipMaps defines if the engine should generate the mip levels
  105068. * @param invertY defines if data must be stored with Y axis inverted
  105069. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105070. * @param compression defines the compression used (null by default)
  105071. * @returns the cube texture as an InternalTexture
  105072. */
  105073. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105074. /**
  105075. * Creates a new raw 3D texture
  105076. * @param data defines the data used to create the texture
  105077. * @param width defines the width of the texture
  105078. * @param height defines the height of the texture
  105079. * @param depth defines the depth of the texture
  105080. * @param format defines the format of the texture
  105081. * @param generateMipMaps defines if the engine must generate mip levels
  105082. * @param invertY defines if data must be stored with Y axis inverted
  105083. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105084. * @param compression defines the compressed used (can be null)
  105085. * @param textureType defines the compressed used (can be null)
  105086. * @returns a new raw 3D texture (stored in an InternalTexture)
  105087. */
  105088. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105089. /**
  105090. * Creates a new raw 2D array texture
  105091. * @param data defines the data used to create the texture
  105092. * @param width defines the width of the texture
  105093. * @param height defines the height of the texture
  105094. * @param depth defines the number of layers of the texture
  105095. * @param format defines the format of the texture
  105096. * @param generateMipMaps defines if the engine must generate mip levels
  105097. * @param invertY defines if data must be stored with Y axis inverted
  105098. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105099. * @param compression defines the compressed used (can be null)
  105100. * @param textureType defines the compressed used (can be null)
  105101. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105102. */
  105103. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105104. private _unpackFlipYCached;
  105105. /**
  105106. * In case you are sharing the context with other applications, it might
  105107. * be interested to not cache the unpack flip y state to ensure a consistent
  105108. * value would be set.
  105109. */
  105110. enableUnpackFlipYCached: boolean;
  105111. /** @hidden */
  105112. _unpackFlipY(value: boolean): void;
  105113. /** @hidden */
  105114. _getUnpackAlignement(): number;
  105115. private _getTextureTarget;
  105116. /**
  105117. * Update the sampling mode of a given texture
  105118. * @param samplingMode defines the required sampling mode
  105119. * @param texture defines the texture to update
  105120. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105121. */
  105122. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105123. /**
  105124. * Update the sampling mode of a given texture
  105125. * @param texture defines the texture to update
  105126. * @param wrapU defines the texture wrap mode of the u coordinates
  105127. * @param wrapV defines the texture wrap mode of the v coordinates
  105128. * @param wrapR defines the texture wrap mode of the r coordinates
  105129. */
  105130. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105131. /** @hidden */
  105132. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105133. width: number;
  105134. height: number;
  105135. layers?: number;
  105136. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105137. /** @hidden */
  105138. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105139. /** @hidden */
  105140. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105141. /**
  105142. * Update a portion of an internal texture
  105143. * @param texture defines the texture to update
  105144. * @param imageData defines the data to store into the texture
  105145. * @param xOffset defines the x coordinates of the update rectangle
  105146. * @param yOffset defines the y coordinates of the update rectangle
  105147. * @param width defines the width of the update rectangle
  105148. * @param height defines the height of the update rectangle
  105149. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105150. * @param lod defines the lod level to update (0 by default)
  105151. */
  105152. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105153. /** @hidden */
  105154. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105155. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105156. private _prepareWebGLTexture;
  105157. /** @hidden */
  105158. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105159. private _getDepthStencilBuffer;
  105160. /** @hidden */
  105161. _releaseFramebufferObjects(texture: InternalTexture): void;
  105162. /** @hidden */
  105163. _releaseTexture(texture: InternalTexture): void;
  105164. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105165. protected _setProgram(program: WebGLProgram): void;
  105166. protected _boundUniforms: {
  105167. [key: number]: WebGLUniformLocation;
  105168. };
  105169. /**
  105170. * Binds an effect to the webGL context
  105171. * @param effect defines the effect to bind
  105172. */
  105173. bindSamplers(effect: Effect): void;
  105174. private _activateCurrentTexture;
  105175. /** @hidden */
  105176. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105177. /** @hidden */
  105178. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105179. /**
  105180. * Unbind all textures from the webGL context
  105181. */
  105182. unbindAllTextures(): void;
  105183. /**
  105184. * Sets a texture to the according uniform.
  105185. * @param channel The texture channel
  105186. * @param uniform The uniform to set
  105187. * @param texture The texture to apply
  105188. */
  105189. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105190. private _bindSamplerUniformToChannel;
  105191. private _getTextureWrapMode;
  105192. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105193. /**
  105194. * Sets an array of texture to the webGL context
  105195. * @param channel defines the channel where the texture array must be set
  105196. * @param uniform defines the associated uniform location
  105197. * @param textures defines the array of textures to bind
  105198. */
  105199. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105200. /** @hidden */
  105201. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105202. private _setTextureParameterFloat;
  105203. private _setTextureParameterInteger;
  105204. /**
  105205. * Unbind all vertex attributes from the webGL context
  105206. */
  105207. unbindAllAttributes(): void;
  105208. /**
  105209. * 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
  105210. */
  105211. releaseEffects(): void;
  105212. /**
  105213. * Dispose and release all associated resources
  105214. */
  105215. dispose(): void;
  105216. /**
  105217. * Attach a new callback raised when context lost event is fired
  105218. * @param callback defines the callback to call
  105219. */
  105220. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105221. /**
  105222. * Attach a new callback raised when context restored event is fired
  105223. * @param callback defines the callback to call
  105224. */
  105225. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105226. /**
  105227. * Get the current error code of the webGL context
  105228. * @returns the error code
  105229. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105230. */
  105231. getError(): number;
  105232. private _canRenderToFloatFramebuffer;
  105233. private _canRenderToHalfFloatFramebuffer;
  105234. private _canRenderToFramebuffer;
  105235. /** @hidden */
  105236. _getWebGLTextureType(type: number): number;
  105237. /** @hidden */
  105238. _getInternalFormat(format: number): number;
  105239. /** @hidden */
  105240. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105241. /** @hidden */
  105242. _getRGBAMultiSampleBufferFormat(type: number): number;
  105243. /** @hidden */
  105244. _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;
  105245. /**
  105246. * Loads a file from a url
  105247. * @param url url to load
  105248. * @param onSuccess callback called when the file successfully loads
  105249. * @param onProgress callback called while file is loading (if the server supports this mode)
  105250. * @param offlineProvider defines the offline provider for caching
  105251. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105252. * @param onError callback called when the file fails to load
  105253. * @returns a file request object
  105254. * @hidden
  105255. */
  105256. 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;
  105257. /**
  105258. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105259. * @param x defines the x coordinate of the rectangle where pixels must be read
  105260. * @param y defines the y coordinate of the rectangle where pixels must be read
  105261. * @param width defines the width of the rectangle where pixels must be read
  105262. * @param height defines the height of the rectangle where pixels must be read
  105263. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105264. * @returns a Uint8Array containing RGBA colors
  105265. */
  105266. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105267. private static _isSupported;
  105268. /**
  105269. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105270. * @returns true if the engine can be created
  105271. * @ignorenaming
  105272. */
  105273. static isSupported(): boolean;
  105274. /**
  105275. * Find the next highest power of two.
  105276. * @param x Number to start search from.
  105277. * @return Next highest power of two.
  105278. */
  105279. static CeilingPOT(x: number): number;
  105280. /**
  105281. * Find the next lowest power of two.
  105282. * @param x Number to start search from.
  105283. * @return Next lowest power of two.
  105284. */
  105285. static FloorPOT(x: number): number;
  105286. /**
  105287. * Find the nearest power of two.
  105288. * @param x Number to start search from.
  105289. * @return Next nearest power of two.
  105290. */
  105291. static NearestPOT(x: number): number;
  105292. /**
  105293. * Get the closest exponent of two
  105294. * @param value defines the value to approximate
  105295. * @param max defines the maximum value to return
  105296. * @param mode defines how to define the closest value
  105297. * @returns closest exponent of two of the given value
  105298. */
  105299. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105300. /**
  105301. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105302. * @param func - the function to be called
  105303. * @param requester - the object that will request the next frame. Falls back to window.
  105304. * @returns frame number
  105305. */
  105306. static QueueNewFrame(func: () => void, requester?: any): number;
  105307. /**
  105308. * Gets host document
  105309. * @returns the host document object
  105310. */
  105311. getHostDocument(): Nullable<Document>;
  105312. }
  105313. }
  105314. declare module BABYLON {
  105315. /**
  105316. * Class representing spherical harmonics coefficients to the 3rd degree
  105317. */
  105318. export class SphericalHarmonics {
  105319. /**
  105320. * Defines whether or not the harmonics have been prescaled for rendering.
  105321. */
  105322. preScaled: boolean;
  105323. /**
  105324. * The l0,0 coefficients of the spherical harmonics
  105325. */
  105326. l00: Vector3;
  105327. /**
  105328. * The l1,-1 coefficients of the spherical harmonics
  105329. */
  105330. l1_1: Vector3;
  105331. /**
  105332. * The l1,0 coefficients of the spherical harmonics
  105333. */
  105334. l10: Vector3;
  105335. /**
  105336. * The l1,1 coefficients of the spherical harmonics
  105337. */
  105338. l11: Vector3;
  105339. /**
  105340. * The l2,-2 coefficients of the spherical harmonics
  105341. */
  105342. l2_2: Vector3;
  105343. /**
  105344. * The l2,-1 coefficients of the spherical harmonics
  105345. */
  105346. l2_1: Vector3;
  105347. /**
  105348. * The l2,0 coefficients of the spherical harmonics
  105349. */
  105350. l20: Vector3;
  105351. /**
  105352. * The l2,1 coefficients of the spherical harmonics
  105353. */
  105354. l21: Vector3;
  105355. /**
  105356. * The l2,2 coefficients of the spherical harmonics
  105357. */
  105358. l22: Vector3;
  105359. /**
  105360. * Adds a light to the spherical harmonics
  105361. * @param direction the direction of the light
  105362. * @param color the color of the light
  105363. * @param deltaSolidAngle the delta solid angle of the light
  105364. */
  105365. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105366. /**
  105367. * Scales the spherical harmonics by the given amount
  105368. * @param scale the amount to scale
  105369. */
  105370. scaleInPlace(scale: number): void;
  105371. /**
  105372. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105373. *
  105374. * ```
  105375. * E_lm = A_l * L_lm
  105376. * ```
  105377. *
  105378. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105379. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105380. * the scaling factors are given in equation 9.
  105381. */
  105382. convertIncidentRadianceToIrradiance(): void;
  105383. /**
  105384. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105385. *
  105386. * ```
  105387. * L = (1/pi) * E * rho
  105388. * ```
  105389. *
  105390. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105391. */
  105392. convertIrradianceToLambertianRadiance(): void;
  105393. /**
  105394. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105395. * required operations at run time.
  105396. *
  105397. * This is simply done by scaling back the SH with Ylm constants parameter.
  105398. * The trigonometric part being applied by the shader at run time.
  105399. */
  105400. preScaleForRendering(): void;
  105401. /**
  105402. * Constructs a spherical harmonics from an array.
  105403. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105404. * @returns the spherical harmonics
  105405. */
  105406. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105407. /**
  105408. * Gets the spherical harmonics from polynomial
  105409. * @param polynomial the spherical polynomial
  105410. * @returns the spherical harmonics
  105411. */
  105412. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105413. }
  105414. /**
  105415. * Class representing spherical polynomial coefficients to the 3rd degree
  105416. */
  105417. export class SphericalPolynomial {
  105418. private _harmonics;
  105419. /**
  105420. * The spherical harmonics used to create the polynomials.
  105421. */
  105422. get preScaledHarmonics(): SphericalHarmonics;
  105423. /**
  105424. * The x coefficients of the spherical polynomial
  105425. */
  105426. x: Vector3;
  105427. /**
  105428. * The y coefficients of the spherical polynomial
  105429. */
  105430. y: Vector3;
  105431. /**
  105432. * The z coefficients of the spherical polynomial
  105433. */
  105434. z: Vector3;
  105435. /**
  105436. * The xx coefficients of the spherical polynomial
  105437. */
  105438. xx: Vector3;
  105439. /**
  105440. * The yy coefficients of the spherical polynomial
  105441. */
  105442. yy: Vector3;
  105443. /**
  105444. * The zz coefficients of the spherical polynomial
  105445. */
  105446. zz: Vector3;
  105447. /**
  105448. * The xy coefficients of the spherical polynomial
  105449. */
  105450. xy: Vector3;
  105451. /**
  105452. * The yz coefficients of the spherical polynomial
  105453. */
  105454. yz: Vector3;
  105455. /**
  105456. * The zx coefficients of the spherical polynomial
  105457. */
  105458. zx: Vector3;
  105459. /**
  105460. * Adds an ambient color to the spherical polynomial
  105461. * @param color the color to add
  105462. */
  105463. addAmbient(color: Color3): void;
  105464. /**
  105465. * Scales the spherical polynomial by the given amount
  105466. * @param scale the amount to scale
  105467. */
  105468. scaleInPlace(scale: number): void;
  105469. /**
  105470. * Gets the spherical polynomial from harmonics
  105471. * @param harmonics the spherical harmonics
  105472. * @returns the spherical polynomial
  105473. */
  105474. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105475. /**
  105476. * Constructs a spherical polynomial from an array.
  105477. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105478. * @returns the spherical polynomial
  105479. */
  105480. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105481. }
  105482. }
  105483. declare module BABYLON {
  105484. /**
  105485. * Defines the source of the internal texture
  105486. */
  105487. export enum InternalTextureSource {
  105488. /**
  105489. * The source of the texture data is unknown
  105490. */
  105491. Unknown = 0,
  105492. /**
  105493. * Texture data comes from an URL
  105494. */
  105495. Url = 1,
  105496. /**
  105497. * Texture data is only used for temporary storage
  105498. */
  105499. Temp = 2,
  105500. /**
  105501. * Texture data comes from raw data (ArrayBuffer)
  105502. */
  105503. Raw = 3,
  105504. /**
  105505. * Texture content is dynamic (video or dynamic texture)
  105506. */
  105507. Dynamic = 4,
  105508. /**
  105509. * Texture content is generated by rendering to it
  105510. */
  105511. RenderTarget = 5,
  105512. /**
  105513. * Texture content is part of a multi render target process
  105514. */
  105515. MultiRenderTarget = 6,
  105516. /**
  105517. * Texture data comes from a cube data file
  105518. */
  105519. Cube = 7,
  105520. /**
  105521. * Texture data comes from a raw cube data
  105522. */
  105523. CubeRaw = 8,
  105524. /**
  105525. * Texture data come from a prefiltered cube data file
  105526. */
  105527. CubePrefiltered = 9,
  105528. /**
  105529. * Texture content is raw 3D data
  105530. */
  105531. Raw3D = 10,
  105532. /**
  105533. * Texture content is raw 2D array data
  105534. */
  105535. Raw2DArray = 11,
  105536. /**
  105537. * Texture content is a depth texture
  105538. */
  105539. Depth = 12,
  105540. /**
  105541. * Texture data comes from a raw cube data encoded with RGBD
  105542. */
  105543. CubeRawRGBD = 13
  105544. }
  105545. /**
  105546. * Class used to store data associated with WebGL texture data for the engine
  105547. * This class should not be used directly
  105548. */
  105549. export class InternalTexture {
  105550. /** @hidden */
  105551. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105552. /**
  105553. * Defines if the texture is ready
  105554. */
  105555. isReady: boolean;
  105556. /**
  105557. * Defines if the texture is a cube texture
  105558. */
  105559. isCube: boolean;
  105560. /**
  105561. * Defines if the texture contains 3D data
  105562. */
  105563. is3D: boolean;
  105564. /**
  105565. * Defines if the texture contains 2D array data
  105566. */
  105567. is2DArray: boolean;
  105568. /**
  105569. * Defines if the texture contains multiview data
  105570. */
  105571. isMultiview: boolean;
  105572. /**
  105573. * Gets the URL used to load this texture
  105574. */
  105575. url: string;
  105576. /**
  105577. * Gets the sampling mode of the texture
  105578. */
  105579. samplingMode: number;
  105580. /**
  105581. * Gets a boolean indicating if the texture needs mipmaps generation
  105582. */
  105583. generateMipMaps: boolean;
  105584. /**
  105585. * Gets the number of samples used by the texture (WebGL2+ only)
  105586. */
  105587. samples: number;
  105588. /**
  105589. * Gets the type of the texture (int, float...)
  105590. */
  105591. type: number;
  105592. /**
  105593. * Gets the format of the texture (RGB, RGBA...)
  105594. */
  105595. format: number;
  105596. /**
  105597. * Observable called when the texture is loaded
  105598. */
  105599. onLoadedObservable: Observable<InternalTexture>;
  105600. /**
  105601. * Gets the width of the texture
  105602. */
  105603. width: number;
  105604. /**
  105605. * Gets the height of the texture
  105606. */
  105607. height: number;
  105608. /**
  105609. * Gets the depth of the texture
  105610. */
  105611. depth: number;
  105612. /**
  105613. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105614. */
  105615. baseWidth: number;
  105616. /**
  105617. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105618. */
  105619. baseHeight: number;
  105620. /**
  105621. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105622. */
  105623. baseDepth: number;
  105624. /**
  105625. * Gets a boolean indicating if the texture is inverted on Y axis
  105626. */
  105627. invertY: boolean;
  105628. /** @hidden */
  105629. _invertVScale: boolean;
  105630. /** @hidden */
  105631. _associatedChannel: number;
  105632. /** @hidden */
  105633. _source: InternalTextureSource;
  105634. /** @hidden */
  105635. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105636. /** @hidden */
  105637. _bufferView: Nullable<ArrayBufferView>;
  105638. /** @hidden */
  105639. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105640. /** @hidden */
  105641. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105642. /** @hidden */
  105643. _size: number;
  105644. /** @hidden */
  105645. _extension: string;
  105646. /** @hidden */
  105647. _files: Nullable<string[]>;
  105648. /** @hidden */
  105649. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105650. /** @hidden */
  105651. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105652. /** @hidden */
  105653. _framebuffer: Nullable<WebGLFramebuffer>;
  105654. /** @hidden */
  105655. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105656. /** @hidden */
  105657. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105658. /** @hidden */
  105659. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105660. /** @hidden */
  105661. _attachments: Nullable<number[]>;
  105662. /** @hidden */
  105663. _cachedCoordinatesMode: Nullable<number>;
  105664. /** @hidden */
  105665. _cachedWrapU: Nullable<number>;
  105666. /** @hidden */
  105667. _cachedWrapV: Nullable<number>;
  105668. /** @hidden */
  105669. _cachedWrapR: Nullable<number>;
  105670. /** @hidden */
  105671. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105672. /** @hidden */
  105673. _isDisabled: boolean;
  105674. /** @hidden */
  105675. _compression: Nullable<string>;
  105676. /** @hidden */
  105677. _generateStencilBuffer: boolean;
  105678. /** @hidden */
  105679. _generateDepthBuffer: boolean;
  105680. /** @hidden */
  105681. _comparisonFunction: number;
  105682. /** @hidden */
  105683. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105684. /** @hidden */
  105685. _lodGenerationScale: number;
  105686. /** @hidden */
  105687. _lodGenerationOffset: number;
  105688. /** @hidden */
  105689. _depthStencilTexture: Nullable<InternalTexture>;
  105690. /** @hidden */
  105691. _colorTextureArray: Nullable<WebGLTexture>;
  105692. /** @hidden */
  105693. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105694. /** @hidden */
  105695. _lodTextureHigh: Nullable<BaseTexture>;
  105696. /** @hidden */
  105697. _lodTextureMid: Nullable<BaseTexture>;
  105698. /** @hidden */
  105699. _lodTextureLow: Nullable<BaseTexture>;
  105700. /** @hidden */
  105701. _isRGBD: boolean;
  105702. /** @hidden */
  105703. _linearSpecularLOD: boolean;
  105704. /** @hidden */
  105705. _irradianceTexture: Nullable<BaseTexture>;
  105706. /** @hidden */
  105707. _webGLTexture: Nullable<WebGLTexture>;
  105708. /** @hidden */
  105709. _references: number;
  105710. private _engine;
  105711. /**
  105712. * Gets the Engine the texture belongs to.
  105713. * @returns The babylon engine
  105714. */
  105715. getEngine(): ThinEngine;
  105716. /**
  105717. * Gets the data source type of the texture
  105718. */
  105719. get source(): InternalTextureSource;
  105720. /**
  105721. * Creates a new InternalTexture
  105722. * @param engine defines the engine to use
  105723. * @param source defines the type of data that will be used
  105724. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105725. */
  105726. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105727. /**
  105728. * Increments the number of references (ie. the number of Texture that point to it)
  105729. */
  105730. incrementReferences(): void;
  105731. /**
  105732. * Change the size of the texture (not the size of the content)
  105733. * @param width defines the new width
  105734. * @param height defines the new height
  105735. * @param depth defines the new depth (1 by default)
  105736. */
  105737. updateSize(width: int, height: int, depth?: int): void;
  105738. /** @hidden */
  105739. _rebuild(): void;
  105740. /** @hidden */
  105741. _swapAndDie(target: InternalTexture): void;
  105742. /**
  105743. * Dispose the current allocated resources
  105744. */
  105745. dispose(): void;
  105746. }
  105747. }
  105748. declare module BABYLON {
  105749. /**
  105750. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105752. */
  105753. export class Analyser {
  105754. /**
  105755. * Gets or sets the smoothing
  105756. * @ignorenaming
  105757. */
  105758. SMOOTHING: number;
  105759. /**
  105760. * Gets or sets the FFT table size
  105761. * @ignorenaming
  105762. */
  105763. FFT_SIZE: number;
  105764. /**
  105765. * Gets or sets the bar graph amplitude
  105766. * @ignorenaming
  105767. */
  105768. BARGRAPHAMPLITUDE: number;
  105769. /**
  105770. * Gets or sets the position of the debug canvas
  105771. * @ignorenaming
  105772. */
  105773. DEBUGCANVASPOS: {
  105774. x: number;
  105775. y: number;
  105776. };
  105777. /**
  105778. * Gets or sets the debug canvas size
  105779. * @ignorenaming
  105780. */
  105781. DEBUGCANVASSIZE: {
  105782. width: number;
  105783. height: number;
  105784. };
  105785. private _byteFreqs;
  105786. private _byteTime;
  105787. private _floatFreqs;
  105788. private _webAudioAnalyser;
  105789. private _debugCanvas;
  105790. private _debugCanvasContext;
  105791. private _scene;
  105792. private _registerFunc;
  105793. private _audioEngine;
  105794. /**
  105795. * Creates a new analyser
  105796. * @param scene defines hosting scene
  105797. */
  105798. constructor(scene: Scene);
  105799. /**
  105800. * Get the number of data values you will have to play with for the visualization
  105801. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105802. * @returns a number
  105803. */
  105804. getFrequencyBinCount(): number;
  105805. /**
  105806. * Gets the current frequency data as a byte array
  105807. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105808. * @returns a Uint8Array
  105809. */
  105810. getByteFrequencyData(): Uint8Array;
  105811. /**
  105812. * Gets the current waveform as a byte array
  105813. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105814. * @returns a Uint8Array
  105815. */
  105816. getByteTimeDomainData(): Uint8Array;
  105817. /**
  105818. * Gets the current frequency data as a float array
  105819. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105820. * @returns a Float32Array
  105821. */
  105822. getFloatFrequencyData(): Float32Array;
  105823. /**
  105824. * Renders the debug canvas
  105825. */
  105826. drawDebugCanvas(): void;
  105827. /**
  105828. * Stops rendering the debug canvas and removes it
  105829. */
  105830. stopDebugCanvas(): void;
  105831. /**
  105832. * Connects two audio nodes
  105833. * @param inputAudioNode defines first node to connect
  105834. * @param outputAudioNode defines second node to connect
  105835. */
  105836. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105837. /**
  105838. * Releases all associated resources
  105839. */
  105840. dispose(): void;
  105841. }
  105842. }
  105843. declare module BABYLON {
  105844. /**
  105845. * This represents an audio engine and it is responsible
  105846. * to play, synchronize and analyse sounds throughout the application.
  105847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105848. */
  105849. export interface IAudioEngine extends IDisposable {
  105850. /**
  105851. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105852. */
  105853. readonly canUseWebAudio: boolean;
  105854. /**
  105855. * Gets the current AudioContext if available.
  105856. */
  105857. readonly audioContext: Nullable<AudioContext>;
  105858. /**
  105859. * The master gain node defines the global audio volume of your audio engine.
  105860. */
  105861. readonly masterGain: GainNode;
  105862. /**
  105863. * Gets whether or not mp3 are supported by your browser.
  105864. */
  105865. readonly isMP3supported: boolean;
  105866. /**
  105867. * Gets whether or not ogg are supported by your browser.
  105868. */
  105869. readonly isOGGsupported: boolean;
  105870. /**
  105871. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105872. * @ignoreNaming
  105873. */
  105874. WarnedWebAudioUnsupported: boolean;
  105875. /**
  105876. * Defines if the audio engine relies on a custom unlocked button.
  105877. * In this case, the embedded button will not be displayed.
  105878. */
  105879. useCustomUnlockedButton: boolean;
  105880. /**
  105881. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105882. */
  105883. readonly unlocked: boolean;
  105884. /**
  105885. * Event raised when audio has been unlocked on the browser.
  105886. */
  105887. onAudioUnlockedObservable: Observable<AudioEngine>;
  105888. /**
  105889. * Event raised when audio has been locked on the browser.
  105890. */
  105891. onAudioLockedObservable: Observable<AudioEngine>;
  105892. /**
  105893. * Flags the audio engine in Locked state.
  105894. * This happens due to new browser policies preventing audio to autoplay.
  105895. */
  105896. lock(): void;
  105897. /**
  105898. * Unlocks the audio engine once a user action has been done on the dom.
  105899. * This is helpful to resume play once browser policies have been satisfied.
  105900. */
  105901. unlock(): void;
  105902. }
  105903. /**
  105904. * This represents the default audio engine used in babylon.
  105905. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105907. */
  105908. export class AudioEngine implements IAudioEngine {
  105909. private _audioContext;
  105910. private _audioContextInitialized;
  105911. private _muteButton;
  105912. private _hostElement;
  105913. /**
  105914. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105915. */
  105916. canUseWebAudio: boolean;
  105917. /**
  105918. * The master gain node defines the global audio volume of your audio engine.
  105919. */
  105920. masterGain: GainNode;
  105921. /**
  105922. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105923. * @ignoreNaming
  105924. */
  105925. WarnedWebAudioUnsupported: boolean;
  105926. /**
  105927. * Gets whether or not mp3 are supported by your browser.
  105928. */
  105929. isMP3supported: boolean;
  105930. /**
  105931. * Gets whether or not ogg are supported by your browser.
  105932. */
  105933. isOGGsupported: boolean;
  105934. /**
  105935. * Gets whether audio has been unlocked on the device.
  105936. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105937. * a user interaction has happened.
  105938. */
  105939. unlocked: boolean;
  105940. /**
  105941. * Defines if the audio engine relies on a custom unlocked button.
  105942. * In this case, the embedded button will not be displayed.
  105943. */
  105944. useCustomUnlockedButton: boolean;
  105945. /**
  105946. * Event raised when audio has been unlocked on the browser.
  105947. */
  105948. onAudioUnlockedObservable: Observable<AudioEngine>;
  105949. /**
  105950. * Event raised when audio has been locked on the browser.
  105951. */
  105952. onAudioLockedObservable: Observable<AudioEngine>;
  105953. /**
  105954. * Gets the current AudioContext if available.
  105955. */
  105956. get audioContext(): Nullable<AudioContext>;
  105957. private _connectedAnalyser;
  105958. /**
  105959. * Instantiates a new audio engine.
  105960. *
  105961. * There should be only one per page as some browsers restrict the number
  105962. * of audio contexts you can create.
  105963. * @param hostElement defines the host element where to display the mute icon if necessary
  105964. */
  105965. constructor(hostElement?: Nullable<HTMLElement>);
  105966. /**
  105967. * Flags the audio engine in Locked state.
  105968. * This happens due to new browser policies preventing audio to autoplay.
  105969. */
  105970. lock(): void;
  105971. /**
  105972. * Unlocks the audio engine once a user action has been done on the dom.
  105973. * This is helpful to resume play once browser policies have been satisfied.
  105974. */
  105975. unlock(): void;
  105976. private _resumeAudioContext;
  105977. private _initializeAudioContext;
  105978. private _tryToRun;
  105979. private _triggerRunningState;
  105980. private _triggerSuspendedState;
  105981. private _displayMuteButton;
  105982. private _moveButtonToTopLeft;
  105983. private _onResize;
  105984. private _hideMuteButton;
  105985. /**
  105986. * Destroy and release the resources associated with the audio ccontext.
  105987. */
  105988. dispose(): void;
  105989. /**
  105990. * Gets the global volume sets on the master gain.
  105991. * @returns the global volume if set or -1 otherwise
  105992. */
  105993. getGlobalVolume(): number;
  105994. /**
  105995. * Sets the global volume of your experience (sets on the master gain).
  105996. * @param newVolume Defines the new global volume of the application
  105997. */
  105998. setGlobalVolume(newVolume: number): void;
  105999. /**
  106000. * Connect the audio engine to an audio analyser allowing some amazing
  106001. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106003. * @param analyser The analyser to connect to the engine
  106004. */
  106005. connectToAnalyser(analyser: Analyser): void;
  106006. }
  106007. }
  106008. declare module BABYLON {
  106009. /**
  106010. * Interface used to present a loading screen while loading a scene
  106011. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106012. */
  106013. export interface ILoadingScreen {
  106014. /**
  106015. * Function called to display the loading screen
  106016. */
  106017. displayLoadingUI: () => void;
  106018. /**
  106019. * Function called to hide the loading screen
  106020. */
  106021. hideLoadingUI: () => void;
  106022. /**
  106023. * Gets or sets the color to use for the background
  106024. */
  106025. loadingUIBackgroundColor: string;
  106026. /**
  106027. * Gets or sets the text to display while loading
  106028. */
  106029. loadingUIText: string;
  106030. }
  106031. /**
  106032. * Class used for the default loading screen
  106033. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106034. */
  106035. export class DefaultLoadingScreen implements ILoadingScreen {
  106036. private _renderingCanvas;
  106037. private _loadingText;
  106038. private _loadingDivBackgroundColor;
  106039. private _loadingDiv;
  106040. private _loadingTextDiv;
  106041. /** Gets or sets the logo url to use for the default loading screen */
  106042. static DefaultLogoUrl: string;
  106043. /** Gets or sets the spinner url to use for the default loading screen */
  106044. static DefaultSpinnerUrl: string;
  106045. /**
  106046. * Creates a new default loading screen
  106047. * @param _renderingCanvas defines the canvas used to render the scene
  106048. * @param _loadingText defines the default text to display
  106049. * @param _loadingDivBackgroundColor defines the default background color
  106050. */
  106051. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106052. /**
  106053. * Function called to display the loading screen
  106054. */
  106055. displayLoadingUI(): void;
  106056. /**
  106057. * Function called to hide the loading screen
  106058. */
  106059. hideLoadingUI(): void;
  106060. /**
  106061. * Gets or sets the text to display while loading
  106062. */
  106063. set loadingUIText(text: string);
  106064. get loadingUIText(): string;
  106065. /**
  106066. * Gets or sets the color to use for the background
  106067. */
  106068. get loadingUIBackgroundColor(): string;
  106069. set loadingUIBackgroundColor(color: string);
  106070. private _resizeLoadingUI;
  106071. }
  106072. }
  106073. declare module BABYLON {
  106074. /**
  106075. * Interface for any object that can request an animation frame
  106076. */
  106077. export interface ICustomAnimationFrameRequester {
  106078. /**
  106079. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106080. */
  106081. renderFunction?: Function;
  106082. /**
  106083. * Called to request the next frame to render to
  106084. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106085. */
  106086. requestAnimationFrame: Function;
  106087. /**
  106088. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106089. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106090. */
  106091. requestID?: number;
  106092. }
  106093. }
  106094. declare module BABYLON {
  106095. /**
  106096. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106097. */
  106098. export class PerformanceMonitor {
  106099. private _enabled;
  106100. private _rollingFrameTime;
  106101. private _lastFrameTimeMs;
  106102. /**
  106103. * constructor
  106104. * @param frameSampleSize The number of samples required to saturate the sliding window
  106105. */
  106106. constructor(frameSampleSize?: number);
  106107. /**
  106108. * Samples current frame
  106109. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106110. */
  106111. sampleFrame(timeMs?: number): void;
  106112. /**
  106113. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106114. */
  106115. get averageFrameTime(): number;
  106116. /**
  106117. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106118. */
  106119. get averageFrameTimeVariance(): number;
  106120. /**
  106121. * Returns the frame time of the most recent frame
  106122. */
  106123. get instantaneousFrameTime(): number;
  106124. /**
  106125. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106126. */
  106127. get averageFPS(): number;
  106128. /**
  106129. * Returns the average framerate in frames per second using the most recent frame time
  106130. */
  106131. get instantaneousFPS(): number;
  106132. /**
  106133. * Returns true if enough samples have been taken to completely fill the sliding window
  106134. */
  106135. get isSaturated(): boolean;
  106136. /**
  106137. * Enables contributions to the sliding window sample set
  106138. */
  106139. enable(): void;
  106140. /**
  106141. * Disables contributions to the sliding window sample set
  106142. * Samples will not be interpolated over the disabled period
  106143. */
  106144. disable(): void;
  106145. /**
  106146. * Returns true if sampling is enabled
  106147. */
  106148. get isEnabled(): boolean;
  106149. /**
  106150. * Resets performance monitor
  106151. */
  106152. reset(): void;
  106153. }
  106154. /**
  106155. * RollingAverage
  106156. *
  106157. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106158. */
  106159. export class RollingAverage {
  106160. /**
  106161. * Current average
  106162. */
  106163. average: number;
  106164. /**
  106165. * Current variance
  106166. */
  106167. variance: number;
  106168. protected _samples: Array<number>;
  106169. protected _sampleCount: number;
  106170. protected _pos: number;
  106171. protected _m2: number;
  106172. /**
  106173. * constructor
  106174. * @param length The number of samples required to saturate the sliding window
  106175. */
  106176. constructor(length: number);
  106177. /**
  106178. * Adds a sample to the sample set
  106179. * @param v The sample value
  106180. */
  106181. add(v: number): void;
  106182. /**
  106183. * Returns previously added values or null if outside of history or outside the sliding window domain
  106184. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106185. * @return Value previously recorded with add() or null if outside of range
  106186. */
  106187. history(i: number): number;
  106188. /**
  106189. * Returns true if enough samples have been taken to completely fill the sliding window
  106190. * @return true if sample-set saturated
  106191. */
  106192. isSaturated(): boolean;
  106193. /**
  106194. * Resets the rolling average (equivalent to 0 samples taken so far)
  106195. */
  106196. reset(): void;
  106197. /**
  106198. * Wraps a value around the sample range boundaries
  106199. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106200. * @return Wrapped position in sample range
  106201. */
  106202. protected _wrapPosition(i: number): number;
  106203. }
  106204. }
  106205. declare module BABYLON {
  106206. /**
  106207. * This class is used to track a performance counter which is number based.
  106208. * The user has access to many properties which give statistics of different nature.
  106209. *
  106210. * The implementer can track two kinds of Performance Counter: time and count.
  106211. * 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.
  106212. * 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.
  106213. */
  106214. export class PerfCounter {
  106215. /**
  106216. * Gets or sets a global boolean to turn on and off all the counters
  106217. */
  106218. static Enabled: boolean;
  106219. /**
  106220. * Returns the smallest value ever
  106221. */
  106222. get min(): number;
  106223. /**
  106224. * Returns the biggest value ever
  106225. */
  106226. get max(): number;
  106227. /**
  106228. * Returns the average value since the performance counter is running
  106229. */
  106230. get average(): number;
  106231. /**
  106232. * Returns the average value of the last second the counter was monitored
  106233. */
  106234. get lastSecAverage(): number;
  106235. /**
  106236. * Returns the current value
  106237. */
  106238. get current(): number;
  106239. /**
  106240. * Gets the accumulated total
  106241. */
  106242. get total(): number;
  106243. /**
  106244. * Gets the total value count
  106245. */
  106246. get count(): number;
  106247. /**
  106248. * Creates a new counter
  106249. */
  106250. constructor();
  106251. /**
  106252. * Call this method to start monitoring a new frame.
  106253. * 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.
  106254. */
  106255. fetchNewFrame(): void;
  106256. /**
  106257. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106258. * @param newCount the count value to add to the monitored count
  106259. * @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.
  106260. */
  106261. addCount(newCount: number, fetchResult: boolean): void;
  106262. /**
  106263. * Start monitoring this performance counter
  106264. */
  106265. beginMonitoring(): void;
  106266. /**
  106267. * Compute the time lapsed since the previous beginMonitoring() call.
  106268. * @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
  106269. */
  106270. endMonitoring(newFrame?: boolean): void;
  106271. private _fetchResult;
  106272. private _startMonitoringTime;
  106273. private _min;
  106274. private _max;
  106275. private _average;
  106276. private _current;
  106277. private _totalValueCount;
  106278. private _totalAccumulated;
  106279. private _lastSecAverage;
  106280. private _lastSecAccumulated;
  106281. private _lastSecTime;
  106282. private _lastSecValueCount;
  106283. }
  106284. }
  106285. declare module BABYLON {
  106286. interface ThinEngine {
  106287. /**
  106288. * Sets alpha constants used by some alpha blending modes
  106289. * @param r defines the red component
  106290. * @param g defines the green component
  106291. * @param b defines the blue component
  106292. * @param a defines the alpha component
  106293. */
  106294. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106295. /**
  106296. * Sets the current alpha mode
  106297. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106298. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106299. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106300. */
  106301. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106302. /**
  106303. * Gets the current alpha mode
  106304. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106305. * @returns the current alpha mode
  106306. */
  106307. getAlphaMode(): number;
  106308. /**
  106309. * Sets the current alpha equation
  106310. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106311. */
  106312. setAlphaEquation(equation: number): void;
  106313. /**
  106314. * Gets the current alpha equation.
  106315. * @returns the current alpha equation
  106316. */
  106317. getAlphaEquation(): number;
  106318. }
  106319. }
  106320. declare module BABYLON {
  106321. /**
  106322. * Defines the interface used by display changed events
  106323. */
  106324. export interface IDisplayChangedEventArgs {
  106325. /** Gets the vrDisplay object (if any) */
  106326. vrDisplay: Nullable<any>;
  106327. /** Gets a boolean indicating if webVR is supported */
  106328. vrSupported: boolean;
  106329. }
  106330. /**
  106331. * Defines the interface used by objects containing a viewport (like a camera)
  106332. */
  106333. interface IViewportOwnerLike {
  106334. /**
  106335. * Gets or sets the viewport
  106336. */
  106337. viewport: IViewportLike;
  106338. }
  106339. /**
  106340. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106341. */
  106342. export class Engine extends ThinEngine {
  106343. /** Defines that alpha blending is disabled */
  106344. static readonly ALPHA_DISABLE: number;
  106345. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106346. static readonly ALPHA_ADD: number;
  106347. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106348. static readonly ALPHA_COMBINE: number;
  106349. /** Defines that alpha blending to DEST - SRC * DEST */
  106350. static readonly ALPHA_SUBTRACT: number;
  106351. /** Defines that alpha blending to SRC * DEST */
  106352. static readonly ALPHA_MULTIPLY: number;
  106353. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106354. static readonly ALPHA_MAXIMIZED: number;
  106355. /** Defines that alpha blending to SRC + DEST */
  106356. static readonly ALPHA_ONEONE: number;
  106357. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106358. static readonly ALPHA_PREMULTIPLIED: number;
  106359. /**
  106360. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106361. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106362. */
  106363. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106364. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106365. static readonly ALPHA_INTERPOLATE: number;
  106366. /**
  106367. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106368. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106369. */
  106370. static readonly ALPHA_SCREENMODE: number;
  106371. /** Defines that the ressource is not delayed*/
  106372. static readonly DELAYLOADSTATE_NONE: number;
  106373. /** Defines that the ressource was successfully delay loaded */
  106374. static readonly DELAYLOADSTATE_LOADED: number;
  106375. /** Defines that the ressource is currently delay loading */
  106376. static readonly DELAYLOADSTATE_LOADING: number;
  106377. /** Defines that the ressource is delayed and has not started loading */
  106378. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106379. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106380. static readonly NEVER: number;
  106381. /** 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 */
  106382. static readonly ALWAYS: number;
  106383. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106384. static readonly LESS: number;
  106385. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106386. static readonly EQUAL: number;
  106387. /** 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 */
  106388. static readonly LEQUAL: number;
  106389. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106390. static readonly GREATER: number;
  106391. /** 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 */
  106392. static readonly GEQUAL: number;
  106393. /** 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 */
  106394. static readonly NOTEQUAL: number;
  106395. /** Passed to stencilOperation to specify that stencil value must be kept */
  106396. static readonly KEEP: number;
  106397. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106398. static readonly REPLACE: number;
  106399. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106400. static readonly INCR: number;
  106401. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106402. static readonly DECR: number;
  106403. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106404. static readonly INVERT: number;
  106405. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106406. static readonly INCR_WRAP: number;
  106407. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106408. static readonly DECR_WRAP: number;
  106409. /** Texture is not repeating outside of 0..1 UVs */
  106410. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106411. /** Texture is repeating outside of 0..1 UVs */
  106412. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106413. /** Texture is repeating and mirrored */
  106414. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106415. /** ALPHA */
  106416. static readonly TEXTUREFORMAT_ALPHA: number;
  106417. /** LUMINANCE */
  106418. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106419. /** LUMINANCE_ALPHA */
  106420. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106421. /** RGB */
  106422. static readonly TEXTUREFORMAT_RGB: number;
  106423. /** RGBA */
  106424. static readonly TEXTUREFORMAT_RGBA: number;
  106425. /** RED */
  106426. static readonly TEXTUREFORMAT_RED: number;
  106427. /** RED (2nd reference) */
  106428. static readonly TEXTUREFORMAT_R: number;
  106429. /** RG */
  106430. static readonly TEXTUREFORMAT_RG: number;
  106431. /** RED_INTEGER */
  106432. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106433. /** RED_INTEGER (2nd reference) */
  106434. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106435. /** RG_INTEGER */
  106436. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106437. /** RGB_INTEGER */
  106438. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106439. /** RGBA_INTEGER */
  106440. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106441. /** UNSIGNED_BYTE */
  106442. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106443. /** UNSIGNED_BYTE (2nd reference) */
  106444. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106445. /** FLOAT */
  106446. static readonly TEXTURETYPE_FLOAT: number;
  106447. /** HALF_FLOAT */
  106448. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106449. /** BYTE */
  106450. static readonly TEXTURETYPE_BYTE: number;
  106451. /** SHORT */
  106452. static readonly TEXTURETYPE_SHORT: number;
  106453. /** UNSIGNED_SHORT */
  106454. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106455. /** INT */
  106456. static readonly TEXTURETYPE_INT: number;
  106457. /** UNSIGNED_INT */
  106458. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106459. /** UNSIGNED_SHORT_4_4_4_4 */
  106460. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106461. /** UNSIGNED_SHORT_5_5_5_1 */
  106462. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106463. /** UNSIGNED_SHORT_5_6_5 */
  106464. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106465. /** UNSIGNED_INT_2_10_10_10_REV */
  106466. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106467. /** UNSIGNED_INT_24_8 */
  106468. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106469. /** UNSIGNED_INT_10F_11F_11F_REV */
  106470. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106471. /** UNSIGNED_INT_5_9_9_9_REV */
  106472. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106473. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106474. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106475. /** nearest is mag = nearest and min = nearest and mip = linear */
  106476. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106477. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106478. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106479. /** Trilinear is mag = linear and min = linear and mip = linear */
  106480. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106481. /** nearest is mag = nearest and min = nearest and mip = linear */
  106482. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106483. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106484. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106485. /** Trilinear is mag = linear and min = linear and mip = linear */
  106486. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106487. /** mag = nearest and min = nearest and mip = nearest */
  106488. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106489. /** mag = nearest and min = linear and mip = nearest */
  106490. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106491. /** mag = nearest and min = linear and mip = linear */
  106492. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106493. /** mag = nearest and min = linear and mip = none */
  106494. static readonly TEXTURE_NEAREST_LINEAR: number;
  106495. /** mag = nearest and min = nearest and mip = none */
  106496. static readonly TEXTURE_NEAREST_NEAREST: number;
  106497. /** mag = linear and min = nearest and mip = nearest */
  106498. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106499. /** mag = linear and min = nearest and mip = linear */
  106500. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106501. /** mag = linear and min = linear and mip = none */
  106502. static readonly TEXTURE_LINEAR_LINEAR: number;
  106503. /** mag = linear and min = nearest and mip = none */
  106504. static readonly TEXTURE_LINEAR_NEAREST: number;
  106505. /** Explicit coordinates mode */
  106506. static readonly TEXTURE_EXPLICIT_MODE: number;
  106507. /** Spherical coordinates mode */
  106508. static readonly TEXTURE_SPHERICAL_MODE: number;
  106509. /** Planar coordinates mode */
  106510. static readonly TEXTURE_PLANAR_MODE: number;
  106511. /** Cubic coordinates mode */
  106512. static readonly TEXTURE_CUBIC_MODE: number;
  106513. /** Projection coordinates mode */
  106514. static readonly TEXTURE_PROJECTION_MODE: number;
  106515. /** Skybox coordinates mode */
  106516. static readonly TEXTURE_SKYBOX_MODE: number;
  106517. /** Inverse Cubic coordinates mode */
  106518. static readonly TEXTURE_INVCUBIC_MODE: number;
  106519. /** Equirectangular coordinates mode */
  106520. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106521. /** Equirectangular Fixed coordinates mode */
  106522. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106523. /** Equirectangular Fixed Mirrored coordinates mode */
  106524. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106525. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106526. static readonly SCALEMODE_FLOOR: number;
  106527. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106528. static readonly SCALEMODE_NEAREST: number;
  106529. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106530. static readonly SCALEMODE_CEILING: number;
  106531. /**
  106532. * Returns the current npm package of the sdk
  106533. */
  106534. static get NpmPackage(): string;
  106535. /**
  106536. * Returns the current version of the framework
  106537. */
  106538. static get Version(): string;
  106539. /** Gets the list of created engines */
  106540. static get Instances(): Engine[];
  106541. /**
  106542. * Gets the latest created engine
  106543. */
  106544. static get LastCreatedEngine(): Nullable<Engine>;
  106545. /**
  106546. * Gets the latest created scene
  106547. */
  106548. static get LastCreatedScene(): Nullable<Scene>;
  106549. /**
  106550. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106551. * @param flag defines which part of the materials must be marked as dirty
  106552. * @param predicate defines a predicate used to filter which materials should be affected
  106553. */
  106554. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106555. /**
  106556. * Method called to create the default loading screen.
  106557. * This can be overriden in your own app.
  106558. * @param canvas The rendering canvas element
  106559. * @returns The loading screen
  106560. */
  106561. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106562. /**
  106563. * Method called to create the default rescale post process on each engine.
  106564. */
  106565. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106566. /**
  106567. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106568. **/
  106569. enableOfflineSupport: boolean;
  106570. /**
  106571. * 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)
  106572. **/
  106573. disableManifestCheck: boolean;
  106574. /**
  106575. * Gets the list of created scenes
  106576. */
  106577. scenes: Scene[];
  106578. /**
  106579. * Event raised when a new scene is created
  106580. */
  106581. onNewSceneAddedObservable: Observable<Scene>;
  106582. /**
  106583. * Gets the list of created postprocesses
  106584. */
  106585. postProcesses: PostProcess[];
  106586. /**
  106587. * Gets a boolean indicating if the pointer is currently locked
  106588. */
  106589. isPointerLock: boolean;
  106590. /**
  106591. * Observable event triggered each time the rendering canvas is resized
  106592. */
  106593. onResizeObservable: Observable<Engine>;
  106594. /**
  106595. * Observable event triggered each time the canvas loses focus
  106596. */
  106597. onCanvasBlurObservable: Observable<Engine>;
  106598. /**
  106599. * Observable event triggered each time the canvas gains focus
  106600. */
  106601. onCanvasFocusObservable: Observable<Engine>;
  106602. /**
  106603. * Observable event triggered each time the canvas receives pointerout event
  106604. */
  106605. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106606. /**
  106607. * Observable raised when the engine begins a new frame
  106608. */
  106609. onBeginFrameObservable: Observable<Engine>;
  106610. /**
  106611. * If set, will be used to request the next animation frame for the render loop
  106612. */
  106613. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106614. /**
  106615. * Observable raised when the engine ends the current frame
  106616. */
  106617. onEndFrameObservable: Observable<Engine>;
  106618. /**
  106619. * Observable raised when the engine is about to compile a shader
  106620. */
  106621. onBeforeShaderCompilationObservable: Observable<Engine>;
  106622. /**
  106623. * Observable raised when the engine has jsut compiled a shader
  106624. */
  106625. onAfterShaderCompilationObservable: Observable<Engine>;
  106626. /**
  106627. * Gets the audio engine
  106628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106629. * @ignorenaming
  106630. */
  106631. static audioEngine: IAudioEngine;
  106632. /**
  106633. * Default AudioEngine factory responsible of creating the Audio Engine.
  106634. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106635. */
  106636. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106637. /**
  106638. * Default offline support factory responsible of creating a tool used to store data locally.
  106639. * By default, this will create a Database object if the workload has been embedded.
  106640. */
  106641. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106642. private _loadingScreen;
  106643. private _pointerLockRequested;
  106644. private _dummyFramebuffer;
  106645. private _rescalePostProcess;
  106646. private _deterministicLockstep;
  106647. private _lockstepMaxSteps;
  106648. private _timeStep;
  106649. protected get _supportsHardwareTextureRescaling(): boolean;
  106650. private _fps;
  106651. private _deltaTime;
  106652. /** @hidden */
  106653. _drawCalls: PerfCounter;
  106654. /** 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 */
  106655. canvasTabIndex: number;
  106656. /**
  106657. * Turn this value on if you want to pause FPS computation when in background
  106658. */
  106659. disablePerformanceMonitorInBackground: boolean;
  106660. private _performanceMonitor;
  106661. /**
  106662. * Gets the performance monitor attached to this engine
  106663. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106664. */
  106665. get performanceMonitor(): PerformanceMonitor;
  106666. private _onFocus;
  106667. private _onBlur;
  106668. private _onCanvasPointerOut;
  106669. private _onCanvasBlur;
  106670. private _onCanvasFocus;
  106671. private _onFullscreenChange;
  106672. private _onPointerLockChange;
  106673. /**
  106674. * Gets the HTML element used to attach event listeners
  106675. * @returns a HTML element
  106676. */
  106677. getInputElement(): Nullable<HTMLElement>;
  106678. /**
  106679. * Creates a new engine
  106680. * @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
  106681. * @param antialias defines enable antialiasing (default: false)
  106682. * @param options defines further options to be sent to the getContext() function
  106683. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106684. */
  106685. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106686. /**
  106687. * Gets current aspect ratio
  106688. * @param viewportOwner defines the camera to use to get the aspect ratio
  106689. * @param useScreen defines if screen size must be used (or the current render target if any)
  106690. * @returns a number defining the aspect ratio
  106691. */
  106692. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106693. /**
  106694. * Gets current screen aspect ratio
  106695. * @returns a number defining the aspect ratio
  106696. */
  106697. getScreenAspectRatio(): number;
  106698. /**
  106699. * Gets the client rect of the HTML canvas attached with the current webGL context
  106700. * @returns a client rectanglee
  106701. */
  106702. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106703. /**
  106704. * Gets the client rect of the HTML element used for events
  106705. * @returns a client rectanglee
  106706. */
  106707. getInputElementClientRect(): Nullable<ClientRect>;
  106708. /**
  106709. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106710. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106711. * @returns true if engine is in deterministic lock step mode
  106712. */
  106713. isDeterministicLockStep(): boolean;
  106714. /**
  106715. * Gets the max steps when engine is running in deterministic lock step
  106716. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106717. * @returns the max steps
  106718. */
  106719. getLockstepMaxSteps(): number;
  106720. /**
  106721. * Returns the time in ms between steps when using deterministic lock step.
  106722. * @returns time step in (ms)
  106723. */
  106724. getTimeStep(): number;
  106725. /**
  106726. * Force the mipmap generation for the given render target texture
  106727. * @param texture defines the render target texture to use
  106728. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106729. */
  106730. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106731. /** States */
  106732. /**
  106733. * Set various states to the webGL context
  106734. * @param culling defines backface culling state
  106735. * @param zOffset defines the value to apply to zOffset (0 by default)
  106736. * @param force defines if states must be applied even if cache is up to date
  106737. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106738. */
  106739. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106740. /**
  106741. * Set the z offset to apply to current rendering
  106742. * @param value defines the offset to apply
  106743. */
  106744. setZOffset(value: number): void;
  106745. /**
  106746. * Gets the current value of the zOffset
  106747. * @returns the current zOffset state
  106748. */
  106749. getZOffset(): number;
  106750. /**
  106751. * Enable or disable depth buffering
  106752. * @param enable defines the state to set
  106753. */
  106754. setDepthBuffer(enable: boolean): void;
  106755. /**
  106756. * Gets a boolean indicating if depth writing is enabled
  106757. * @returns the current depth writing state
  106758. */
  106759. getDepthWrite(): boolean;
  106760. /**
  106761. * Enable or disable depth writing
  106762. * @param enable defines the state to set
  106763. */
  106764. setDepthWrite(enable: boolean): void;
  106765. /**
  106766. * Gets a boolean indicating if stencil buffer is enabled
  106767. * @returns the current stencil buffer state
  106768. */
  106769. getStencilBuffer(): boolean;
  106770. /**
  106771. * Enable or disable the stencil buffer
  106772. * @param enable defines if the stencil buffer must be enabled or disabled
  106773. */
  106774. setStencilBuffer(enable: boolean): void;
  106775. /**
  106776. * Gets the current stencil mask
  106777. * @returns a number defining the new stencil mask to use
  106778. */
  106779. getStencilMask(): number;
  106780. /**
  106781. * Sets the current stencil mask
  106782. * @param mask defines the new stencil mask to use
  106783. */
  106784. setStencilMask(mask: number): void;
  106785. /**
  106786. * Gets the current stencil function
  106787. * @returns a number defining the stencil function to use
  106788. */
  106789. getStencilFunction(): number;
  106790. /**
  106791. * Gets the current stencil reference value
  106792. * @returns a number defining the stencil reference value to use
  106793. */
  106794. getStencilFunctionReference(): number;
  106795. /**
  106796. * Gets the current stencil mask
  106797. * @returns a number defining the stencil mask to use
  106798. */
  106799. getStencilFunctionMask(): number;
  106800. /**
  106801. * Sets the current stencil function
  106802. * @param stencilFunc defines the new stencil function to use
  106803. */
  106804. setStencilFunction(stencilFunc: number): void;
  106805. /**
  106806. * Sets the current stencil reference
  106807. * @param reference defines the new stencil reference to use
  106808. */
  106809. setStencilFunctionReference(reference: number): void;
  106810. /**
  106811. * Sets the current stencil mask
  106812. * @param mask defines the new stencil mask to use
  106813. */
  106814. setStencilFunctionMask(mask: number): void;
  106815. /**
  106816. * Gets the current stencil operation when stencil fails
  106817. * @returns a number defining stencil operation to use when stencil fails
  106818. */
  106819. getStencilOperationFail(): number;
  106820. /**
  106821. * Gets the current stencil operation when depth fails
  106822. * @returns a number defining stencil operation to use when depth fails
  106823. */
  106824. getStencilOperationDepthFail(): number;
  106825. /**
  106826. * Gets the current stencil operation when stencil passes
  106827. * @returns a number defining stencil operation to use when stencil passes
  106828. */
  106829. getStencilOperationPass(): number;
  106830. /**
  106831. * Sets the stencil operation to use when stencil fails
  106832. * @param operation defines the stencil operation to use when stencil fails
  106833. */
  106834. setStencilOperationFail(operation: number): void;
  106835. /**
  106836. * Sets the stencil operation to use when depth fails
  106837. * @param operation defines the stencil operation to use when depth fails
  106838. */
  106839. setStencilOperationDepthFail(operation: number): void;
  106840. /**
  106841. * Sets the stencil operation to use when stencil passes
  106842. * @param operation defines the stencil operation to use when stencil passes
  106843. */
  106844. setStencilOperationPass(operation: number): void;
  106845. /**
  106846. * Sets a boolean indicating if the dithering state is enabled or disabled
  106847. * @param value defines the dithering state
  106848. */
  106849. setDitheringState(value: boolean): void;
  106850. /**
  106851. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106852. * @param value defines the rasterizer state
  106853. */
  106854. setRasterizerState(value: boolean): void;
  106855. /**
  106856. * Gets the current depth function
  106857. * @returns a number defining the depth function
  106858. */
  106859. getDepthFunction(): Nullable<number>;
  106860. /**
  106861. * Sets the current depth function
  106862. * @param depthFunc defines the function to use
  106863. */
  106864. setDepthFunction(depthFunc: number): void;
  106865. /**
  106866. * Sets the current depth function to GREATER
  106867. */
  106868. setDepthFunctionToGreater(): void;
  106869. /**
  106870. * Sets the current depth function to GEQUAL
  106871. */
  106872. setDepthFunctionToGreaterOrEqual(): void;
  106873. /**
  106874. * Sets the current depth function to LESS
  106875. */
  106876. setDepthFunctionToLess(): void;
  106877. /**
  106878. * Sets the current depth function to LEQUAL
  106879. */
  106880. setDepthFunctionToLessOrEqual(): void;
  106881. private _cachedStencilBuffer;
  106882. private _cachedStencilFunction;
  106883. private _cachedStencilMask;
  106884. private _cachedStencilOperationPass;
  106885. private _cachedStencilOperationFail;
  106886. private _cachedStencilOperationDepthFail;
  106887. private _cachedStencilReference;
  106888. /**
  106889. * Caches the the state of the stencil buffer
  106890. */
  106891. cacheStencilState(): void;
  106892. /**
  106893. * Restores the state of the stencil buffer
  106894. */
  106895. restoreStencilState(): void;
  106896. /**
  106897. * Directly set the WebGL Viewport
  106898. * @param x defines the x coordinate of the viewport (in screen space)
  106899. * @param y defines the y coordinate of the viewport (in screen space)
  106900. * @param width defines the width of the viewport (in screen space)
  106901. * @param height defines the height of the viewport (in screen space)
  106902. * @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
  106903. */
  106904. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106905. /**
  106906. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106907. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106908. * @param y defines the y-coordinate of the corner of the clear rectangle
  106909. * @param width defines the width of the clear rectangle
  106910. * @param height defines the height of the clear rectangle
  106911. * @param clearColor defines the clear color
  106912. */
  106913. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106914. /**
  106915. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106916. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106917. * @param y defines the y-coordinate of the corner of the clear rectangle
  106918. * @param width defines the width of the clear rectangle
  106919. * @param height defines the height of the clear rectangle
  106920. */
  106921. enableScissor(x: number, y: number, width: number, height: number): void;
  106922. /**
  106923. * Disable previously set scissor test rectangle
  106924. */
  106925. disableScissor(): void;
  106926. protected _reportDrawCall(): void;
  106927. /**
  106928. * Initializes a webVR display and starts listening to display change events
  106929. * The onVRDisplayChangedObservable will be notified upon these changes
  106930. * @returns The onVRDisplayChangedObservable
  106931. */
  106932. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106933. /** @hidden */
  106934. _prepareVRComponent(): void;
  106935. /** @hidden */
  106936. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106937. /** @hidden */
  106938. _submitVRFrame(): void;
  106939. /**
  106940. * Call this function to leave webVR mode
  106941. * Will do nothing if webVR is not supported or if there is no webVR device
  106942. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106943. */
  106944. disableVR(): void;
  106945. /**
  106946. * Gets a boolean indicating that the system is in VR mode and is presenting
  106947. * @returns true if VR mode is engaged
  106948. */
  106949. isVRPresenting(): boolean;
  106950. /** @hidden */
  106951. _requestVRFrame(): void;
  106952. /** @hidden */
  106953. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106954. /**
  106955. * Gets the source code of the vertex shader associated with a specific webGL program
  106956. * @param program defines the program to use
  106957. * @returns a string containing the source code of the vertex shader associated with the program
  106958. */
  106959. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106960. /**
  106961. * Gets the source code of the fragment shader associated with a specific webGL program
  106962. * @param program defines the program to use
  106963. * @returns a string containing the source code of the fragment shader associated with the program
  106964. */
  106965. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106966. /**
  106967. * Sets a depth stencil texture from a render target to the according uniform.
  106968. * @param channel The texture channel
  106969. * @param uniform The uniform to set
  106970. * @param texture The render target texture containing the depth stencil texture to apply
  106971. */
  106972. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106973. /**
  106974. * Sets a texture to the webGL context from a postprocess
  106975. * @param channel defines the channel to use
  106976. * @param postProcess defines the source postprocess
  106977. */
  106978. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106979. /**
  106980. * Binds the output of the passed in post process to the texture channel specified
  106981. * @param channel The channel the texture should be bound to
  106982. * @param postProcess The post process which's output should be bound
  106983. */
  106984. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106985. /** @hidden */
  106986. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106987. protected _rebuildBuffers(): void;
  106988. /** @hidden */
  106989. _renderFrame(): void;
  106990. _renderLoop(): void;
  106991. /** @hidden */
  106992. _renderViews(): boolean;
  106993. /**
  106994. * Toggle full screen mode
  106995. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106996. */
  106997. switchFullscreen(requestPointerLock: boolean): void;
  106998. /**
  106999. * Enters full screen mode
  107000. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107001. */
  107002. enterFullscreen(requestPointerLock: boolean): void;
  107003. /**
  107004. * Exits full screen mode
  107005. */
  107006. exitFullscreen(): void;
  107007. /**
  107008. * Enters Pointerlock mode
  107009. */
  107010. enterPointerlock(): void;
  107011. /**
  107012. * Exits Pointerlock mode
  107013. */
  107014. exitPointerlock(): void;
  107015. /**
  107016. * Begin a new frame
  107017. */
  107018. beginFrame(): void;
  107019. /**
  107020. * Enf the current frame
  107021. */
  107022. endFrame(): void;
  107023. resize(): void;
  107024. /**
  107025. * Force a specific size of the canvas
  107026. * @param width defines the new canvas' width
  107027. * @param height defines the new canvas' height
  107028. */
  107029. setSize(width: number, height: number): void;
  107030. /**
  107031. * Updates a dynamic vertex buffer.
  107032. * @param vertexBuffer the vertex buffer to update
  107033. * @param data the data used to update the vertex buffer
  107034. * @param byteOffset the byte offset of the data
  107035. * @param byteLength the byte length of the data
  107036. */
  107037. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107038. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107039. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107040. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107041. _releaseTexture(texture: InternalTexture): void;
  107042. /**
  107043. * @hidden
  107044. * Rescales a texture
  107045. * @param source input texutre
  107046. * @param destination destination texture
  107047. * @param scene scene to use to render the resize
  107048. * @param internalFormat format to use when resizing
  107049. * @param onComplete callback to be called when resize has completed
  107050. */
  107051. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107052. /**
  107053. * Gets the current framerate
  107054. * @returns a number representing the framerate
  107055. */
  107056. getFps(): number;
  107057. /**
  107058. * Gets the time spent between current and previous frame
  107059. * @returns a number representing the delta time in ms
  107060. */
  107061. getDeltaTime(): number;
  107062. private _measureFps;
  107063. /** @hidden */
  107064. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107065. /**
  107066. * Update a dynamic index buffer
  107067. * @param indexBuffer defines the target index buffer
  107068. * @param indices defines the data to update
  107069. * @param offset defines the offset in the target index buffer where update should start
  107070. */
  107071. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107072. /**
  107073. * Updates the sample count of a render target texture
  107074. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107075. * @param texture defines the texture to update
  107076. * @param samples defines the sample count to set
  107077. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107078. */
  107079. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107080. /**
  107081. * Updates a depth texture Comparison Mode and Function.
  107082. * If the comparison Function is equal to 0, the mode will be set to none.
  107083. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107084. * @param texture The texture to set the comparison function for
  107085. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107086. */
  107087. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107088. /**
  107089. * Creates a webGL buffer to use with instanciation
  107090. * @param capacity defines the size of the buffer
  107091. * @returns the webGL buffer
  107092. */
  107093. createInstancesBuffer(capacity: number): DataBuffer;
  107094. /**
  107095. * Delete a webGL buffer used with instanciation
  107096. * @param buffer defines the webGL buffer to delete
  107097. */
  107098. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107099. private _clientWaitAsync;
  107100. /** @hidden */
  107101. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107102. /** @hidden */
  107103. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107104. dispose(): void;
  107105. private _disableTouchAction;
  107106. /**
  107107. * Display the loading screen
  107108. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107109. */
  107110. displayLoadingUI(): void;
  107111. /**
  107112. * Hide the loading screen
  107113. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107114. */
  107115. hideLoadingUI(): void;
  107116. /**
  107117. * Gets the current loading screen object
  107118. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107119. */
  107120. get loadingScreen(): ILoadingScreen;
  107121. /**
  107122. * Sets the current loading screen object
  107123. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107124. */
  107125. set loadingScreen(loadingScreen: ILoadingScreen);
  107126. /**
  107127. * Sets the current loading screen text
  107128. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107129. */
  107130. set loadingUIText(text: string);
  107131. /**
  107132. * Sets the current loading screen background color
  107133. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107134. */
  107135. set loadingUIBackgroundColor(color: string);
  107136. /** Pointerlock and fullscreen */
  107137. /**
  107138. * Ask the browser to promote the current element to pointerlock mode
  107139. * @param element defines the DOM element to promote
  107140. */
  107141. static _RequestPointerlock(element: HTMLElement): void;
  107142. /**
  107143. * Asks the browser to exit pointerlock mode
  107144. */
  107145. static _ExitPointerlock(): void;
  107146. /**
  107147. * Ask the browser to promote the current element to fullscreen rendering mode
  107148. * @param element defines the DOM element to promote
  107149. */
  107150. static _RequestFullscreen(element: HTMLElement): void;
  107151. /**
  107152. * Asks the browser to exit fullscreen mode
  107153. */
  107154. static _ExitFullscreen(): void;
  107155. }
  107156. }
  107157. declare module BABYLON {
  107158. /**
  107159. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107160. * during the life time of the application.
  107161. */
  107162. export class EngineStore {
  107163. /** Gets the list of created engines */
  107164. static Instances: Engine[];
  107165. /** @hidden */
  107166. static _LastCreatedScene: Nullable<Scene>;
  107167. /**
  107168. * Gets the latest created engine
  107169. */
  107170. static get LastCreatedEngine(): Nullable<Engine>;
  107171. /**
  107172. * Gets the latest created scene
  107173. */
  107174. static get LastCreatedScene(): Nullable<Scene>;
  107175. /**
  107176. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107177. * @ignorenaming
  107178. */
  107179. static UseFallbackTexture: boolean;
  107180. /**
  107181. * Texture content used if a texture cannot loaded
  107182. * @ignorenaming
  107183. */
  107184. static FallbackTexture: string;
  107185. }
  107186. }
  107187. declare module BABYLON {
  107188. /**
  107189. * Helper class that provides a small promise polyfill
  107190. */
  107191. export class PromisePolyfill {
  107192. /**
  107193. * Static function used to check if the polyfill is required
  107194. * If this is the case then the function will inject the polyfill to window.Promise
  107195. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107196. */
  107197. static Apply(force?: boolean): void;
  107198. }
  107199. }
  107200. declare module BABYLON {
  107201. /**
  107202. * Interface for screenshot methods with describe argument called `size` as object with options
  107203. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107204. */
  107205. export interface IScreenshotSize {
  107206. /**
  107207. * number in pixels for canvas height
  107208. */
  107209. height?: number;
  107210. /**
  107211. * multiplier allowing render at a higher or lower resolution
  107212. * If value is defined then height and width will be ignored and taken from camera
  107213. */
  107214. precision?: number;
  107215. /**
  107216. * number in pixels for canvas width
  107217. */
  107218. width?: number;
  107219. }
  107220. }
  107221. declare module BABYLON {
  107222. interface IColor4Like {
  107223. r: float;
  107224. g: float;
  107225. b: float;
  107226. a: float;
  107227. }
  107228. /**
  107229. * Class containing a set of static utilities functions
  107230. */
  107231. export class Tools {
  107232. /**
  107233. * Gets or sets the base URL to use to load assets
  107234. */
  107235. static get BaseUrl(): string;
  107236. static set BaseUrl(value: string);
  107237. /**
  107238. * Enable/Disable Custom HTTP Request Headers globally.
  107239. * default = false
  107240. * @see CustomRequestHeaders
  107241. */
  107242. static UseCustomRequestHeaders: boolean;
  107243. /**
  107244. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107245. * i.e. when loading files, where the server/service expects an Authorization header
  107246. */
  107247. static CustomRequestHeaders: {
  107248. [key: string]: string;
  107249. };
  107250. /**
  107251. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107252. */
  107253. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107254. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107255. /**
  107256. * Default behaviour for cors in the application.
  107257. * It can be a string if the expected behavior is identical in the entire app.
  107258. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107259. */
  107260. static CorsBehavior: string | ((url: string | string[]) => string);
  107261. /**
  107262. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107263. * @ignorenaming
  107264. */
  107265. static get UseFallbackTexture(): boolean;
  107266. static set UseFallbackTexture(value: boolean);
  107267. /**
  107268. * Use this object to register external classes like custom textures or material
  107269. * to allow the laoders to instantiate them
  107270. */
  107271. static get RegisteredExternalClasses(): {
  107272. [key: string]: Object;
  107273. };
  107274. static set RegisteredExternalClasses(classes: {
  107275. [key: string]: Object;
  107276. });
  107277. /**
  107278. * Texture content used if a texture cannot loaded
  107279. * @ignorenaming
  107280. */
  107281. static get fallbackTexture(): string;
  107282. static set fallbackTexture(value: string);
  107283. /**
  107284. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107285. * @param u defines the coordinate on X axis
  107286. * @param v defines the coordinate on Y axis
  107287. * @param width defines the width of the source data
  107288. * @param height defines the height of the source data
  107289. * @param pixels defines the source byte array
  107290. * @param color defines the output color
  107291. */
  107292. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107293. /**
  107294. * Interpolates between a and b via alpha
  107295. * @param a The lower value (returned when alpha = 0)
  107296. * @param b The upper value (returned when alpha = 1)
  107297. * @param alpha The interpolation-factor
  107298. * @return The mixed value
  107299. */
  107300. static Mix(a: number, b: number, alpha: number): number;
  107301. /**
  107302. * Tries to instantiate a new object from a given class name
  107303. * @param className defines the class name to instantiate
  107304. * @returns the new object or null if the system was not able to do the instantiation
  107305. */
  107306. static Instantiate(className: string): any;
  107307. /**
  107308. * Provides a slice function that will work even on IE
  107309. * @param data defines the array to slice
  107310. * @param start defines the start of the data (optional)
  107311. * @param end defines the end of the data (optional)
  107312. * @returns the new sliced array
  107313. */
  107314. static Slice<T>(data: T, start?: number, end?: number): T;
  107315. /**
  107316. * Polyfill for setImmediate
  107317. * @param action defines the action to execute after the current execution block
  107318. */
  107319. static SetImmediate(action: () => void): void;
  107320. /**
  107321. * Function indicating if a number is an exponent of 2
  107322. * @param value defines the value to test
  107323. * @returns true if the value is an exponent of 2
  107324. */
  107325. static IsExponentOfTwo(value: number): boolean;
  107326. private static _tmpFloatArray;
  107327. /**
  107328. * Returns the nearest 32-bit single precision float representation of a Number
  107329. * @param value A Number. If the parameter is of a different type, it will get converted
  107330. * to a number or to NaN if it cannot be converted
  107331. * @returns number
  107332. */
  107333. static FloatRound(value: number): number;
  107334. /**
  107335. * Extracts the filename from a path
  107336. * @param path defines the path to use
  107337. * @returns the filename
  107338. */
  107339. static GetFilename(path: string): string;
  107340. /**
  107341. * Extracts the "folder" part of a path (everything before the filename).
  107342. * @param uri The URI to extract the info from
  107343. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107344. * @returns The "folder" part of the path
  107345. */
  107346. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107347. /**
  107348. * Extracts text content from a DOM element hierarchy
  107349. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107350. */
  107351. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107352. /**
  107353. * Convert an angle in radians to degrees
  107354. * @param angle defines the angle to convert
  107355. * @returns the angle in degrees
  107356. */
  107357. static ToDegrees(angle: number): number;
  107358. /**
  107359. * Convert an angle in degrees to radians
  107360. * @param angle defines the angle to convert
  107361. * @returns the angle in radians
  107362. */
  107363. static ToRadians(angle: number): number;
  107364. /**
  107365. * Returns an array if obj is not an array
  107366. * @param obj defines the object to evaluate as an array
  107367. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107368. * @returns either obj directly if obj is an array or a new array containing obj
  107369. */
  107370. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107371. /**
  107372. * Gets the pointer prefix to use
  107373. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107374. */
  107375. static GetPointerPrefix(): string;
  107376. /**
  107377. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107378. * @param url define the url we are trying
  107379. * @param element define the dom element where to configure the cors policy
  107380. */
  107381. static SetCorsBehavior(url: string | string[], element: {
  107382. crossOrigin: string | null;
  107383. }): void;
  107384. /**
  107385. * Removes unwanted characters from an url
  107386. * @param url defines the url to clean
  107387. * @returns the cleaned url
  107388. */
  107389. static CleanUrl(url: string): string;
  107390. /**
  107391. * Gets or sets a function used to pre-process url before using them to load assets
  107392. */
  107393. static get PreprocessUrl(): (url: string) => string;
  107394. static set PreprocessUrl(processor: (url: string) => string);
  107395. /**
  107396. * Loads an image as an HTMLImageElement.
  107397. * @param input url string, ArrayBuffer, or Blob to load
  107398. * @param onLoad callback called when the image successfully loads
  107399. * @param onError callback called when the image fails to load
  107400. * @param offlineProvider offline provider for caching
  107401. * @param mimeType optional mime type
  107402. * @returns the HTMLImageElement of the loaded image
  107403. */
  107404. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107405. /**
  107406. * Loads a file from a url
  107407. * @param url url string, ArrayBuffer, or Blob to load
  107408. * @param onSuccess callback called when the file successfully loads
  107409. * @param onProgress callback called while file is loading (if the server supports this mode)
  107410. * @param offlineProvider defines the offline provider for caching
  107411. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107412. * @param onError callback called when the file fails to load
  107413. * @returns a file request object
  107414. */
  107415. 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;
  107416. /**
  107417. * Loads a file from a url
  107418. * @param url the file url to load
  107419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107420. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107421. */
  107422. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107423. /**
  107424. * Load a script (identified by an url). When the url returns, the
  107425. * content of this file is added into a new script element, attached to the DOM (body element)
  107426. * @param scriptUrl defines the url of the script to laod
  107427. * @param onSuccess defines the callback called when the script is loaded
  107428. * @param onError defines the callback to call if an error occurs
  107429. * @param scriptId defines the id of the script element
  107430. */
  107431. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107432. /**
  107433. * Load an asynchronous script (identified by an url). When the url returns, the
  107434. * content of this file is added into a new script element, attached to the DOM (body element)
  107435. * @param scriptUrl defines the url of the script to laod
  107436. * @param scriptId defines the id of the script element
  107437. * @returns a promise request object
  107438. */
  107439. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107440. /**
  107441. * Loads a file from a blob
  107442. * @param fileToLoad defines the blob to use
  107443. * @param callback defines the callback to call when data is loaded
  107444. * @param progressCallback defines the callback to call during loading process
  107445. * @returns a file request object
  107446. */
  107447. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107448. /**
  107449. * Reads a file from a File object
  107450. * @param file defines the file to load
  107451. * @param onSuccess defines the callback to call when data is loaded
  107452. * @param onProgress defines the callback to call during loading process
  107453. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107454. * @param onError defines the callback to call when an error occurs
  107455. * @returns a file request object
  107456. */
  107457. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107458. /**
  107459. * Creates a data url from a given string content
  107460. * @param content defines the content to convert
  107461. * @returns the new data url link
  107462. */
  107463. static FileAsURL(content: string): string;
  107464. /**
  107465. * Format the given number to a specific decimal format
  107466. * @param value defines the number to format
  107467. * @param decimals defines the number of decimals to use
  107468. * @returns the formatted string
  107469. */
  107470. static Format(value: number, decimals?: number): string;
  107471. /**
  107472. * Tries to copy an object by duplicating every property
  107473. * @param source defines the source object
  107474. * @param destination defines the target object
  107475. * @param doNotCopyList defines a list of properties to avoid
  107476. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107477. */
  107478. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107479. /**
  107480. * Gets a boolean indicating if the given object has no own property
  107481. * @param obj defines the object to test
  107482. * @returns true if object has no own property
  107483. */
  107484. static IsEmpty(obj: any): boolean;
  107485. /**
  107486. * Function used to register events at window level
  107487. * @param windowElement defines the Window object to use
  107488. * @param events defines the events to register
  107489. */
  107490. static RegisterTopRootEvents(windowElement: Window, events: {
  107491. name: string;
  107492. handler: Nullable<(e: FocusEvent) => any>;
  107493. }[]): void;
  107494. /**
  107495. * Function used to unregister events from window level
  107496. * @param windowElement defines the Window object to use
  107497. * @param events defines the events to unregister
  107498. */
  107499. static UnregisterTopRootEvents(windowElement: Window, events: {
  107500. name: string;
  107501. handler: Nullable<(e: FocusEvent) => any>;
  107502. }[]): void;
  107503. /**
  107504. * @ignore
  107505. */
  107506. static _ScreenshotCanvas: HTMLCanvasElement;
  107507. /**
  107508. * Dumps the current bound framebuffer
  107509. * @param width defines the rendering width
  107510. * @param height defines the rendering height
  107511. * @param engine defines the hosting engine
  107512. * @param successCallback defines the callback triggered once the data are available
  107513. * @param mimeType defines the mime type of the result
  107514. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107515. */
  107516. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107517. /**
  107518. * Converts the canvas data to blob.
  107519. * This acts as a polyfill for browsers not supporting the to blob function.
  107520. * @param canvas Defines the canvas to extract the data from
  107521. * @param successCallback Defines the callback triggered once the data are available
  107522. * @param mimeType Defines the mime type of the result
  107523. */
  107524. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107525. /**
  107526. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107527. * @param successCallback defines the callback triggered once the data are available
  107528. * @param mimeType defines the mime type of the result
  107529. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107530. */
  107531. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107532. /**
  107533. * Downloads a blob in the browser
  107534. * @param blob defines the blob to download
  107535. * @param fileName defines the name of the downloaded file
  107536. */
  107537. static Download(blob: Blob, fileName: string): void;
  107538. /**
  107539. * Captures a screenshot of the current rendering
  107540. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107541. * @param engine defines the rendering engine
  107542. * @param camera defines the source camera
  107543. * @param size This parameter can be set to a single number or to an object with the
  107544. * following (optional) properties: precision, width, height. If a single number is passed,
  107545. * it will be used for both width and height. If an object is passed, the screenshot size
  107546. * will be derived from the parameters. The precision property is a multiplier allowing
  107547. * rendering at a higher or lower resolution
  107548. * @param successCallback defines the callback receives a single parameter which contains the
  107549. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107550. * src parameter of an <img> to display it
  107551. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107552. * Check your browser for supported MIME types
  107553. */
  107554. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107555. /**
  107556. * Captures a screenshot of the current rendering
  107557. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107558. * @param engine defines the rendering engine
  107559. * @param camera defines the source camera
  107560. * @param size This parameter can be set to a single number or to an object with the
  107561. * following (optional) properties: precision, width, height. If a single number is passed,
  107562. * it will be used for both width and height. If an object is passed, the screenshot size
  107563. * will be derived from the parameters. The precision property is a multiplier allowing
  107564. * rendering at a higher or lower resolution
  107565. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107566. * Check your browser for supported MIME types
  107567. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107568. * to the src parameter of an <img> to display it
  107569. */
  107570. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107571. /**
  107572. * Generates an image screenshot from the specified camera.
  107573. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107574. * @param engine The engine to use for rendering
  107575. * @param camera The camera to use for rendering
  107576. * @param size This parameter can be set to a single number or to an object with the
  107577. * following (optional) properties: precision, width, height. If a single number is passed,
  107578. * it will be used for both width and height. If an object is passed, the screenshot size
  107579. * will be derived from the parameters. The precision property is a multiplier allowing
  107580. * rendering at a higher or lower resolution
  107581. * @param successCallback The callback receives a single parameter which contains the
  107582. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107583. * src parameter of an <img> to display it
  107584. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107585. * Check your browser for supported MIME types
  107586. * @param samples Texture samples (default: 1)
  107587. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107588. * @param fileName A name for for the downloaded file.
  107589. */
  107590. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107591. /**
  107592. * Generates an image screenshot from the specified camera.
  107593. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107594. * @param engine The engine to use for rendering
  107595. * @param camera The camera to use for rendering
  107596. * @param size This parameter can be set to a single number or to an object with the
  107597. * following (optional) properties: precision, width, height. If a single number is passed,
  107598. * it will be used for both width and height. If an object is passed, the screenshot size
  107599. * will be derived from the parameters. The precision property is a multiplier allowing
  107600. * rendering at a higher or lower resolution
  107601. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107602. * Check your browser for supported MIME types
  107603. * @param samples Texture samples (default: 1)
  107604. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107605. * @param fileName A name for for the downloaded file.
  107606. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107607. * to the src parameter of an <img> to display it
  107608. */
  107609. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107610. /**
  107611. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107612. * Be aware Math.random() could cause collisions, but:
  107613. * "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"
  107614. * @returns a pseudo random id
  107615. */
  107616. static RandomId(): string;
  107617. /**
  107618. * Test if the given uri is a base64 string
  107619. * @param uri The uri to test
  107620. * @return True if the uri is a base64 string or false otherwise
  107621. */
  107622. static IsBase64(uri: string): boolean;
  107623. /**
  107624. * Decode the given base64 uri.
  107625. * @param uri The uri to decode
  107626. * @return The decoded base64 data.
  107627. */
  107628. static DecodeBase64(uri: string): ArrayBuffer;
  107629. /**
  107630. * Gets the absolute url.
  107631. * @param url the input url
  107632. * @return the absolute url
  107633. */
  107634. static GetAbsoluteUrl(url: string): string;
  107635. /**
  107636. * No log
  107637. */
  107638. static readonly NoneLogLevel: number;
  107639. /**
  107640. * Only message logs
  107641. */
  107642. static readonly MessageLogLevel: number;
  107643. /**
  107644. * Only warning logs
  107645. */
  107646. static readonly WarningLogLevel: number;
  107647. /**
  107648. * Only error logs
  107649. */
  107650. static readonly ErrorLogLevel: number;
  107651. /**
  107652. * All logs
  107653. */
  107654. static readonly AllLogLevel: number;
  107655. /**
  107656. * Gets a value indicating the number of loading errors
  107657. * @ignorenaming
  107658. */
  107659. static get errorsCount(): number;
  107660. /**
  107661. * Callback called when a new log is added
  107662. */
  107663. static OnNewCacheEntry: (entry: string) => void;
  107664. /**
  107665. * Log a message to the console
  107666. * @param message defines the message to log
  107667. */
  107668. static Log(message: string): void;
  107669. /**
  107670. * Write a warning message to the console
  107671. * @param message defines the message to log
  107672. */
  107673. static Warn(message: string): void;
  107674. /**
  107675. * Write an error message to the console
  107676. * @param message defines the message to log
  107677. */
  107678. static Error(message: string): void;
  107679. /**
  107680. * Gets current log cache (list of logs)
  107681. */
  107682. static get LogCache(): string;
  107683. /**
  107684. * Clears the log cache
  107685. */
  107686. static ClearLogCache(): void;
  107687. /**
  107688. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107689. */
  107690. static set LogLevels(level: number);
  107691. /**
  107692. * Checks if the window object exists
  107693. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107694. */
  107695. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107696. /**
  107697. * No performance log
  107698. */
  107699. static readonly PerformanceNoneLogLevel: number;
  107700. /**
  107701. * Use user marks to log performance
  107702. */
  107703. static readonly PerformanceUserMarkLogLevel: number;
  107704. /**
  107705. * Log performance to the console
  107706. */
  107707. static readonly PerformanceConsoleLogLevel: number;
  107708. private static _performance;
  107709. /**
  107710. * Sets the current performance log level
  107711. */
  107712. static set PerformanceLogLevel(level: number);
  107713. private static _StartPerformanceCounterDisabled;
  107714. private static _EndPerformanceCounterDisabled;
  107715. private static _StartUserMark;
  107716. private static _EndUserMark;
  107717. private static _StartPerformanceConsole;
  107718. private static _EndPerformanceConsole;
  107719. /**
  107720. * Starts a performance counter
  107721. */
  107722. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107723. /**
  107724. * Ends a specific performance coutner
  107725. */
  107726. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107727. /**
  107728. * Gets either window.performance.now() if supported or Date.now() else
  107729. */
  107730. static get Now(): number;
  107731. /**
  107732. * This method will return the name of the class used to create the instance of the given object.
  107733. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107734. * @param object the object to get the class name from
  107735. * @param isType defines if the object is actually a type
  107736. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107737. */
  107738. static GetClassName(object: any, isType?: boolean): string;
  107739. /**
  107740. * Gets the first element of an array satisfying a given predicate
  107741. * @param array defines the array to browse
  107742. * @param predicate defines the predicate to use
  107743. * @returns null if not found or the element
  107744. */
  107745. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107746. /**
  107747. * This method will return the name of the full name of the class, including its owning module (if any).
  107748. * 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).
  107749. * @param object the object to get the class name from
  107750. * @param isType defines if the object is actually a type
  107751. * @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.
  107752. * @ignorenaming
  107753. */
  107754. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107755. /**
  107756. * Returns a promise that resolves after the given amount of time.
  107757. * @param delay Number of milliseconds to delay
  107758. * @returns Promise that resolves after the given amount of time
  107759. */
  107760. static DelayAsync(delay: number): Promise<void>;
  107761. /**
  107762. * Utility function to detect if the current user agent is Safari
  107763. * @returns whether or not the current user agent is safari
  107764. */
  107765. static IsSafari(): boolean;
  107766. }
  107767. /**
  107768. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107769. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107770. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107771. * @param name The name of the class, case should be preserved
  107772. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107773. */
  107774. export function className(name: string, module?: string): (target: Object) => void;
  107775. /**
  107776. * An implementation of a loop for asynchronous functions.
  107777. */
  107778. export class AsyncLoop {
  107779. /**
  107780. * Defines the number of iterations for the loop
  107781. */
  107782. iterations: number;
  107783. /**
  107784. * Defines the current index of the loop.
  107785. */
  107786. index: number;
  107787. private _done;
  107788. private _fn;
  107789. private _successCallback;
  107790. /**
  107791. * Constructor.
  107792. * @param iterations the number of iterations.
  107793. * @param func the function to run each iteration
  107794. * @param successCallback the callback that will be called upon succesful execution
  107795. * @param offset starting offset.
  107796. */
  107797. constructor(
  107798. /**
  107799. * Defines the number of iterations for the loop
  107800. */
  107801. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107802. /**
  107803. * Execute the next iteration. Must be called after the last iteration was finished.
  107804. */
  107805. executeNext(): void;
  107806. /**
  107807. * Break the loop and run the success callback.
  107808. */
  107809. breakLoop(): void;
  107810. /**
  107811. * Create and run an async loop.
  107812. * @param iterations the number of iterations.
  107813. * @param fn the function to run each iteration
  107814. * @param successCallback the callback that will be called upon succesful execution
  107815. * @param offset starting offset.
  107816. * @returns the created async loop object
  107817. */
  107818. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107819. /**
  107820. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107821. * @param iterations total number of iterations
  107822. * @param syncedIterations number of synchronous iterations in each async iteration.
  107823. * @param fn the function to call each iteration.
  107824. * @param callback a success call back that will be called when iterating stops.
  107825. * @param breakFunction a break condition (optional)
  107826. * @param timeout timeout settings for the setTimeout function. default - 0.
  107827. * @returns the created async loop object
  107828. */
  107829. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107830. }
  107831. }
  107832. declare module BABYLON {
  107833. /**
  107834. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107835. * The underlying implementation relies on an associative array to ensure the best performances.
  107836. * The value can be anything including 'null' but except 'undefined'
  107837. */
  107838. export class StringDictionary<T> {
  107839. /**
  107840. * This will clear this dictionary and copy the content from the 'source' one.
  107841. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107842. * @param source the dictionary to take the content from and copy to this dictionary
  107843. */
  107844. copyFrom(source: StringDictionary<T>): void;
  107845. /**
  107846. * Get a value based from its key
  107847. * @param key the given key to get the matching value from
  107848. * @return the value if found, otherwise undefined is returned
  107849. */
  107850. get(key: string): T | undefined;
  107851. /**
  107852. * Get a value from its key or add it if it doesn't exist.
  107853. * This method will ensure you that a given key/data will be present in the dictionary.
  107854. * @param key the given key to get the matching value from
  107855. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107856. * The factory will only be invoked if there's no data for the given key.
  107857. * @return the value corresponding to the key.
  107858. */
  107859. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107860. /**
  107861. * Get a value from its key if present in the dictionary otherwise add it
  107862. * @param key the key to get the value from
  107863. * @param val if there's no such key/value pair in the dictionary add it with this value
  107864. * @return the value corresponding to the key
  107865. */
  107866. getOrAdd(key: string, val: T): T;
  107867. /**
  107868. * Check if there's a given key in the dictionary
  107869. * @param key the key to check for
  107870. * @return true if the key is present, false otherwise
  107871. */
  107872. contains(key: string): boolean;
  107873. /**
  107874. * Add a new key and its corresponding value
  107875. * @param key the key to add
  107876. * @param value the value corresponding to the key
  107877. * @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
  107878. */
  107879. add(key: string, value: T): boolean;
  107880. /**
  107881. * Update a specific value associated to a key
  107882. * @param key defines the key to use
  107883. * @param value defines the value to store
  107884. * @returns true if the value was updated (or false if the key was not found)
  107885. */
  107886. set(key: string, value: T): boolean;
  107887. /**
  107888. * Get the element of the given key and remove it from the dictionary
  107889. * @param key defines the key to search
  107890. * @returns the value associated with the key or null if not found
  107891. */
  107892. getAndRemove(key: string): Nullable<T>;
  107893. /**
  107894. * Remove a key/value from the dictionary.
  107895. * @param key the key to remove
  107896. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107897. */
  107898. remove(key: string): boolean;
  107899. /**
  107900. * Clear the whole content of the dictionary
  107901. */
  107902. clear(): void;
  107903. /**
  107904. * Gets the current count
  107905. */
  107906. get count(): number;
  107907. /**
  107908. * Execute a callback on each key/val of the dictionary.
  107909. * Note that you can remove any element in this dictionary in the callback implementation
  107910. * @param callback the callback to execute on a given key/value pair
  107911. */
  107912. forEach(callback: (key: string, val: T) => void): void;
  107913. /**
  107914. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107915. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107916. * Note that you can remove any element in this dictionary in the callback implementation
  107917. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107918. * @returns the first item
  107919. */
  107920. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107921. private _count;
  107922. private _data;
  107923. }
  107924. }
  107925. declare module BABYLON {
  107926. /** @hidden */
  107927. export interface ICollisionCoordinator {
  107928. createCollider(): Collider;
  107929. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107930. init(scene: Scene): void;
  107931. }
  107932. /** @hidden */
  107933. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107934. private _scene;
  107935. private _scaledPosition;
  107936. private _scaledVelocity;
  107937. private _finalPosition;
  107938. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107939. createCollider(): Collider;
  107940. init(scene: Scene): void;
  107941. private _collideWithWorld;
  107942. }
  107943. }
  107944. declare module BABYLON {
  107945. /**
  107946. * Class used to manage all inputs for the scene.
  107947. */
  107948. export class InputManager {
  107949. /** The distance in pixel that you have to move to prevent some events */
  107950. static DragMovementThreshold: number;
  107951. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107952. static LongPressDelay: number;
  107953. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107954. static DoubleClickDelay: number;
  107955. /** If you need to check double click without raising a single click at first click, enable this flag */
  107956. static ExclusiveDoubleClickMode: boolean;
  107957. private _wheelEventName;
  107958. private _onPointerMove;
  107959. private _onPointerDown;
  107960. private _onPointerUp;
  107961. private _initClickEvent;
  107962. private _initActionManager;
  107963. private _delayedSimpleClick;
  107964. private _delayedSimpleClickTimeout;
  107965. private _previousDelayedSimpleClickTimeout;
  107966. private _meshPickProceed;
  107967. private _previousButtonPressed;
  107968. private _currentPickResult;
  107969. private _previousPickResult;
  107970. private _totalPointersPressed;
  107971. private _doubleClickOccured;
  107972. private _pointerOverMesh;
  107973. private _pickedDownMesh;
  107974. private _pickedUpMesh;
  107975. private _pointerX;
  107976. private _pointerY;
  107977. private _unTranslatedPointerX;
  107978. private _unTranslatedPointerY;
  107979. private _startingPointerPosition;
  107980. private _previousStartingPointerPosition;
  107981. private _startingPointerTime;
  107982. private _previousStartingPointerTime;
  107983. private _pointerCaptures;
  107984. private _onKeyDown;
  107985. private _onKeyUp;
  107986. private _onCanvasFocusObserver;
  107987. private _onCanvasBlurObserver;
  107988. private _scene;
  107989. /**
  107990. * Creates a new InputManager
  107991. * @param scene defines the hosting scene
  107992. */
  107993. constructor(scene: Scene);
  107994. /**
  107995. * Gets the mesh that is currently under the pointer
  107996. */
  107997. get meshUnderPointer(): Nullable<AbstractMesh>;
  107998. /**
  107999. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  108000. */
  108001. get unTranslatedPointer(): Vector2;
  108002. /**
  108003. * Gets or sets the current on-screen X position of the pointer
  108004. */
  108005. get pointerX(): number;
  108006. set pointerX(value: number);
  108007. /**
  108008. * Gets or sets the current on-screen Y position of the pointer
  108009. */
  108010. get pointerY(): number;
  108011. set pointerY(value: number);
  108012. private _updatePointerPosition;
  108013. private _processPointerMove;
  108014. private _setRayOnPointerInfo;
  108015. private _checkPrePointerObservable;
  108016. /**
  108017. * Use this method to simulate a pointer move on a mesh
  108018. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108019. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108020. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108021. */
  108022. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108023. /**
  108024. * Use this method to simulate a pointer down on a mesh
  108025. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108026. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108027. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108028. */
  108029. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108030. private _processPointerDown;
  108031. /** @hidden */
  108032. _isPointerSwiping(): boolean;
  108033. /**
  108034. * Use this method to simulate a pointer up on a mesh
  108035. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108036. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108037. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108038. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108039. */
  108040. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108041. private _processPointerUp;
  108042. /**
  108043. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108044. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108045. * @returns true if the pointer was captured
  108046. */
  108047. isPointerCaptured(pointerId?: number): boolean;
  108048. /**
  108049. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108050. * @param attachUp defines if you want to attach events to pointerup
  108051. * @param attachDown defines if you want to attach events to pointerdown
  108052. * @param attachMove defines if you want to attach events to pointermove
  108053. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108054. */
  108055. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108056. /**
  108057. * Detaches all event handlers
  108058. */
  108059. detachControl(): void;
  108060. /**
  108061. * Force the value of meshUnderPointer
  108062. * @param mesh defines the mesh to use
  108063. */
  108064. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108065. /**
  108066. * Gets the mesh under the pointer
  108067. * @returns a Mesh or null if no mesh is under the pointer
  108068. */
  108069. getPointerOverMesh(): Nullable<AbstractMesh>;
  108070. }
  108071. }
  108072. declare module BABYLON {
  108073. /**
  108074. * Helper class used to generate session unique ID
  108075. */
  108076. export class UniqueIdGenerator {
  108077. private static _UniqueIdCounter;
  108078. /**
  108079. * Gets an unique (relatively to the current scene) Id
  108080. */
  108081. static get UniqueId(): number;
  108082. }
  108083. }
  108084. declare module BABYLON {
  108085. /**
  108086. * This class defines the direct association between an animation and a target
  108087. */
  108088. export class TargetedAnimation {
  108089. /**
  108090. * Animation to perform
  108091. */
  108092. animation: Animation;
  108093. /**
  108094. * Target to animate
  108095. */
  108096. target: any;
  108097. /**
  108098. * Serialize the object
  108099. * @returns the JSON object representing the current entity
  108100. */
  108101. serialize(): any;
  108102. }
  108103. /**
  108104. * Use this class to create coordinated animations on multiple targets
  108105. */
  108106. export class AnimationGroup implements IDisposable {
  108107. /** The name of the animation group */
  108108. name: string;
  108109. private _scene;
  108110. private _targetedAnimations;
  108111. private _animatables;
  108112. private _from;
  108113. private _to;
  108114. private _isStarted;
  108115. private _isPaused;
  108116. private _speedRatio;
  108117. private _loopAnimation;
  108118. /**
  108119. * Gets or sets the unique id of the node
  108120. */
  108121. uniqueId: number;
  108122. /**
  108123. * This observable will notify when one animation have ended
  108124. */
  108125. onAnimationEndObservable: Observable<TargetedAnimation>;
  108126. /**
  108127. * Observer raised when one animation loops
  108128. */
  108129. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108130. /**
  108131. * Observer raised when all animations have looped
  108132. */
  108133. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108134. /**
  108135. * This observable will notify when all animations have ended.
  108136. */
  108137. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108138. /**
  108139. * This observable will notify when all animations have paused.
  108140. */
  108141. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108142. /**
  108143. * This observable will notify when all animations are playing.
  108144. */
  108145. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108146. /**
  108147. * Gets the first frame
  108148. */
  108149. get from(): number;
  108150. /**
  108151. * Gets the last frame
  108152. */
  108153. get to(): number;
  108154. /**
  108155. * Define if the animations are started
  108156. */
  108157. get isStarted(): boolean;
  108158. /**
  108159. * Gets a value indicating that the current group is playing
  108160. */
  108161. get isPlaying(): boolean;
  108162. /**
  108163. * Gets or sets the speed ratio to use for all animations
  108164. */
  108165. get speedRatio(): number;
  108166. /**
  108167. * Gets or sets the speed ratio to use for all animations
  108168. */
  108169. set speedRatio(value: number);
  108170. /**
  108171. * Gets or sets if all animations should loop or not
  108172. */
  108173. get loopAnimation(): boolean;
  108174. set loopAnimation(value: boolean);
  108175. /**
  108176. * Gets the targeted animations for this animation group
  108177. */
  108178. get targetedAnimations(): Array<TargetedAnimation>;
  108179. /**
  108180. * returning the list of animatables controlled by this animation group.
  108181. */
  108182. get animatables(): Array<Animatable>;
  108183. /**
  108184. * Instantiates a new Animation Group.
  108185. * This helps managing several animations at once.
  108186. * @see http://doc.babylonjs.com/how_to/group
  108187. * @param name Defines the name of the group
  108188. * @param scene Defines the scene the group belongs to
  108189. */
  108190. constructor(
  108191. /** The name of the animation group */
  108192. name: string, scene?: Nullable<Scene>);
  108193. /**
  108194. * Add an animation (with its target) in the group
  108195. * @param animation defines the animation we want to add
  108196. * @param target defines the target of the animation
  108197. * @returns the TargetedAnimation object
  108198. */
  108199. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108200. /**
  108201. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108202. * It can add constant keys at begin or end
  108203. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108204. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108205. * @returns the animation group
  108206. */
  108207. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108208. private _animationLoopCount;
  108209. private _animationLoopFlags;
  108210. private _processLoop;
  108211. /**
  108212. * Start all animations on given targets
  108213. * @param loop defines if animations must loop
  108214. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108215. * @param from defines the from key (optional)
  108216. * @param to defines the to key (optional)
  108217. * @returns the current animation group
  108218. */
  108219. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108220. /**
  108221. * Pause all animations
  108222. * @returns the animation group
  108223. */
  108224. pause(): AnimationGroup;
  108225. /**
  108226. * Play all animations to initial state
  108227. * This function will start() the animations if they were not started or will restart() them if they were paused
  108228. * @param loop defines if animations must loop
  108229. * @returns the animation group
  108230. */
  108231. play(loop?: boolean): AnimationGroup;
  108232. /**
  108233. * Reset all animations to initial state
  108234. * @returns the animation group
  108235. */
  108236. reset(): AnimationGroup;
  108237. /**
  108238. * Restart animations from key 0
  108239. * @returns the animation group
  108240. */
  108241. restart(): AnimationGroup;
  108242. /**
  108243. * Stop all animations
  108244. * @returns the animation group
  108245. */
  108246. stop(): AnimationGroup;
  108247. /**
  108248. * Set animation weight for all animatables
  108249. * @param weight defines the weight to use
  108250. * @return the animationGroup
  108251. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108252. */
  108253. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108254. /**
  108255. * Synchronize and normalize all animatables with a source animatable
  108256. * @param root defines the root animatable to synchronize with
  108257. * @return the animationGroup
  108258. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108259. */
  108260. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108261. /**
  108262. * Goes to a specific frame in this animation group
  108263. * @param frame the frame number to go to
  108264. * @return the animationGroup
  108265. */
  108266. goToFrame(frame: number): AnimationGroup;
  108267. /**
  108268. * Dispose all associated resources
  108269. */
  108270. dispose(): void;
  108271. private _checkAnimationGroupEnded;
  108272. /**
  108273. * Clone the current animation group and returns a copy
  108274. * @param newName defines the name of the new group
  108275. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108276. * @returns the new aniamtion group
  108277. */
  108278. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108279. /**
  108280. * Serializes the animationGroup to an object
  108281. * @returns Serialized object
  108282. */
  108283. serialize(): any;
  108284. /**
  108285. * Returns a new AnimationGroup object parsed from the source provided.
  108286. * @param parsedAnimationGroup defines the source
  108287. * @param scene defines the scene that will receive the animationGroup
  108288. * @returns a new AnimationGroup
  108289. */
  108290. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108291. /**
  108292. * Returns the string "AnimationGroup"
  108293. * @returns "AnimationGroup"
  108294. */
  108295. getClassName(): string;
  108296. /**
  108297. * Creates a detailled string about the object
  108298. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108299. * @returns a string representing the object
  108300. */
  108301. toString(fullDetails?: boolean): string;
  108302. }
  108303. }
  108304. declare module BABYLON {
  108305. /**
  108306. * Define an interface for all classes that will hold resources
  108307. */
  108308. export interface IDisposable {
  108309. /**
  108310. * Releases all held resources
  108311. */
  108312. dispose(): void;
  108313. }
  108314. /** Interface defining initialization parameters for Scene class */
  108315. export interface SceneOptions {
  108316. /**
  108317. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108318. * It will improve performance when the number of geometries becomes important.
  108319. */
  108320. useGeometryUniqueIdsMap?: boolean;
  108321. /**
  108322. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108323. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108324. */
  108325. useMaterialMeshMap?: boolean;
  108326. /**
  108327. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108328. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108329. */
  108330. useClonedMeshMap?: boolean;
  108331. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108332. virtual?: boolean;
  108333. }
  108334. /**
  108335. * Represents a scene to be rendered by the engine.
  108336. * @see http://doc.babylonjs.com/features/scene
  108337. */
  108338. export class Scene extends AbstractScene implements IAnimatable {
  108339. /** The fog is deactivated */
  108340. static readonly FOGMODE_NONE: number;
  108341. /** The fog density is following an exponential function */
  108342. static readonly FOGMODE_EXP: number;
  108343. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108344. static readonly FOGMODE_EXP2: number;
  108345. /** The fog density is following a linear function. */
  108346. static readonly FOGMODE_LINEAR: number;
  108347. /**
  108348. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108349. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108350. */
  108351. static MinDeltaTime: number;
  108352. /**
  108353. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108354. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108355. */
  108356. static MaxDeltaTime: number;
  108357. /**
  108358. * Factory used to create the default material.
  108359. * @param name The name of the material to create
  108360. * @param scene The scene to create the material for
  108361. * @returns The default material
  108362. */
  108363. static DefaultMaterialFactory(scene: Scene): Material;
  108364. /**
  108365. * Factory used to create the a collision coordinator.
  108366. * @returns The collision coordinator
  108367. */
  108368. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108369. /** @hidden */
  108370. _inputManager: InputManager;
  108371. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108372. cameraToUseForPointers: Nullable<Camera>;
  108373. /** @hidden */
  108374. readonly _isScene: boolean;
  108375. /** @hidden */
  108376. _blockEntityCollection: boolean;
  108377. /**
  108378. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108379. */
  108380. autoClear: boolean;
  108381. /**
  108382. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108383. */
  108384. autoClearDepthAndStencil: boolean;
  108385. /**
  108386. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108387. */
  108388. clearColor: Color4;
  108389. /**
  108390. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108391. */
  108392. ambientColor: Color3;
  108393. /**
  108394. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108395. * It should only be one of the following (if not the default embedded one):
  108396. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108397. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108398. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108399. * The material properties need to be setup according to the type of texture in use.
  108400. */
  108401. environmentBRDFTexture: BaseTexture;
  108402. /** @hidden */
  108403. protected _environmentTexture: Nullable<BaseTexture>;
  108404. /**
  108405. * Texture used in all pbr material as the reflection texture.
  108406. * As in the majority of the scene they are the same (exception for multi room and so on),
  108407. * this is easier to reference from here than from all the materials.
  108408. */
  108409. get environmentTexture(): Nullable<BaseTexture>;
  108410. /**
  108411. * Texture used in all pbr material as the reflection texture.
  108412. * As in the majority of the scene they are the same (exception for multi room and so on),
  108413. * this is easier to set here than in all the materials.
  108414. */
  108415. set environmentTexture(value: Nullable<BaseTexture>);
  108416. /** @hidden */
  108417. protected _environmentIntensity: number;
  108418. /**
  108419. * Intensity of the environment in all pbr material.
  108420. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108421. * As in the majority of the scene they are the same (exception for multi room and so on),
  108422. * this is easier to reference from here than from all the materials.
  108423. */
  108424. get environmentIntensity(): number;
  108425. /**
  108426. * Intensity of the environment in all pbr material.
  108427. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108428. * As in the majority of the scene they are the same (exception for multi room and so on),
  108429. * this is easier to set here than in all the materials.
  108430. */
  108431. set environmentIntensity(value: number);
  108432. /** @hidden */
  108433. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108434. /**
  108435. * Default image processing configuration used either in the rendering
  108436. * Forward main pass or through the imageProcessingPostProcess if present.
  108437. * As in the majority of the scene they are the same (exception for multi camera),
  108438. * this is easier to reference from here than from all the materials and post process.
  108439. *
  108440. * No setter as we it is a shared configuration, you can set the values instead.
  108441. */
  108442. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108443. private _forceWireframe;
  108444. /**
  108445. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108446. */
  108447. set forceWireframe(value: boolean);
  108448. get forceWireframe(): boolean;
  108449. private _skipFrustumClipping;
  108450. /**
  108451. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108452. */
  108453. set skipFrustumClipping(value: boolean);
  108454. get skipFrustumClipping(): boolean;
  108455. private _forcePointsCloud;
  108456. /**
  108457. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108458. */
  108459. set forcePointsCloud(value: boolean);
  108460. get forcePointsCloud(): boolean;
  108461. /**
  108462. * Gets or sets the active clipplane 1
  108463. */
  108464. clipPlane: Nullable<Plane>;
  108465. /**
  108466. * Gets or sets the active clipplane 2
  108467. */
  108468. clipPlane2: Nullable<Plane>;
  108469. /**
  108470. * Gets or sets the active clipplane 3
  108471. */
  108472. clipPlane3: Nullable<Plane>;
  108473. /**
  108474. * Gets or sets the active clipplane 4
  108475. */
  108476. clipPlane4: Nullable<Plane>;
  108477. /**
  108478. * Gets or sets the active clipplane 5
  108479. */
  108480. clipPlane5: Nullable<Plane>;
  108481. /**
  108482. * Gets or sets the active clipplane 6
  108483. */
  108484. clipPlane6: Nullable<Plane>;
  108485. /**
  108486. * Gets or sets a boolean indicating if animations are enabled
  108487. */
  108488. animationsEnabled: boolean;
  108489. private _animationPropertiesOverride;
  108490. /**
  108491. * Gets or sets the animation properties override
  108492. */
  108493. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108494. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108495. /**
  108496. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108497. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108498. */
  108499. useConstantAnimationDeltaTime: boolean;
  108500. /**
  108501. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108502. * Please note that it requires to run a ray cast through the scene on every frame
  108503. */
  108504. constantlyUpdateMeshUnderPointer: boolean;
  108505. /**
  108506. * Defines the HTML cursor to use when hovering over interactive elements
  108507. */
  108508. hoverCursor: string;
  108509. /**
  108510. * Defines the HTML default cursor to use (empty by default)
  108511. */
  108512. defaultCursor: string;
  108513. /**
  108514. * Defines whether cursors are handled by the scene.
  108515. */
  108516. doNotHandleCursors: boolean;
  108517. /**
  108518. * This is used to call preventDefault() on pointer down
  108519. * in order to block unwanted artifacts like system double clicks
  108520. */
  108521. preventDefaultOnPointerDown: boolean;
  108522. /**
  108523. * This is used to call preventDefault() on pointer up
  108524. * in order to block unwanted artifacts like system double clicks
  108525. */
  108526. preventDefaultOnPointerUp: boolean;
  108527. /**
  108528. * Gets or sets user defined metadata
  108529. */
  108530. metadata: any;
  108531. /**
  108532. * For internal use only. Please do not use.
  108533. */
  108534. reservedDataStore: any;
  108535. /**
  108536. * Gets the name of the plugin used to load this scene (null by default)
  108537. */
  108538. loadingPluginName: string;
  108539. /**
  108540. * Use this array to add regular expressions used to disable offline support for specific urls
  108541. */
  108542. disableOfflineSupportExceptionRules: RegExp[];
  108543. /**
  108544. * An event triggered when the scene is disposed.
  108545. */
  108546. onDisposeObservable: Observable<Scene>;
  108547. private _onDisposeObserver;
  108548. /** Sets a function to be executed when this scene is disposed. */
  108549. set onDispose(callback: () => void);
  108550. /**
  108551. * An event triggered before rendering the scene (right after animations and physics)
  108552. */
  108553. onBeforeRenderObservable: Observable<Scene>;
  108554. private _onBeforeRenderObserver;
  108555. /** Sets a function to be executed before rendering this scene */
  108556. set beforeRender(callback: Nullable<() => void>);
  108557. /**
  108558. * An event triggered after rendering the scene
  108559. */
  108560. onAfterRenderObservable: Observable<Scene>;
  108561. /**
  108562. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108563. */
  108564. onAfterRenderCameraObservable: Observable<Camera>;
  108565. private _onAfterRenderObserver;
  108566. /** Sets a function to be executed after rendering this scene */
  108567. set afterRender(callback: Nullable<() => void>);
  108568. /**
  108569. * An event triggered before animating the scene
  108570. */
  108571. onBeforeAnimationsObservable: Observable<Scene>;
  108572. /**
  108573. * An event triggered after animations processing
  108574. */
  108575. onAfterAnimationsObservable: Observable<Scene>;
  108576. /**
  108577. * An event triggered before draw calls are ready to be sent
  108578. */
  108579. onBeforeDrawPhaseObservable: Observable<Scene>;
  108580. /**
  108581. * An event triggered after draw calls have been sent
  108582. */
  108583. onAfterDrawPhaseObservable: Observable<Scene>;
  108584. /**
  108585. * An event triggered when the scene is ready
  108586. */
  108587. onReadyObservable: Observable<Scene>;
  108588. /**
  108589. * An event triggered before rendering a camera
  108590. */
  108591. onBeforeCameraRenderObservable: Observable<Camera>;
  108592. private _onBeforeCameraRenderObserver;
  108593. /** Sets a function to be executed before rendering a camera*/
  108594. set beforeCameraRender(callback: () => void);
  108595. /**
  108596. * An event triggered after rendering a camera
  108597. */
  108598. onAfterCameraRenderObservable: Observable<Camera>;
  108599. private _onAfterCameraRenderObserver;
  108600. /** Sets a function to be executed after rendering a camera*/
  108601. set afterCameraRender(callback: () => void);
  108602. /**
  108603. * An event triggered when active meshes evaluation is about to start
  108604. */
  108605. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108606. /**
  108607. * An event triggered when active meshes evaluation is done
  108608. */
  108609. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108610. /**
  108611. * An event triggered when particles rendering is about to start
  108612. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108613. */
  108614. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108615. /**
  108616. * An event triggered when particles rendering is done
  108617. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108618. */
  108619. onAfterParticlesRenderingObservable: Observable<Scene>;
  108620. /**
  108621. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108622. */
  108623. onDataLoadedObservable: Observable<Scene>;
  108624. /**
  108625. * An event triggered when a camera is created
  108626. */
  108627. onNewCameraAddedObservable: Observable<Camera>;
  108628. /**
  108629. * An event triggered when a camera is removed
  108630. */
  108631. onCameraRemovedObservable: Observable<Camera>;
  108632. /**
  108633. * An event triggered when a light is created
  108634. */
  108635. onNewLightAddedObservable: Observable<Light>;
  108636. /**
  108637. * An event triggered when a light is removed
  108638. */
  108639. onLightRemovedObservable: Observable<Light>;
  108640. /**
  108641. * An event triggered when a geometry is created
  108642. */
  108643. onNewGeometryAddedObservable: Observable<Geometry>;
  108644. /**
  108645. * An event triggered when a geometry is removed
  108646. */
  108647. onGeometryRemovedObservable: Observable<Geometry>;
  108648. /**
  108649. * An event triggered when a transform node is created
  108650. */
  108651. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108652. /**
  108653. * An event triggered when a transform node is removed
  108654. */
  108655. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108656. /**
  108657. * An event triggered when a mesh is created
  108658. */
  108659. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108660. /**
  108661. * An event triggered when a mesh is removed
  108662. */
  108663. onMeshRemovedObservable: Observable<AbstractMesh>;
  108664. /**
  108665. * An event triggered when a skeleton is created
  108666. */
  108667. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108668. /**
  108669. * An event triggered when a skeleton is removed
  108670. */
  108671. onSkeletonRemovedObservable: Observable<Skeleton>;
  108672. /**
  108673. * An event triggered when a material is created
  108674. */
  108675. onNewMaterialAddedObservable: Observable<Material>;
  108676. /**
  108677. * An event triggered when a material is removed
  108678. */
  108679. onMaterialRemovedObservable: Observable<Material>;
  108680. /**
  108681. * An event triggered when a texture is created
  108682. */
  108683. onNewTextureAddedObservable: Observable<BaseTexture>;
  108684. /**
  108685. * An event triggered when a texture is removed
  108686. */
  108687. onTextureRemovedObservable: Observable<BaseTexture>;
  108688. /**
  108689. * An event triggered when render targets are about to be rendered
  108690. * Can happen multiple times per frame.
  108691. */
  108692. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108693. /**
  108694. * An event triggered when render targets were rendered.
  108695. * Can happen multiple times per frame.
  108696. */
  108697. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108698. /**
  108699. * An event triggered before calculating deterministic simulation step
  108700. */
  108701. onBeforeStepObservable: Observable<Scene>;
  108702. /**
  108703. * An event triggered after calculating deterministic simulation step
  108704. */
  108705. onAfterStepObservable: Observable<Scene>;
  108706. /**
  108707. * An event triggered when the activeCamera property is updated
  108708. */
  108709. onActiveCameraChanged: Observable<Scene>;
  108710. /**
  108711. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108712. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108713. * 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)
  108714. */
  108715. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108716. /**
  108717. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108718. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108719. * 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)
  108720. */
  108721. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108722. /**
  108723. * This Observable will when a mesh has been imported into the scene.
  108724. */
  108725. onMeshImportedObservable: Observable<AbstractMesh>;
  108726. /**
  108727. * This Observable will when an animation file has been imported into the scene.
  108728. */
  108729. onAnimationFileImportedObservable: Observable<Scene>;
  108730. /**
  108731. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108732. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108733. */
  108734. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108735. /** @hidden */
  108736. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108737. /**
  108738. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108739. */
  108740. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108741. /**
  108742. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108743. */
  108744. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108745. /**
  108746. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108747. */
  108748. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108749. /** Callback called when a pointer move is detected */
  108750. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108751. /** Callback called when a pointer down is detected */
  108752. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108753. /** Callback called when a pointer up is detected */
  108754. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108755. /** Callback called when a pointer pick is detected */
  108756. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108757. /**
  108758. * 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).
  108759. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108760. */
  108761. onPrePointerObservable: Observable<PointerInfoPre>;
  108762. /**
  108763. * Observable event triggered each time an input event is received from the rendering canvas
  108764. */
  108765. onPointerObservable: Observable<PointerInfo>;
  108766. /**
  108767. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108768. */
  108769. get unTranslatedPointer(): Vector2;
  108770. /**
  108771. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108772. */
  108773. static get DragMovementThreshold(): number;
  108774. static set DragMovementThreshold(value: number);
  108775. /**
  108776. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108777. */
  108778. static get LongPressDelay(): number;
  108779. static set LongPressDelay(value: number);
  108780. /**
  108781. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108782. */
  108783. static get DoubleClickDelay(): number;
  108784. static set DoubleClickDelay(value: number);
  108785. /** If you need to check double click without raising a single click at first click, enable this flag */
  108786. static get ExclusiveDoubleClickMode(): boolean;
  108787. static set ExclusiveDoubleClickMode(value: boolean);
  108788. /** @hidden */
  108789. _mirroredCameraPosition: Nullable<Vector3>;
  108790. /**
  108791. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108792. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108793. */
  108794. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108795. /**
  108796. * Observable event triggered each time an keyboard event is received from the hosting window
  108797. */
  108798. onKeyboardObservable: Observable<KeyboardInfo>;
  108799. private _useRightHandedSystem;
  108800. /**
  108801. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108802. */
  108803. set useRightHandedSystem(value: boolean);
  108804. get useRightHandedSystem(): boolean;
  108805. private _timeAccumulator;
  108806. private _currentStepId;
  108807. private _currentInternalStep;
  108808. /**
  108809. * Sets the step Id used by deterministic lock step
  108810. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108811. * @param newStepId defines the step Id
  108812. */
  108813. setStepId(newStepId: number): void;
  108814. /**
  108815. * Gets the step Id used by deterministic lock step
  108816. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108817. * @returns the step Id
  108818. */
  108819. getStepId(): number;
  108820. /**
  108821. * Gets the internal step used by deterministic lock step
  108822. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108823. * @returns the internal step
  108824. */
  108825. getInternalStep(): number;
  108826. private _fogEnabled;
  108827. /**
  108828. * Gets or sets a boolean indicating if fog is enabled on this scene
  108829. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108830. * (Default is true)
  108831. */
  108832. set fogEnabled(value: boolean);
  108833. get fogEnabled(): boolean;
  108834. private _fogMode;
  108835. /**
  108836. * Gets or sets the fog mode to use
  108837. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108838. * | mode | value |
  108839. * | --- | --- |
  108840. * | FOGMODE_NONE | 0 |
  108841. * | FOGMODE_EXP | 1 |
  108842. * | FOGMODE_EXP2 | 2 |
  108843. * | FOGMODE_LINEAR | 3 |
  108844. */
  108845. set fogMode(value: number);
  108846. get fogMode(): number;
  108847. /**
  108848. * Gets or sets the fog color to use
  108849. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108850. * (Default is Color3(0.2, 0.2, 0.3))
  108851. */
  108852. fogColor: Color3;
  108853. /**
  108854. * Gets or sets the fog density to use
  108855. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108856. * (Default is 0.1)
  108857. */
  108858. fogDensity: number;
  108859. /**
  108860. * Gets or sets the fog start distance to use
  108861. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108862. * (Default is 0)
  108863. */
  108864. fogStart: number;
  108865. /**
  108866. * Gets or sets the fog end distance to use
  108867. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108868. * (Default is 1000)
  108869. */
  108870. fogEnd: number;
  108871. private _shadowsEnabled;
  108872. /**
  108873. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108874. */
  108875. set shadowsEnabled(value: boolean);
  108876. get shadowsEnabled(): boolean;
  108877. private _lightsEnabled;
  108878. /**
  108879. * Gets or sets a boolean indicating if lights are enabled on this scene
  108880. */
  108881. set lightsEnabled(value: boolean);
  108882. get lightsEnabled(): boolean;
  108883. /** All of the active cameras added to this scene. */
  108884. activeCameras: Camera[];
  108885. /** @hidden */
  108886. _activeCamera: Nullable<Camera>;
  108887. /** Gets or sets the current active camera */
  108888. get activeCamera(): Nullable<Camera>;
  108889. set activeCamera(value: Nullable<Camera>);
  108890. private _defaultMaterial;
  108891. /** The default material used on meshes when no material is affected */
  108892. get defaultMaterial(): Material;
  108893. /** The default material used on meshes when no material is affected */
  108894. set defaultMaterial(value: Material);
  108895. private _texturesEnabled;
  108896. /**
  108897. * Gets or sets a boolean indicating if textures are enabled on this scene
  108898. */
  108899. set texturesEnabled(value: boolean);
  108900. get texturesEnabled(): boolean;
  108901. /**
  108902. * Gets or sets a boolean indicating if particles are enabled on this scene
  108903. */
  108904. particlesEnabled: boolean;
  108905. /**
  108906. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108907. */
  108908. spritesEnabled: boolean;
  108909. private _skeletonsEnabled;
  108910. /**
  108911. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108912. */
  108913. set skeletonsEnabled(value: boolean);
  108914. get skeletonsEnabled(): boolean;
  108915. /**
  108916. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108917. */
  108918. lensFlaresEnabled: boolean;
  108919. /**
  108920. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108921. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108922. */
  108923. collisionsEnabled: boolean;
  108924. private _collisionCoordinator;
  108925. /** @hidden */
  108926. get collisionCoordinator(): ICollisionCoordinator;
  108927. /**
  108928. * Defines the gravity applied to this scene (used only for collisions)
  108929. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108930. */
  108931. gravity: Vector3;
  108932. /**
  108933. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108934. */
  108935. postProcessesEnabled: boolean;
  108936. /**
  108937. * The list of postprocesses added to the scene
  108938. */
  108939. postProcesses: PostProcess[];
  108940. /**
  108941. * Gets the current postprocess manager
  108942. */
  108943. postProcessManager: PostProcessManager;
  108944. /**
  108945. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108946. */
  108947. renderTargetsEnabled: boolean;
  108948. /**
  108949. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108950. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108951. */
  108952. dumpNextRenderTargets: boolean;
  108953. /**
  108954. * The list of user defined render targets added to the scene
  108955. */
  108956. customRenderTargets: RenderTargetTexture[];
  108957. /**
  108958. * Defines if texture loading must be delayed
  108959. * If true, textures will only be loaded when they need to be rendered
  108960. */
  108961. useDelayedTextureLoading: boolean;
  108962. /**
  108963. * Gets the list of meshes imported to the scene through SceneLoader
  108964. */
  108965. importedMeshesFiles: String[];
  108966. /**
  108967. * Gets or sets a boolean indicating if probes are enabled on this scene
  108968. */
  108969. probesEnabled: boolean;
  108970. /**
  108971. * Gets or sets the current offline provider to use to store scene data
  108972. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108973. */
  108974. offlineProvider: IOfflineProvider;
  108975. /**
  108976. * Gets or sets the action manager associated with the scene
  108977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108978. */
  108979. actionManager: AbstractActionManager;
  108980. private _meshesForIntersections;
  108981. /**
  108982. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108983. */
  108984. proceduralTexturesEnabled: boolean;
  108985. private _engine;
  108986. private _totalVertices;
  108987. /** @hidden */
  108988. _activeIndices: PerfCounter;
  108989. /** @hidden */
  108990. _activeParticles: PerfCounter;
  108991. /** @hidden */
  108992. _activeBones: PerfCounter;
  108993. private _animationRatio;
  108994. /** @hidden */
  108995. _animationTimeLast: number;
  108996. /** @hidden */
  108997. _animationTime: number;
  108998. /**
  108999. * Gets or sets a general scale for animation speed
  109000. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  109001. */
  109002. animationTimeScale: number;
  109003. /** @hidden */
  109004. _cachedMaterial: Nullable<Material>;
  109005. /** @hidden */
  109006. _cachedEffect: Nullable<Effect>;
  109007. /** @hidden */
  109008. _cachedVisibility: Nullable<number>;
  109009. private _renderId;
  109010. private _frameId;
  109011. private _executeWhenReadyTimeoutId;
  109012. private _intermediateRendering;
  109013. private _viewUpdateFlag;
  109014. private _projectionUpdateFlag;
  109015. /** @hidden */
  109016. _toBeDisposed: Nullable<IDisposable>[];
  109017. private _activeRequests;
  109018. /** @hidden */
  109019. _pendingData: any[];
  109020. private _isDisposed;
  109021. /**
  109022. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109023. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109024. */
  109025. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109026. private _activeMeshes;
  109027. private _processedMaterials;
  109028. private _renderTargets;
  109029. /** @hidden */
  109030. _activeParticleSystems: SmartArray<IParticleSystem>;
  109031. private _activeSkeletons;
  109032. private _softwareSkinnedMeshes;
  109033. private _renderingManager;
  109034. /** @hidden */
  109035. _activeAnimatables: Animatable[];
  109036. private _transformMatrix;
  109037. private _sceneUbo;
  109038. /** @hidden */
  109039. _viewMatrix: Matrix;
  109040. private _projectionMatrix;
  109041. /** @hidden */
  109042. _forcedViewPosition: Nullable<Vector3>;
  109043. /** @hidden */
  109044. _frustumPlanes: Plane[];
  109045. /**
  109046. * Gets the list of frustum planes (built from the active camera)
  109047. */
  109048. get frustumPlanes(): Plane[];
  109049. /**
  109050. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109051. * This is useful if there are more lights that the maximum simulteanous authorized
  109052. */
  109053. requireLightSorting: boolean;
  109054. /** @hidden */
  109055. readonly useMaterialMeshMap: boolean;
  109056. /** @hidden */
  109057. readonly useClonedMeshMap: boolean;
  109058. private _externalData;
  109059. private _uid;
  109060. /**
  109061. * @hidden
  109062. * Backing store of defined scene components.
  109063. */
  109064. _components: ISceneComponent[];
  109065. /**
  109066. * @hidden
  109067. * Backing store of defined scene components.
  109068. */
  109069. _serializableComponents: ISceneSerializableComponent[];
  109070. /**
  109071. * List of components to register on the next registration step.
  109072. */
  109073. private _transientComponents;
  109074. /**
  109075. * Registers the transient components if needed.
  109076. */
  109077. private _registerTransientComponents;
  109078. /**
  109079. * @hidden
  109080. * Add a component to the scene.
  109081. * Note that the ccomponent could be registered on th next frame if this is called after
  109082. * the register component stage.
  109083. * @param component Defines the component to add to the scene
  109084. */
  109085. _addComponent(component: ISceneComponent): void;
  109086. /**
  109087. * @hidden
  109088. * Gets a component from the scene.
  109089. * @param name defines the name of the component to retrieve
  109090. * @returns the component or null if not present
  109091. */
  109092. _getComponent(name: string): Nullable<ISceneComponent>;
  109093. /**
  109094. * @hidden
  109095. * Defines the actions happening before camera updates.
  109096. */
  109097. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109098. /**
  109099. * @hidden
  109100. * Defines the actions happening before clear the canvas.
  109101. */
  109102. _beforeClearStage: Stage<SimpleStageAction>;
  109103. /**
  109104. * @hidden
  109105. * Defines the actions when collecting render targets for the frame.
  109106. */
  109107. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109108. /**
  109109. * @hidden
  109110. * Defines the actions happening for one camera in the frame.
  109111. */
  109112. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109113. /**
  109114. * @hidden
  109115. * Defines the actions happening during the per mesh ready checks.
  109116. */
  109117. _isReadyForMeshStage: Stage<MeshStageAction>;
  109118. /**
  109119. * @hidden
  109120. * Defines the actions happening before evaluate active mesh checks.
  109121. */
  109122. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109123. /**
  109124. * @hidden
  109125. * Defines the actions happening during the evaluate sub mesh checks.
  109126. */
  109127. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109128. /**
  109129. * @hidden
  109130. * Defines the actions happening during the active mesh stage.
  109131. */
  109132. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109133. /**
  109134. * @hidden
  109135. * Defines the actions happening during the per camera render target step.
  109136. */
  109137. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109138. /**
  109139. * @hidden
  109140. * Defines the actions happening just before the active camera is drawing.
  109141. */
  109142. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109143. /**
  109144. * @hidden
  109145. * Defines the actions happening just before a render target is drawing.
  109146. */
  109147. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109148. /**
  109149. * @hidden
  109150. * Defines the actions happening just before a rendering group is drawing.
  109151. */
  109152. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109153. /**
  109154. * @hidden
  109155. * Defines the actions happening just before a mesh is drawing.
  109156. */
  109157. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109158. /**
  109159. * @hidden
  109160. * Defines the actions happening just after a mesh has been drawn.
  109161. */
  109162. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109163. /**
  109164. * @hidden
  109165. * Defines the actions happening just after a rendering group has been drawn.
  109166. */
  109167. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109168. /**
  109169. * @hidden
  109170. * Defines the actions happening just after the active camera has been drawn.
  109171. */
  109172. _afterCameraDrawStage: Stage<CameraStageAction>;
  109173. /**
  109174. * @hidden
  109175. * Defines the actions happening just after a render target has been drawn.
  109176. */
  109177. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109178. /**
  109179. * @hidden
  109180. * Defines the actions happening just after rendering all cameras and computing intersections.
  109181. */
  109182. _afterRenderStage: Stage<SimpleStageAction>;
  109183. /**
  109184. * @hidden
  109185. * Defines the actions happening when a pointer move event happens.
  109186. */
  109187. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109188. /**
  109189. * @hidden
  109190. * Defines the actions happening when a pointer down event happens.
  109191. */
  109192. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109193. /**
  109194. * @hidden
  109195. * Defines the actions happening when a pointer up event happens.
  109196. */
  109197. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109198. /**
  109199. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109200. */
  109201. private geometriesByUniqueId;
  109202. /**
  109203. * Creates a new Scene
  109204. * @param engine defines the engine to use to render this scene
  109205. * @param options defines the scene options
  109206. */
  109207. constructor(engine: Engine, options?: SceneOptions);
  109208. /**
  109209. * Gets a string idenfifying the name of the class
  109210. * @returns "Scene" string
  109211. */
  109212. getClassName(): string;
  109213. private _defaultMeshCandidates;
  109214. /**
  109215. * @hidden
  109216. */
  109217. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109218. private _defaultSubMeshCandidates;
  109219. /**
  109220. * @hidden
  109221. */
  109222. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109223. /**
  109224. * Sets the default candidate providers for the scene.
  109225. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109226. * and getCollidingSubMeshCandidates to their default function
  109227. */
  109228. setDefaultCandidateProviders(): void;
  109229. /**
  109230. * Gets the mesh that is currently under the pointer
  109231. */
  109232. get meshUnderPointer(): Nullable<AbstractMesh>;
  109233. /**
  109234. * Gets or sets the current on-screen X position of the pointer
  109235. */
  109236. get pointerX(): number;
  109237. set pointerX(value: number);
  109238. /**
  109239. * Gets or sets the current on-screen Y position of the pointer
  109240. */
  109241. get pointerY(): number;
  109242. set pointerY(value: number);
  109243. /**
  109244. * Gets the cached material (ie. the latest rendered one)
  109245. * @returns the cached material
  109246. */
  109247. getCachedMaterial(): Nullable<Material>;
  109248. /**
  109249. * Gets the cached effect (ie. the latest rendered one)
  109250. * @returns the cached effect
  109251. */
  109252. getCachedEffect(): Nullable<Effect>;
  109253. /**
  109254. * Gets the cached visibility state (ie. the latest rendered one)
  109255. * @returns the cached visibility state
  109256. */
  109257. getCachedVisibility(): Nullable<number>;
  109258. /**
  109259. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109260. * @param material defines the current material
  109261. * @param effect defines the current effect
  109262. * @param visibility defines the current visibility state
  109263. * @returns true if one parameter is not cached
  109264. */
  109265. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109266. /**
  109267. * Gets the engine associated with the scene
  109268. * @returns an Engine
  109269. */
  109270. getEngine(): Engine;
  109271. /**
  109272. * Gets the total number of vertices rendered per frame
  109273. * @returns the total number of vertices rendered per frame
  109274. */
  109275. getTotalVertices(): number;
  109276. /**
  109277. * Gets the performance counter for total vertices
  109278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109279. */
  109280. get totalVerticesPerfCounter(): PerfCounter;
  109281. /**
  109282. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109283. * @returns the total number of active indices rendered per frame
  109284. */
  109285. getActiveIndices(): number;
  109286. /**
  109287. * Gets the performance counter for active indices
  109288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109289. */
  109290. get totalActiveIndicesPerfCounter(): PerfCounter;
  109291. /**
  109292. * Gets the total number of active particles rendered per frame
  109293. * @returns the total number of active particles rendered per frame
  109294. */
  109295. getActiveParticles(): number;
  109296. /**
  109297. * Gets the performance counter for active particles
  109298. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109299. */
  109300. get activeParticlesPerfCounter(): PerfCounter;
  109301. /**
  109302. * Gets the total number of active bones rendered per frame
  109303. * @returns the total number of active bones rendered per frame
  109304. */
  109305. getActiveBones(): number;
  109306. /**
  109307. * Gets the performance counter for active bones
  109308. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109309. */
  109310. get activeBonesPerfCounter(): PerfCounter;
  109311. /**
  109312. * Gets the array of active meshes
  109313. * @returns an array of AbstractMesh
  109314. */
  109315. getActiveMeshes(): SmartArray<AbstractMesh>;
  109316. /**
  109317. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109318. * @returns a number
  109319. */
  109320. getAnimationRatio(): number;
  109321. /**
  109322. * Gets an unique Id for the current render phase
  109323. * @returns a number
  109324. */
  109325. getRenderId(): number;
  109326. /**
  109327. * Gets an unique Id for the current frame
  109328. * @returns a number
  109329. */
  109330. getFrameId(): number;
  109331. /** Call this function if you want to manually increment the render Id*/
  109332. incrementRenderId(): void;
  109333. private _createUbo;
  109334. /**
  109335. * Use this method to simulate a pointer move on a mesh
  109336. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109337. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109338. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109339. * @returns the current scene
  109340. */
  109341. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109342. /**
  109343. * Use this method to simulate a pointer down on a mesh
  109344. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109345. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109346. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109347. * @returns the current scene
  109348. */
  109349. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109350. /**
  109351. * Use this method to simulate a pointer up on a mesh
  109352. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109353. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109354. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109355. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109356. * @returns the current scene
  109357. */
  109358. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109359. /**
  109360. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109361. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109362. * @returns true if the pointer was captured
  109363. */
  109364. isPointerCaptured(pointerId?: number): boolean;
  109365. /**
  109366. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109367. * @param attachUp defines if you want to attach events to pointerup
  109368. * @param attachDown defines if you want to attach events to pointerdown
  109369. * @param attachMove defines if you want to attach events to pointermove
  109370. */
  109371. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109372. /** Detaches all event handlers*/
  109373. detachControl(): void;
  109374. /**
  109375. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109376. * Delay loaded resources are not taking in account
  109377. * @return true if all required resources are ready
  109378. */
  109379. isReady(): boolean;
  109380. /** Resets all cached information relative to material (including effect and visibility) */
  109381. resetCachedMaterial(): void;
  109382. /**
  109383. * Registers a function to be called before every frame render
  109384. * @param func defines the function to register
  109385. */
  109386. registerBeforeRender(func: () => void): void;
  109387. /**
  109388. * Unregisters a function called before every frame render
  109389. * @param func defines the function to unregister
  109390. */
  109391. unregisterBeforeRender(func: () => void): void;
  109392. /**
  109393. * Registers a function to be called after every frame render
  109394. * @param func defines the function to register
  109395. */
  109396. registerAfterRender(func: () => void): void;
  109397. /**
  109398. * Unregisters a function called after every frame render
  109399. * @param func defines the function to unregister
  109400. */
  109401. unregisterAfterRender(func: () => void): void;
  109402. private _executeOnceBeforeRender;
  109403. /**
  109404. * The provided function will run before render once and will be disposed afterwards.
  109405. * A timeout delay can be provided so that the function will be executed in N ms.
  109406. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109407. * @param func The function to be executed.
  109408. * @param timeout optional delay in ms
  109409. */
  109410. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109411. /** @hidden */
  109412. _addPendingData(data: any): void;
  109413. /** @hidden */
  109414. _removePendingData(data: any): void;
  109415. /**
  109416. * Returns the number of items waiting to be loaded
  109417. * @returns the number of items waiting to be loaded
  109418. */
  109419. getWaitingItemsCount(): number;
  109420. /**
  109421. * Returns a boolean indicating if the scene is still loading data
  109422. */
  109423. get isLoading(): boolean;
  109424. /**
  109425. * Registers a function to be executed when the scene is ready
  109426. * @param {Function} func - the function to be executed
  109427. */
  109428. executeWhenReady(func: () => void): void;
  109429. /**
  109430. * Returns a promise that resolves when the scene is ready
  109431. * @returns A promise that resolves when the scene is ready
  109432. */
  109433. whenReadyAsync(): Promise<void>;
  109434. /** @hidden */
  109435. _checkIsReady(): void;
  109436. /**
  109437. * Gets all animatable attached to the scene
  109438. */
  109439. get animatables(): Animatable[];
  109440. /**
  109441. * Resets the last animation time frame.
  109442. * Useful to override when animations start running when loading a scene for the first time.
  109443. */
  109444. resetLastAnimationTimeFrame(): void;
  109445. /**
  109446. * Gets the current view matrix
  109447. * @returns a Matrix
  109448. */
  109449. getViewMatrix(): Matrix;
  109450. /**
  109451. * Gets the current projection matrix
  109452. * @returns a Matrix
  109453. */
  109454. getProjectionMatrix(): Matrix;
  109455. /**
  109456. * Gets the current transform matrix
  109457. * @returns a Matrix made of View * Projection
  109458. */
  109459. getTransformMatrix(): Matrix;
  109460. /**
  109461. * Sets the current transform matrix
  109462. * @param viewL defines the View matrix to use
  109463. * @param projectionL defines the Projection matrix to use
  109464. * @param viewR defines the right View matrix to use (if provided)
  109465. * @param projectionR defines the right Projection matrix to use (if provided)
  109466. */
  109467. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109468. /**
  109469. * Gets the uniform buffer used to store scene data
  109470. * @returns a UniformBuffer
  109471. */
  109472. getSceneUniformBuffer(): UniformBuffer;
  109473. /**
  109474. * Gets an unique (relatively to the current scene) Id
  109475. * @returns an unique number for the scene
  109476. */
  109477. getUniqueId(): number;
  109478. /**
  109479. * Add a mesh to the list of scene's meshes
  109480. * @param newMesh defines the mesh to add
  109481. * @param recursive if all child meshes should also be added to the scene
  109482. */
  109483. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109484. /**
  109485. * Remove a mesh for the list of scene's meshes
  109486. * @param toRemove defines the mesh to remove
  109487. * @param recursive if all child meshes should also be removed from the scene
  109488. * @returns the index where the mesh was in the mesh list
  109489. */
  109490. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109491. /**
  109492. * Add a transform node to the list of scene's transform nodes
  109493. * @param newTransformNode defines the transform node to add
  109494. */
  109495. addTransformNode(newTransformNode: TransformNode): void;
  109496. /**
  109497. * Remove a transform node for the list of scene's transform nodes
  109498. * @param toRemove defines the transform node to remove
  109499. * @returns the index where the transform node was in the transform node list
  109500. */
  109501. removeTransformNode(toRemove: TransformNode): number;
  109502. /**
  109503. * Remove a skeleton for the list of scene's skeletons
  109504. * @param toRemove defines the skeleton to remove
  109505. * @returns the index where the skeleton was in the skeleton list
  109506. */
  109507. removeSkeleton(toRemove: Skeleton): number;
  109508. /**
  109509. * Remove a morph target for the list of scene's morph targets
  109510. * @param toRemove defines the morph target to remove
  109511. * @returns the index where the morph target was in the morph target list
  109512. */
  109513. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109514. /**
  109515. * Remove a light for the list of scene's lights
  109516. * @param toRemove defines the light to remove
  109517. * @returns the index where the light was in the light list
  109518. */
  109519. removeLight(toRemove: Light): number;
  109520. /**
  109521. * Remove a camera for the list of scene's cameras
  109522. * @param toRemove defines the camera to remove
  109523. * @returns the index where the camera was in the camera list
  109524. */
  109525. removeCamera(toRemove: Camera): number;
  109526. /**
  109527. * Remove a particle system for the list of scene's particle systems
  109528. * @param toRemove defines the particle system to remove
  109529. * @returns the index where the particle system was in the particle system list
  109530. */
  109531. removeParticleSystem(toRemove: IParticleSystem): number;
  109532. /**
  109533. * Remove a animation for the list of scene's animations
  109534. * @param toRemove defines the animation to remove
  109535. * @returns the index where the animation was in the animation list
  109536. */
  109537. removeAnimation(toRemove: Animation): number;
  109538. /**
  109539. * Will stop the animation of the given target
  109540. * @param target - the target
  109541. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109542. * @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)
  109543. */
  109544. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109545. /**
  109546. * Removes the given animation group from this scene.
  109547. * @param toRemove The animation group to remove
  109548. * @returns The index of the removed animation group
  109549. */
  109550. removeAnimationGroup(toRemove: AnimationGroup): number;
  109551. /**
  109552. * Removes the given multi-material from this scene.
  109553. * @param toRemove The multi-material to remove
  109554. * @returns The index of the removed multi-material
  109555. */
  109556. removeMultiMaterial(toRemove: MultiMaterial): number;
  109557. /**
  109558. * Removes the given material from this scene.
  109559. * @param toRemove The material to remove
  109560. * @returns The index of the removed material
  109561. */
  109562. removeMaterial(toRemove: Material): number;
  109563. /**
  109564. * Removes the given action manager from this scene.
  109565. * @param toRemove The action manager to remove
  109566. * @returns The index of the removed action manager
  109567. */
  109568. removeActionManager(toRemove: AbstractActionManager): number;
  109569. /**
  109570. * Removes the given texture from this scene.
  109571. * @param toRemove The texture to remove
  109572. * @returns The index of the removed texture
  109573. */
  109574. removeTexture(toRemove: BaseTexture): number;
  109575. /**
  109576. * Adds the given light to this scene
  109577. * @param newLight The light to add
  109578. */
  109579. addLight(newLight: Light): void;
  109580. /**
  109581. * Sorts the list list based on light priorities
  109582. */
  109583. sortLightsByPriority(): void;
  109584. /**
  109585. * Adds the given camera to this scene
  109586. * @param newCamera The camera to add
  109587. */
  109588. addCamera(newCamera: Camera): void;
  109589. /**
  109590. * Adds the given skeleton to this scene
  109591. * @param newSkeleton The skeleton to add
  109592. */
  109593. addSkeleton(newSkeleton: Skeleton): void;
  109594. /**
  109595. * Adds the given particle system to this scene
  109596. * @param newParticleSystem The particle system to add
  109597. */
  109598. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109599. /**
  109600. * Adds the given animation to this scene
  109601. * @param newAnimation The animation to add
  109602. */
  109603. addAnimation(newAnimation: Animation): void;
  109604. /**
  109605. * Adds the given animation group to this scene.
  109606. * @param newAnimationGroup The animation group to add
  109607. */
  109608. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109609. /**
  109610. * Adds the given multi-material to this scene
  109611. * @param newMultiMaterial The multi-material to add
  109612. */
  109613. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109614. /**
  109615. * Adds the given material to this scene
  109616. * @param newMaterial The material to add
  109617. */
  109618. addMaterial(newMaterial: Material): void;
  109619. /**
  109620. * Adds the given morph target to this scene
  109621. * @param newMorphTargetManager The morph target to add
  109622. */
  109623. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109624. /**
  109625. * Adds the given geometry to this scene
  109626. * @param newGeometry The geometry to add
  109627. */
  109628. addGeometry(newGeometry: Geometry): void;
  109629. /**
  109630. * Adds the given action manager to this scene
  109631. * @param newActionManager The action manager to add
  109632. */
  109633. addActionManager(newActionManager: AbstractActionManager): void;
  109634. /**
  109635. * Adds the given texture to this scene.
  109636. * @param newTexture The texture to add
  109637. */
  109638. addTexture(newTexture: BaseTexture): void;
  109639. /**
  109640. * Switch active camera
  109641. * @param newCamera defines the new active camera
  109642. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109643. */
  109644. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109645. /**
  109646. * sets the active camera of the scene using its ID
  109647. * @param id defines the camera's ID
  109648. * @return the new active camera or null if none found.
  109649. */
  109650. setActiveCameraByID(id: string): Nullable<Camera>;
  109651. /**
  109652. * sets the active camera of the scene using its name
  109653. * @param name defines the camera's name
  109654. * @returns the new active camera or null if none found.
  109655. */
  109656. setActiveCameraByName(name: string): Nullable<Camera>;
  109657. /**
  109658. * get an animation group using its name
  109659. * @param name defines the material's name
  109660. * @return the animation group or null if none found.
  109661. */
  109662. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109663. /**
  109664. * Get a material using its unique id
  109665. * @param uniqueId defines the material's unique id
  109666. * @return the material or null if none found.
  109667. */
  109668. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109669. /**
  109670. * get a material using its id
  109671. * @param id defines the material's ID
  109672. * @return the material or null if none found.
  109673. */
  109674. getMaterialByID(id: string): Nullable<Material>;
  109675. /**
  109676. * Gets a the last added material using a given id
  109677. * @param id defines the material's ID
  109678. * @return the last material with the given id or null if none found.
  109679. */
  109680. getLastMaterialByID(id: string): Nullable<Material>;
  109681. /**
  109682. * Gets a material using its name
  109683. * @param name defines the material's name
  109684. * @return the material or null if none found.
  109685. */
  109686. getMaterialByName(name: string): Nullable<Material>;
  109687. /**
  109688. * Get a texture using its unique id
  109689. * @param uniqueId defines the texture's unique id
  109690. * @return the texture or null if none found.
  109691. */
  109692. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109693. /**
  109694. * Gets a camera using its id
  109695. * @param id defines the id to look for
  109696. * @returns the camera or null if not found
  109697. */
  109698. getCameraByID(id: string): Nullable<Camera>;
  109699. /**
  109700. * Gets a camera using its unique id
  109701. * @param uniqueId defines the unique id to look for
  109702. * @returns the camera or null if not found
  109703. */
  109704. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109705. /**
  109706. * Gets a camera using its name
  109707. * @param name defines the camera's name
  109708. * @return the camera or null if none found.
  109709. */
  109710. getCameraByName(name: string): Nullable<Camera>;
  109711. /**
  109712. * Gets a bone using its id
  109713. * @param id defines the bone's id
  109714. * @return the bone or null if not found
  109715. */
  109716. getBoneByID(id: string): Nullable<Bone>;
  109717. /**
  109718. * Gets a bone using its id
  109719. * @param name defines the bone's name
  109720. * @return the bone or null if not found
  109721. */
  109722. getBoneByName(name: string): Nullable<Bone>;
  109723. /**
  109724. * Gets a light node using its name
  109725. * @param name defines the the light's name
  109726. * @return the light or null if none found.
  109727. */
  109728. getLightByName(name: string): Nullable<Light>;
  109729. /**
  109730. * Gets a light node using its id
  109731. * @param id defines the light's id
  109732. * @return the light or null if none found.
  109733. */
  109734. getLightByID(id: string): Nullable<Light>;
  109735. /**
  109736. * Gets a light node using its scene-generated unique ID
  109737. * @param uniqueId defines the light's unique id
  109738. * @return the light or null if none found.
  109739. */
  109740. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109741. /**
  109742. * Gets a particle system by id
  109743. * @param id defines the particle system id
  109744. * @return the corresponding system or null if none found
  109745. */
  109746. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109747. /**
  109748. * Gets a geometry using its ID
  109749. * @param id defines the geometry's id
  109750. * @return the geometry or null if none found.
  109751. */
  109752. getGeometryByID(id: string): Nullable<Geometry>;
  109753. private _getGeometryByUniqueID;
  109754. /**
  109755. * Add a new geometry to this scene
  109756. * @param geometry defines the geometry to be added to the scene.
  109757. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109758. * @return a boolean defining if the geometry was added or not
  109759. */
  109760. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109761. /**
  109762. * Removes an existing geometry
  109763. * @param geometry defines the geometry to be removed from the scene
  109764. * @return a boolean defining if the geometry was removed or not
  109765. */
  109766. removeGeometry(geometry: Geometry): boolean;
  109767. /**
  109768. * Gets the list of geometries attached to the scene
  109769. * @returns an array of Geometry
  109770. */
  109771. getGeometries(): Geometry[];
  109772. /**
  109773. * Gets the first added mesh found of a given ID
  109774. * @param id defines the id to search for
  109775. * @return the mesh found or null if not found at all
  109776. */
  109777. getMeshByID(id: string): Nullable<AbstractMesh>;
  109778. /**
  109779. * Gets a list of meshes using their id
  109780. * @param id defines the id to search for
  109781. * @returns a list of meshes
  109782. */
  109783. getMeshesByID(id: string): Array<AbstractMesh>;
  109784. /**
  109785. * Gets the first added transform node found of a given ID
  109786. * @param id defines the id to search for
  109787. * @return the found transform node or null if not found at all.
  109788. */
  109789. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109790. /**
  109791. * Gets a transform node with its auto-generated unique id
  109792. * @param uniqueId efines the unique id to search for
  109793. * @return the found transform node or null if not found at all.
  109794. */
  109795. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109796. /**
  109797. * Gets a list of transform nodes using their id
  109798. * @param id defines the id to search for
  109799. * @returns a list of transform nodes
  109800. */
  109801. getTransformNodesByID(id: string): Array<TransformNode>;
  109802. /**
  109803. * Gets a mesh with its auto-generated unique id
  109804. * @param uniqueId defines the unique id to search for
  109805. * @return the found mesh or null if not found at all.
  109806. */
  109807. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109808. /**
  109809. * Gets a the last added mesh using a given id
  109810. * @param id defines the id to search for
  109811. * @return the found mesh or null if not found at all.
  109812. */
  109813. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109814. /**
  109815. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109816. * @param id defines the id to search for
  109817. * @return the found node or null if not found at all
  109818. */
  109819. getLastEntryByID(id: string): Nullable<Node>;
  109820. /**
  109821. * Gets a node (Mesh, Camera, Light) using a given id
  109822. * @param id defines the id to search for
  109823. * @return the found node or null if not found at all
  109824. */
  109825. getNodeByID(id: string): Nullable<Node>;
  109826. /**
  109827. * Gets a node (Mesh, Camera, Light) using a given name
  109828. * @param name defines the name to search for
  109829. * @return the found node or null if not found at all.
  109830. */
  109831. getNodeByName(name: string): Nullable<Node>;
  109832. /**
  109833. * Gets a mesh using a given name
  109834. * @param name defines the name to search for
  109835. * @return the found mesh or null if not found at all.
  109836. */
  109837. getMeshByName(name: string): Nullable<AbstractMesh>;
  109838. /**
  109839. * Gets a transform node using a given name
  109840. * @param name defines the name to search for
  109841. * @return the found transform node or null if not found at all.
  109842. */
  109843. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109844. /**
  109845. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109846. * @param id defines the id to search for
  109847. * @return the found skeleton or null if not found at all.
  109848. */
  109849. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109850. /**
  109851. * Gets a skeleton using a given auto generated unique id
  109852. * @param uniqueId defines the unique id to search for
  109853. * @return the found skeleton or null if not found at all.
  109854. */
  109855. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109856. /**
  109857. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109858. * @param id defines the id to search for
  109859. * @return the found skeleton or null if not found at all.
  109860. */
  109861. getSkeletonById(id: string): Nullable<Skeleton>;
  109862. /**
  109863. * Gets a skeleton using a given name
  109864. * @param name defines the name to search for
  109865. * @return the found skeleton or null if not found at all.
  109866. */
  109867. getSkeletonByName(name: string): Nullable<Skeleton>;
  109868. /**
  109869. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109870. * @param id defines the id to search for
  109871. * @return the found morph target manager or null if not found at all.
  109872. */
  109873. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109874. /**
  109875. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109876. * @param id defines the id to search for
  109877. * @return the found morph target or null if not found at all.
  109878. */
  109879. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109880. /**
  109881. * Gets a boolean indicating if the given mesh is active
  109882. * @param mesh defines the mesh to look for
  109883. * @returns true if the mesh is in the active list
  109884. */
  109885. isActiveMesh(mesh: AbstractMesh): boolean;
  109886. /**
  109887. * Return a unique id as a string which can serve as an identifier for the scene
  109888. */
  109889. get uid(): string;
  109890. /**
  109891. * Add an externaly attached data from its key.
  109892. * This method call will fail and return false, if such key already exists.
  109893. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109894. * @param key the unique key that identifies the data
  109895. * @param data the data object to associate to the key for this Engine instance
  109896. * @return true if no such key were already present and the data was added successfully, false otherwise
  109897. */
  109898. addExternalData<T>(key: string, data: T): boolean;
  109899. /**
  109900. * Get an externaly attached data from its key
  109901. * @param key the unique key that identifies the data
  109902. * @return the associated data, if present (can be null), or undefined if not present
  109903. */
  109904. getExternalData<T>(key: string): Nullable<T>;
  109905. /**
  109906. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109907. * @param key the unique key that identifies the data
  109908. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109909. * @return the associated data, can be null if the factory returned null.
  109910. */
  109911. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109912. /**
  109913. * Remove an externaly attached data from the Engine instance
  109914. * @param key the unique key that identifies the data
  109915. * @return true if the data was successfully removed, false if it doesn't exist
  109916. */
  109917. removeExternalData(key: string): boolean;
  109918. private _evaluateSubMesh;
  109919. /**
  109920. * Clear the processed materials smart array preventing retention point in material dispose.
  109921. */
  109922. freeProcessedMaterials(): void;
  109923. private _preventFreeActiveMeshesAndRenderingGroups;
  109924. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109925. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109926. * when disposing several meshes in a row or a hierarchy of meshes.
  109927. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109928. */
  109929. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109930. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109931. /**
  109932. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109933. */
  109934. freeActiveMeshes(): void;
  109935. /**
  109936. * Clear the info related to rendering groups preventing retention points during dispose.
  109937. */
  109938. freeRenderingGroups(): void;
  109939. /** @hidden */
  109940. _isInIntermediateRendering(): boolean;
  109941. /**
  109942. * Lambda returning the list of potentially active meshes.
  109943. */
  109944. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109945. /**
  109946. * Lambda returning the list of potentially active sub meshes.
  109947. */
  109948. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109949. /**
  109950. * Lambda returning the list of potentially intersecting sub meshes.
  109951. */
  109952. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109953. /**
  109954. * Lambda returning the list of potentially colliding sub meshes.
  109955. */
  109956. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109957. private _activeMeshesFrozen;
  109958. private _skipEvaluateActiveMeshesCompletely;
  109959. /**
  109960. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109961. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109962. * @returns the current scene
  109963. */
  109964. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109965. /**
  109966. * Use this function to restart evaluating active meshes on every frame
  109967. * @returns the current scene
  109968. */
  109969. unfreezeActiveMeshes(): Scene;
  109970. private _evaluateActiveMeshes;
  109971. private _activeMesh;
  109972. /**
  109973. * Update the transform matrix to update from the current active camera
  109974. * @param force defines a boolean used to force the update even if cache is up to date
  109975. */
  109976. updateTransformMatrix(force?: boolean): void;
  109977. private _bindFrameBuffer;
  109978. /** @hidden */
  109979. _allowPostProcessClearColor: boolean;
  109980. /** @hidden */
  109981. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109982. private _processSubCameras;
  109983. private _checkIntersections;
  109984. /** @hidden */
  109985. _advancePhysicsEngineStep(step: number): void;
  109986. /**
  109987. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109988. */
  109989. getDeterministicFrameTime: () => number;
  109990. /** @hidden */
  109991. _animate(): void;
  109992. /** Execute all animations (for a frame) */
  109993. animate(): void;
  109994. /**
  109995. * Render the scene
  109996. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109997. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109998. */
  109999. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  110000. /**
  110001. * Freeze all materials
  110002. * A frozen material will not be updatable but should be faster to render
  110003. */
  110004. freezeMaterials(): void;
  110005. /**
  110006. * Unfreeze all materials
  110007. * A frozen material will not be updatable but should be faster to render
  110008. */
  110009. unfreezeMaterials(): void;
  110010. /**
  110011. * Releases all held ressources
  110012. */
  110013. dispose(): void;
  110014. /**
  110015. * Gets if the scene is already disposed
  110016. */
  110017. get isDisposed(): boolean;
  110018. /**
  110019. * Call this function to reduce memory footprint of the scene.
  110020. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110021. */
  110022. clearCachedVertexData(): void;
  110023. /**
  110024. * This function will remove the local cached buffer data from texture.
  110025. * It will save memory but will prevent the texture from being rebuilt
  110026. */
  110027. cleanCachedTextureBuffer(): void;
  110028. /**
  110029. * Get the world extend vectors with an optional filter
  110030. *
  110031. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110032. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110033. */
  110034. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110035. min: Vector3;
  110036. max: Vector3;
  110037. };
  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 world defines the world matrix to use if you want to pick in object space (instead of world space)
  110043. * @param camera defines the camera to use for the picking
  110044. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110045. * @returns a Ray
  110046. */
  110047. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110048. /**
  110049. * Creates a ray that can be used to pick in the scene
  110050. * @param x defines the x coordinate of the origin (on-screen)
  110051. * @param y defines the y coordinate of the origin (on-screen)
  110052. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110053. * @param result defines the ray where to store the picking ray
  110054. * @param camera defines the camera to use for the picking
  110055. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110056. * @returns the current scene
  110057. */
  110058. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110059. /**
  110060. * Creates a ray that can be used to pick in the scene
  110061. * @param x defines the x coordinate of the origin (on-screen)
  110062. * @param y defines the y coordinate of the origin (on-screen)
  110063. * @param camera defines the camera to use for the picking
  110064. * @returns a Ray
  110065. */
  110066. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110067. /**
  110068. * Creates a ray that can be used to pick in the scene
  110069. * @param x defines the x coordinate of the origin (on-screen)
  110070. * @param y defines the y coordinate of the origin (on-screen)
  110071. * @param result defines the ray where to store the picking ray
  110072. * @param camera defines the camera to use for the picking
  110073. * @returns the current scene
  110074. */
  110075. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110076. /** Launch a ray to try to pick a mesh in the scene
  110077. * @param x position on screen
  110078. * @param y position on screen
  110079. * @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
  110080. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110081. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110082. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110083. * @returns a PickingInfo
  110084. */
  110085. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110086. /** Use the given ray to pick a mesh in the scene
  110087. * @param ray The ray to use to pick meshes
  110088. * @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
  110089. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110090. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110091. * @returns a PickingInfo
  110092. */
  110093. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110094. /**
  110095. * Launch a ray to try to pick a mesh in the scene
  110096. * @param x X position on screen
  110097. * @param y Y position on screen
  110098. * @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
  110099. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110100. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110101. * @returns an array of PickingInfo
  110102. */
  110103. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110104. /**
  110105. * Launch a ray to try to pick a mesh in the scene
  110106. * @param ray Ray to use
  110107. * @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
  110108. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110109. * @returns an array of PickingInfo
  110110. */
  110111. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110112. /**
  110113. * Force the value of meshUnderPointer
  110114. * @param mesh defines the mesh to use
  110115. */
  110116. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110117. /**
  110118. * Gets the mesh under the pointer
  110119. * @returns a Mesh or null if no mesh is under the pointer
  110120. */
  110121. getPointerOverMesh(): Nullable<AbstractMesh>;
  110122. /** @hidden */
  110123. _rebuildGeometries(): void;
  110124. /** @hidden */
  110125. _rebuildTextures(): void;
  110126. private _getByTags;
  110127. /**
  110128. * Get a list of meshes 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 Mesh
  110132. */
  110133. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110134. /**
  110135. * Get a list of cameras by tags
  110136. * @param tagsQuery defines the tags query to use
  110137. * @param forEach defines a predicate used to filter results
  110138. * @returns an array of Camera
  110139. */
  110140. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110141. /**
  110142. * Get a list of lights by tags
  110143. * @param tagsQuery defines the tags query to use
  110144. * @param forEach defines a predicate used to filter results
  110145. * @returns an array of Light
  110146. */
  110147. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110148. /**
  110149. * Get a list of materials by tags
  110150. * @param tagsQuery defines the tags query to use
  110151. * @param forEach defines a predicate used to filter results
  110152. * @returns an array of Material
  110153. */
  110154. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110155. /**
  110156. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110157. * This allowed control for front to back rendering or reversly depending of the special needs.
  110158. *
  110159. * @param renderingGroupId The rendering group id corresponding to its index
  110160. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110161. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110162. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110163. */
  110164. 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;
  110165. /**
  110166. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110167. *
  110168. * @param renderingGroupId The rendering group id corresponding to its index
  110169. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110170. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110171. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110172. */
  110173. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110174. /**
  110175. * Gets the current auto clear configuration for one rendering group of the rendering
  110176. * manager.
  110177. * @param index the rendering group index to get the information for
  110178. * @returns The auto clear setup for the requested rendering group
  110179. */
  110180. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110181. private _blockMaterialDirtyMechanism;
  110182. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110183. get blockMaterialDirtyMechanism(): boolean;
  110184. set blockMaterialDirtyMechanism(value: boolean);
  110185. /**
  110186. * Will flag all materials as dirty to trigger new shader compilation
  110187. * @param flag defines the flag used to specify which material part must be marked as dirty
  110188. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110189. */
  110190. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110191. /** @hidden */
  110192. _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;
  110193. /** @hidden */
  110194. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110195. /** @hidden */
  110196. _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;
  110197. /** @hidden */
  110198. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110199. /** @hidden */
  110200. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110201. /** @hidden */
  110202. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110203. }
  110204. }
  110205. declare module BABYLON {
  110206. /**
  110207. * Set of assets to keep when moving a scene into an asset container.
  110208. */
  110209. export class KeepAssets extends AbstractScene {
  110210. }
  110211. /**
  110212. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110213. */
  110214. export class InstantiatedEntries {
  110215. /**
  110216. * List of new root nodes (eg. nodes with no parent)
  110217. */
  110218. rootNodes: TransformNode[];
  110219. /**
  110220. * List of new skeletons
  110221. */
  110222. skeletons: Skeleton[];
  110223. /**
  110224. * List of new animation groups
  110225. */
  110226. animationGroups: AnimationGroup[];
  110227. }
  110228. /**
  110229. * Container with a set of assets that can be added or removed from a scene.
  110230. */
  110231. export class AssetContainer extends AbstractScene {
  110232. private _wasAddedToScene;
  110233. /**
  110234. * The scene the AssetContainer belongs to.
  110235. */
  110236. scene: Scene;
  110237. /**
  110238. * Instantiates an AssetContainer.
  110239. * @param scene The scene the AssetContainer belongs to.
  110240. */
  110241. constructor(scene: Scene);
  110242. /**
  110243. * Instantiate or clone all meshes and add the new ones to the scene.
  110244. * Skeletons and animation groups will all be cloned
  110245. * @param nameFunction defines an optional function used to get new names for clones
  110246. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110247. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110248. */
  110249. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110250. /**
  110251. * Adds all the assets from the container to the scene.
  110252. */
  110253. addAllToScene(): void;
  110254. /**
  110255. * Removes all the assets in the container from the scene
  110256. */
  110257. removeAllFromScene(): void;
  110258. /**
  110259. * Disposes all the assets in the container
  110260. */
  110261. dispose(): void;
  110262. private _moveAssets;
  110263. /**
  110264. * Removes all the assets contained in the scene and adds them to the container.
  110265. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110266. */
  110267. moveAllFromScene(keepAssets?: KeepAssets): void;
  110268. /**
  110269. * 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.
  110270. * @returns the root mesh
  110271. */
  110272. createRootMesh(): Mesh;
  110273. /**
  110274. * Merge animations from this asset container into a scene
  110275. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110276. * @param animatables set of animatables to retarget to a node from the scene
  110277. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110278. */
  110279. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110280. }
  110281. }
  110282. declare module BABYLON {
  110283. /**
  110284. * Defines how the parser contract is defined.
  110285. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110286. */
  110287. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110288. /**
  110289. * Defines how the individual parser contract is defined.
  110290. * These parser can parse an individual asset
  110291. */
  110292. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110293. /**
  110294. * Base class of the scene acting as a container for the different elements composing a scene.
  110295. * This class is dynamically extended by the different components of the scene increasing
  110296. * flexibility and reducing coupling
  110297. */
  110298. export abstract class AbstractScene {
  110299. /**
  110300. * Stores the list of available parsers in the application.
  110301. */
  110302. private static _BabylonFileParsers;
  110303. /**
  110304. * Stores the list of available individual parsers in the application.
  110305. */
  110306. private static _IndividualBabylonFileParsers;
  110307. /**
  110308. * Adds a parser in the list of available ones
  110309. * @param name Defines the name of the parser
  110310. * @param parser Defines the parser to add
  110311. */
  110312. static AddParser(name: string, parser: BabylonFileParser): void;
  110313. /**
  110314. * Gets a general parser from the list of avaialble ones
  110315. * @param name Defines the name of the parser
  110316. * @returns the requested parser or null
  110317. */
  110318. static GetParser(name: string): Nullable<BabylonFileParser>;
  110319. /**
  110320. * Adds n individual parser in the list of available ones
  110321. * @param name Defines the name of the parser
  110322. * @param parser Defines the parser to add
  110323. */
  110324. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110325. /**
  110326. * Gets an individual parser from the list of avaialble ones
  110327. * @param name Defines the name of the parser
  110328. * @returns the requested parser or null
  110329. */
  110330. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110331. /**
  110332. * Parser json data and populate both a scene and its associated container object
  110333. * @param jsonData Defines the data to parse
  110334. * @param scene Defines the scene to parse the data for
  110335. * @param container Defines the container attached to the parsing sequence
  110336. * @param rootUrl Defines the root url of the data
  110337. */
  110338. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110339. /**
  110340. * Gets the list of root nodes (ie. nodes with no parent)
  110341. */
  110342. rootNodes: Node[];
  110343. /** All of the cameras added to this scene
  110344. * @see http://doc.babylonjs.com/babylon101/cameras
  110345. */
  110346. cameras: Camera[];
  110347. /**
  110348. * All of the lights added to this scene
  110349. * @see http://doc.babylonjs.com/babylon101/lights
  110350. */
  110351. lights: Light[];
  110352. /**
  110353. * All of the (abstract) meshes added to this scene
  110354. */
  110355. meshes: AbstractMesh[];
  110356. /**
  110357. * The list of skeletons added to the scene
  110358. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110359. */
  110360. skeletons: Skeleton[];
  110361. /**
  110362. * All of the particle systems added to this scene
  110363. * @see http://doc.babylonjs.com/babylon101/particles
  110364. */
  110365. particleSystems: IParticleSystem[];
  110366. /**
  110367. * Gets a list of Animations associated with the scene
  110368. */
  110369. animations: Animation[];
  110370. /**
  110371. * All of the animation groups added to this scene
  110372. * @see http://doc.babylonjs.com/how_to/group
  110373. */
  110374. animationGroups: AnimationGroup[];
  110375. /**
  110376. * All of the multi-materials added to this scene
  110377. * @see http://doc.babylonjs.com/how_to/multi_materials
  110378. */
  110379. multiMaterials: MultiMaterial[];
  110380. /**
  110381. * All of the materials added to this scene
  110382. * In the context of a Scene, it is not supposed to be modified manually.
  110383. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110384. * Note also that the order of the Material within the array is not significant and might change.
  110385. * @see http://doc.babylonjs.com/babylon101/materials
  110386. */
  110387. materials: Material[];
  110388. /**
  110389. * The list of morph target managers added to the scene
  110390. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110391. */
  110392. morphTargetManagers: MorphTargetManager[];
  110393. /**
  110394. * The list of geometries used in the scene.
  110395. */
  110396. geometries: Geometry[];
  110397. /**
  110398. * All of the tranform nodes added to this scene
  110399. * In the context of a Scene, it is not supposed to be modified manually.
  110400. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110401. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110402. * @see http://doc.babylonjs.com/how_to/transformnode
  110403. */
  110404. transformNodes: TransformNode[];
  110405. /**
  110406. * ActionManagers available on the scene.
  110407. */
  110408. actionManagers: AbstractActionManager[];
  110409. /**
  110410. * Textures to keep.
  110411. */
  110412. textures: BaseTexture[];
  110413. /**
  110414. * Environment texture for the scene
  110415. */
  110416. environmentTexture: Nullable<BaseTexture>;
  110417. /**
  110418. * @returns all meshes, lights, cameras, transformNodes and bones
  110419. */
  110420. getNodes(): Array<Node>;
  110421. }
  110422. }
  110423. declare module BABYLON {
  110424. /**
  110425. * Interface used to define options for Sound class
  110426. */
  110427. export interface ISoundOptions {
  110428. /**
  110429. * Does the sound autoplay once loaded.
  110430. */
  110431. autoplay?: boolean;
  110432. /**
  110433. * Does the sound loop after it finishes playing once.
  110434. */
  110435. loop?: boolean;
  110436. /**
  110437. * Sound's volume
  110438. */
  110439. volume?: number;
  110440. /**
  110441. * Is it a spatial sound?
  110442. */
  110443. spatialSound?: boolean;
  110444. /**
  110445. * Maximum distance to hear that sound
  110446. */
  110447. maxDistance?: number;
  110448. /**
  110449. * Uses user defined attenuation function
  110450. */
  110451. useCustomAttenuation?: boolean;
  110452. /**
  110453. * Define the roll off factor of spatial sounds.
  110454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110455. */
  110456. rolloffFactor?: number;
  110457. /**
  110458. * Define the reference distance the sound should be heard perfectly.
  110459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110460. */
  110461. refDistance?: number;
  110462. /**
  110463. * Define the distance attenuation model the sound will follow.
  110464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110465. */
  110466. distanceModel?: string;
  110467. /**
  110468. * Defines the playback speed (1 by default)
  110469. */
  110470. playbackRate?: number;
  110471. /**
  110472. * Defines if the sound is from a streaming source
  110473. */
  110474. streaming?: boolean;
  110475. /**
  110476. * Defines an optional length (in seconds) inside the sound file
  110477. */
  110478. length?: number;
  110479. /**
  110480. * Defines an optional offset (in seconds) inside the sound file
  110481. */
  110482. offset?: number;
  110483. /**
  110484. * If true, URLs will not be required to state the audio file codec to use.
  110485. */
  110486. skipCodecCheck?: boolean;
  110487. }
  110488. /**
  110489. * Defines a sound that can be played in the application.
  110490. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110491. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110492. */
  110493. export class Sound {
  110494. /**
  110495. * The name of the sound in the scene.
  110496. */
  110497. name: string;
  110498. /**
  110499. * Does the sound autoplay once loaded.
  110500. */
  110501. autoplay: boolean;
  110502. /**
  110503. * Does the sound loop after it finishes playing once.
  110504. */
  110505. loop: boolean;
  110506. /**
  110507. * Does the sound use a custom attenuation curve to simulate the falloff
  110508. * happening when the source gets further away from the camera.
  110509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110510. */
  110511. useCustomAttenuation: boolean;
  110512. /**
  110513. * The sound track id this sound belongs to.
  110514. */
  110515. soundTrackId: number;
  110516. /**
  110517. * Is this sound currently played.
  110518. */
  110519. isPlaying: boolean;
  110520. /**
  110521. * Is this sound currently paused.
  110522. */
  110523. isPaused: boolean;
  110524. /**
  110525. * Does this sound enables spatial sound.
  110526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110527. */
  110528. spatialSound: boolean;
  110529. /**
  110530. * Define the reference distance the sound should be heard perfectly.
  110531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110532. */
  110533. refDistance: number;
  110534. /**
  110535. * Define the roll off factor of spatial sounds.
  110536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110537. */
  110538. rolloffFactor: number;
  110539. /**
  110540. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110542. */
  110543. maxDistance: number;
  110544. /**
  110545. * Define the distance attenuation model the sound will follow.
  110546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110547. */
  110548. distanceModel: string;
  110549. /**
  110550. * @hidden
  110551. * Back Compat
  110552. **/
  110553. onended: () => any;
  110554. /**
  110555. * Observable event when the current playing sound finishes.
  110556. */
  110557. onEndedObservable: Observable<Sound>;
  110558. private _panningModel;
  110559. private _playbackRate;
  110560. private _streaming;
  110561. private _startTime;
  110562. private _startOffset;
  110563. private _position;
  110564. /** @hidden */
  110565. _positionInEmitterSpace: boolean;
  110566. private _localDirection;
  110567. private _volume;
  110568. private _isReadyToPlay;
  110569. private _isDirectional;
  110570. private _readyToPlayCallback;
  110571. private _audioBuffer;
  110572. private _soundSource;
  110573. private _streamingSource;
  110574. private _soundPanner;
  110575. private _soundGain;
  110576. private _inputAudioNode;
  110577. private _outputAudioNode;
  110578. private _coneInnerAngle;
  110579. private _coneOuterAngle;
  110580. private _coneOuterGain;
  110581. private _scene;
  110582. private _connectedTransformNode;
  110583. private _customAttenuationFunction;
  110584. private _registerFunc;
  110585. private _isOutputConnected;
  110586. private _htmlAudioElement;
  110587. private _urlType;
  110588. private _length?;
  110589. private _offset?;
  110590. /** @hidden */
  110591. static _SceneComponentInitialization: (scene: Scene) => void;
  110592. /**
  110593. * Create a sound and attach it to a scene
  110594. * @param name Name of your sound
  110595. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110596. * @param scene defines the scene the sound belongs to
  110597. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110598. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110599. */
  110600. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110601. /**
  110602. * Release the sound and its associated resources
  110603. */
  110604. dispose(): void;
  110605. /**
  110606. * Gets if the sounds is ready to be played or not.
  110607. * @returns true if ready, otherwise false
  110608. */
  110609. isReady(): boolean;
  110610. private _soundLoaded;
  110611. /**
  110612. * Sets the data of the sound from an audiobuffer
  110613. * @param audioBuffer The audioBuffer containing the data
  110614. */
  110615. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110616. /**
  110617. * Updates the current sounds options such as maxdistance, loop...
  110618. * @param options A JSON object containing values named as the object properties
  110619. */
  110620. updateOptions(options: ISoundOptions): void;
  110621. private _createSpatialParameters;
  110622. private _updateSpatialParameters;
  110623. /**
  110624. * Switch the panning model to HRTF:
  110625. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110627. */
  110628. switchPanningModelToHRTF(): void;
  110629. /**
  110630. * Switch the panning model to Equal Power:
  110631. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110633. */
  110634. switchPanningModelToEqualPower(): void;
  110635. private _switchPanningModel;
  110636. /**
  110637. * Connect this sound to a sound track audio node like gain...
  110638. * @param soundTrackAudioNode the sound track audio node to connect to
  110639. */
  110640. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110641. /**
  110642. * Transform this sound into a directional source
  110643. * @param coneInnerAngle Size of the inner cone in degree
  110644. * @param coneOuterAngle Size of the outer cone in degree
  110645. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110646. */
  110647. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110648. /**
  110649. * Gets or sets the inner angle for the directional cone.
  110650. */
  110651. get directionalConeInnerAngle(): number;
  110652. /**
  110653. * Gets or sets the inner angle for the directional cone.
  110654. */
  110655. set directionalConeInnerAngle(value: number);
  110656. /**
  110657. * Gets or sets the outer angle for the directional cone.
  110658. */
  110659. get directionalConeOuterAngle(): number;
  110660. /**
  110661. * Gets or sets the outer angle for the directional cone.
  110662. */
  110663. set directionalConeOuterAngle(value: number);
  110664. /**
  110665. * Sets the position of the emitter if spatial sound is enabled
  110666. * @param newPosition Defines the new posisiton
  110667. */
  110668. setPosition(newPosition: Vector3): void;
  110669. /**
  110670. * Sets the local direction of the emitter if spatial sound is enabled
  110671. * @param newLocalDirection Defines the new local direction
  110672. */
  110673. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110674. private _updateDirection;
  110675. /** @hidden */
  110676. updateDistanceFromListener(): void;
  110677. /**
  110678. * Sets a new custom attenuation function for the sound.
  110679. * @param callback Defines the function used for the attenuation
  110680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110681. */
  110682. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110683. /**
  110684. * Play the sound
  110685. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110686. * @param offset (optional) Start the sound at a specific time in seconds
  110687. * @param length (optional) Sound duration (in seconds)
  110688. */
  110689. play(time?: number, offset?: number, length?: number): void;
  110690. private _onended;
  110691. /**
  110692. * Stop the sound
  110693. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110694. */
  110695. stop(time?: number): void;
  110696. /**
  110697. * Put the sound in pause
  110698. */
  110699. pause(): void;
  110700. /**
  110701. * Sets a dedicated volume for this sounds
  110702. * @param newVolume Define the new volume of the sound
  110703. * @param time Define time for gradual change to new volume
  110704. */
  110705. setVolume(newVolume: number, time?: number): void;
  110706. /**
  110707. * Set the sound play back rate
  110708. * @param newPlaybackRate Define the playback rate the sound should be played at
  110709. */
  110710. setPlaybackRate(newPlaybackRate: number): void;
  110711. /**
  110712. * Gets the volume of the sound.
  110713. * @returns the volume of the sound
  110714. */
  110715. getVolume(): number;
  110716. /**
  110717. * Attach the sound to a dedicated mesh
  110718. * @param transformNode The transform node to connect the sound with
  110719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110720. */
  110721. attachToMesh(transformNode: TransformNode): void;
  110722. /**
  110723. * Detach the sound from the previously attached mesh
  110724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110725. */
  110726. detachFromMesh(): void;
  110727. private _onRegisterAfterWorldMatrixUpdate;
  110728. /**
  110729. * Clone the current sound in the scene.
  110730. * @returns the new sound clone
  110731. */
  110732. clone(): Nullable<Sound>;
  110733. /**
  110734. * Gets the current underlying audio buffer containing the data
  110735. * @returns the audio buffer
  110736. */
  110737. getAudioBuffer(): Nullable<AudioBuffer>;
  110738. /**
  110739. * Serializes the Sound in a JSON representation
  110740. * @returns the JSON representation of the sound
  110741. */
  110742. serialize(): any;
  110743. /**
  110744. * Parse a JSON representation of a sound to innstantiate in a given scene
  110745. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110746. * @param scene Define the scene the new parsed sound should be created in
  110747. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110748. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110749. * @returns the newly parsed sound
  110750. */
  110751. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110752. }
  110753. }
  110754. declare module BABYLON {
  110755. /**
  110756. * This defines an action helpful to play a defined sound on a triggered action.
  110757. */
  110758. export class PlaySoundAction extends Action {
  110759. private _sound;
  110760. /**
  110761. * Instantiate the action
  110762. * @param triggerOptions defines the trigger options
  110763. * @param sound defines the sound to play
  110764. * @param condition defines the trigger related conditions
  110765. */
  110766. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110767. /** @hidden */
  110768. _prepare(): void;
  110769. /**
  110770. * Execute the action and play the sound.
  110771. */
  110772. execute(): void;
  110773. /**
  110774. * Serializes the actions and its related information.
  110775. * @param parent defines the object to serialize in
  110776. * @returns the serialized object
  110777. */
  110778. serialize(parent: any): any;
  110779. }
  110780. /**
  110781. * This defines an action helpful to stop a defined sound on a triggered action.
  110782. */
  110783. export class StopSoundAction extends Action {
  110784. private _sound;
  110785. /**
  110786. * Instantiate the action
  110787. * @param triggerOptions defines the trigger options
  110788. * @param sound defines the sound to stop
  110789. * @param condition defines the trigger related conditions
  110790. */
  110791. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110792. /** @hidden */
  110793. _prepare(): void;
  110794. /**
  110795. * Execute the action and stop the sound.
  110796. */
  110797. execute(): void;
  110798. /**
  110799. * Serializes the actions and its related information.
  110800. * @param parent defines the object to serialize in
  110801. * @returns the serialized object
  110802. */
  110803. serialize(parent: any): any;
  110804. }
  110805. }
  110806. declare module BABYLON {
  110807. /**
  110808. * This defines an action responsible to change the value of a property
  110809. * by interpolating between its current value and the newly set one once triggered.
  110810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110811. */
  110812. export class InterpolateValueAction extends Action {
  110813. /**
  110814. * Defines the path of the property where the value should be interpolated
  110815. */
  110816. propertyPath: string;
  110817. /**
  110818. * Defines the target value at the end of the interpolation.
  110819. */
  110820. value: any;
  110821. /**
  110822. * Defines the time it will take for the property to interpolate to the value.
  110823. */
  110824. duration: number;
  110825. /**
  110826. * Defines if the other scene animations should be stopped when the action has been triggered
  110827. */
  110828. stopOtherAnimations?: boolean;
  110829. /**
  110830. * Defines a callback raised once the interpolation animation has been done.
  110831. */
  110832. onInterpolationDone?: () => void;
  110833. /**
  110834. * Observable triggered once the interpolation animation has been done.
  110835. */
  110836. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110837. private _target;
  110838. private _effectiveTarget;
  110839. private _property;
  110840. /**
  110841. * Instantiate the action
  110842. * @param triggerOptions defines the trigger options
  110843. * @param target defines the object containing the value to interpolate
  110844. * @param propertyPath defines the path to the property in the target object
  110845. * @param value defines the target value at the end of the interpolation
  110846. * @param duration deines the time it will take for the property to interpolate to the value.
  110847. * @param condition defines the trigger related conditions
  110848. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110849. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110850. */
  110851. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110852. /** @hidden */
  110853. _prepare(): void;
  110854. /**
  110855. * Execute the action starts the value interpolation.
  110856. */
  110857. execute(): void;
  110858. /**
  110859. * Serializes the actions and its related information.
  110860. * @param parent defines the object to serialize in
  110861. * @returns the serialized object
  110862. */
  110863. serialize(parent: any): any;
  110864. }
  110865. }
  110866. declare module BABYLON {
  110867. /**
  110868. * Options allowed during the creation of a sound track.
  110869. */
  110870. export interface ISoundTrackOptions {
  110871. /**
  110872. * The volume the sound track should take during creation
  110873. */
  110874. volume?: number;
  110875. /**
  110876. * Define if the sound track is the main sound track of the scene
  110877. */
  110878. mainTrack?: boolean;
  110879. }
  110880. /**
  110881. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110882. * It will be also used in a future release to apply effects on a specific track.
  110883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110884. */
  110885. export class SoundTrack {
  110886. /**
  110887. * The unique identifier of the sound track in the scene.
  110888. */
  110889. id: number;
  110890. /**
  110891. * The list of sounds included in the sound track.
  110892. */
  110893. soundCollection: Array<Sound>;
  110894. private _outputAudioNode;
  110895. private _scene;
  110896. private _connectedAnalyser;
  110897. private _options;
  110898. private _isInitialized;
  110899. /**
  110900. * Creates a new sound track.
  110901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110902. * @param scene Define the scene the sound track belongs to
  110903. * @param options
  110904. */
  110905. constructor(scene: Scene, options?: ISoundTrackOptions);
  110906. private _initializeSoundTrackAudioGraph;
  110907. /**
  110908. * Release the sound track and its associated resources
  110909. */
  110910. dispose(): void;
  110911. /**
  110912. * Adds a sound to this sound track
  110913. * @param sound define the cound to add
  110914. * @ignoreNaming
  110915. */
  110916. AddSound(sound: Sound): void;
  110917. /**
  110918. * Removes a sound to this sound track
  110919. * @param sound define the cound to remove
  110920. * @ignoreNaming
  110921. */
  110922. RemoveSound(sound: Sound): void;
  110923. /**
  110924. * Set a global volume for the full sound track.
  110925. * @param newVolume Define the new volume of the sound track
  110926. */
  110927. setVolume(newVolume: number): void;
  110928. /**
  110929. * Switch the panning model to HRTF:
  110930. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110932. */
  110933. switchPanningModelToHRTF(): void;
  110934. /**
  110935. * Switch the panning model to Equal Power:
  110936. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110938. */
  110939. switchPanningModelToEqualPower(): void;
  110940. /**
  110941. * Connect the sound track to an audio analyser allowing some amazing
  110942. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110944. * @param analyser The analyser to connect to the engine
  110945. */
  110946. connectToAnalyser(analyser: Analyser): void;
  110947. }
  110948. }
  110949. declare module BABYLON {
  110950. interface AbstractScene {
  110951. /**
  110952. * The list of sounds used in the scene.
  110953. */
  110954. sounds: Nullable<Array<Sound>>;
  110955. }
  110956. interface Scene {
  110957. /**
  110958. * @hidden
  110959. * Backing field
  110960. */
  110961. _mainSoundTrack: SoundTrack;
  110962. /**
  110963. * The main sound track played by the scene.
  110964. * It cotains your primary collection of sounds.
  110965. */
  110966. mainSoundTrack: SoundTrack;
  110967. /**
  110968. * The list of sound tracks added to the scene
  110969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110970. */
  110971. soundTracks: Nullable<Array<SoundTrack>>;
  110972. /**
  110973. * Gets a sound using a given name
  110974. * @param name defines the name to search for
  110975. * @return the found sound or null if not found at all.
  110976. */
  110977. getSoundByName(name: string): Nullable<Sound>;
  110978. /**
  110979. * Gets or sets if audio support is enabled
  110980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110981. */
  110982. audioEnabled: boolean;
  110983. /**
  110984. * Gets or sets if audio will be output to headphones
  110985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110986. */
  110987. headphone: boolean;
  110988. /**
  110989. * Gets or sets custom audio listener position provider
  110990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110991. */
  110992. audioListenerPositionProvider: Nullable<() => Vector3>;
  110993. /**
  110994. * Gets or sets a refresh rate when using 3D audio positioning
  110995. */
  110996. audioPositioningRefreshRate: number;
  110997. }
  110998. /**
  110999. * Defines the sound scene component responsible to manage any sounds
  111000. * in a given scene.
  111001. */
  111002. export class AudioSceneComponent implements ISceneSerializableComponent {
  111003. /**
  111004. * The component name helpfull to identify the component in the list of scene components.
  111005. */
  111006. readonly name: string;
  111007. /**
  111008. * The scene the component belongs to.
  111009. */
  111010. scene: Scene;
  111011. private _audioEnabled;
  111012. /**
  111013. * Gets whether audio is enabled or not.
  111014. * Please use related enable/disable method to switch state.
  111015. */
  111016. get audioEnabled(): boolean;
  111017. private _headphone;
  111018. /**
  111019. * Gets whether audio is outputing to headphone or not.
  111020. * Please use the according Switch methods to change output.
  111021. */
  111022. get headphone(): boolean;
  111023. /**
  111024. * Gets or sets a refresh rate when using 3D audio positioning
  111025. */
  111026. audioPositioningRefreshRate: number;
  111027. private _audioListenerPositionProvider;
  111028. /**
  111029. * Gets the current audio listener position provider
  111030. */
  111031. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111032. /**
  111033. * Sets a custom listener position for all sounds in the scene
  111034. * By default, this is the position of the first active camera
  111035. */
  111036. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111037. /**
  111038. * Creates a new instance of the component for the given scene
  111039. * @param scene Defines the scene to register the component in
  111040. */
  111041. constructor(scene: Scene);
  111042. /**
  111043. * Registers the component in a given scene
  111044. */
  111045. register(): void;
  111046. /**
  111047. * Rebuilds the elements related to this component in case of
  111048. * context lost for instance.
  111049. */
  111050. rebuild(): void;
  111051. /**
  111052. * Serializes the component data to the specified json object
  111053. * @param serializationObject The object to serialize to
  111054. */
  111055. serialize(serializationObject: any): void;
  111056. /**
  111057. * Adds all the elements from the container to the scene
  111058. * @param container the container holding the elements
  111059. */
  111060. addFromContainer(container: AbstractScene): void;
  111061. /**
  111062. * Removes all the elements in the container from the scene
  111063. * @param container contains the elements to remove
  111064. * @param dispose if the removed element should be disposed (default: false)
  111065. */
  111066. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111067. /**
  111068. * Disposes the component and the associated ressources.
  111069. */
  111070. dispose(): void;
  111071. /**
  111072. * Disables audio in the associated scene.
  111073. */
  111074. disableAudio(): void;
  111075. /**
  111076. * Enables audio in the associated scene.
  111077. */
  111078. enableAudio(): void;
  111079. /**
  111080. * Switch audio to headphone output.
  111081. */
  111082. switchAudioModeForHeadphones(): void;
  111083. /**
  111084. * Switch audio to normal speakers.
  111085. */
  111086. switchAudioModeForNormalSpeakers(): void;
  111087. private _cachedCameraDirection;
  111088. private _cachedCameraPosition;
  111089. private _lastCheck;
  111090. private _afterRender;
  111091. }
  111092. }
  111093. declare module BABYLON {
  111094. /**
  111095. * Wraps one or more Sound objects and selects one with random weight for playback.
  111096. */
  111097. export class WeightedSound {
  111098. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111099. loop: boolean;
  111100. private _coneInnerAngle;
  111101. private _coneOuterAngle;
  111102. private _volume;
  111103. /** A Sound is currently playing. */
  111104. isPlaying: boolean;
  111105. /** A Sound is currently paused. */
  111106. isPaused: boolean;
  111107. private _sounds;
  111108. private _weights;
  111109. private _currentIndex?;
  111110. /**
  111111. * Creates a new WeightedSound from the list of sounds given.
  111112. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111113. * @param sounds Array of Sounds that will be selected from.
  111114. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111115. */
  111116. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111117. /**
  111118. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111119. */
  111120. get directionalConeInnerAngle(): number;
  111121. /**
  111122. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111123. */
  111124. set directionalConeInnerAngle(value: number);
  111125. /**
  111126. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111127. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111128. */
  111129. get directionalConeOuterAngle(): number;
  111130. /**
  111131. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111132. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111133. */
  111134. set directionalConeOuterAngle(value: number);
  111135. /**
  111136. * Playback volume.
  111137. */
  111138. get volume(): number;
  111139. /**
  111140. * Playback volume.
  111141. */
  111142. set volume(value: number);
  111143. private _onended;
  111144. /**
  111145. * Suspend playback
  111146. */
  111147. pause(): void;
  111148. /**
  111149. * Stop playback
  111150. */
  111151. stop(): void;
  111152. /**
  111153. * Start playback.
  111154. * @param startOffset Position the clip head at a specific time in seconds.
  111155. */
  111156. play(startOffset?: number): void;
  111157. }
  111158. }
  111159. declare module BABYLON {
  111160. /**
  111161. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111162. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111163. */
  111164. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111165. /**
  111166. * Gets the name of the behavior.
  111167. */
  111168. get name(): string;
  111169. /**
  111170. * The easing function used by animations
  111171. */
  111172. static EasingFunction: BackEase;
  111173. /**
  111174. * The easing mode used by animations
  111175. */
  111176. static EasingMode: number;
  111177. /**
  111178. * The duration of the animation, in milliseconds
  111179. */
  111180. transitionDuration: number;
  111181. /**
  111182. * Length of the distance animated by the transition when lower radius is reached
  111183. */
  111184. lowerRadiusTransitionRange: number;
  111185. /**
  111186. * Length of the distance animated by the transition when upper radius is reached
  111187. */
  111188. upperRadiusTransitionRange: number;
  111189. private _autoTransitionRange;
  111190. /**
  111191. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111192. */
  111193. get autoTransitionRange(): boolean;
  111194. /**
  111195. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111196. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111197. */
  111198. set autoTransitionRange(value: boolean);
  111199. private _attachedCamera;
  111200. private _onAfterCheckInputsObserver;
  111201. private _onMeshTargetChangedObserver;
  111202. /**
  111203. * Initializes the behavior.
  111204. */
  111205. init(): void;
  111206. /**
  111207. * Attaches the behavior to its arc rotate camera.
  111208. * @param camera Defines the camera to attach the behavior to
  111209. */
  111210. attach(camera: ArcRotateCamera): void;
  111211. /**
  111212. * Detaches the behavior from its current arc rotate camera.
  111213. */
  111214. detach(): void;
  111215. private _radiusIsAnimating;
  111216. private _radiusBounceTransition;
  111217. private _animatables;
  111218. private _cachedWheelPrecision;
  111219. /**
  111220. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111221. * @param radiusLimit The limit to check against.
  111222. * @return Bool to indicate if at limit.
  111223. */
  111224. private _isRadiusAtLimit;
  111225. /**
  111226. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111227. * @param radiusDelta The delta by which to animate to. Can be negative.
  111228. */
  111229. private _applyBoundRadiusAnimation;
  111230. /**
  111231. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111232. */
  111233. protected _clearAnimationLocks(): void;
  111234. /**
  111235. * Stops and removes all animations that have been applied to the camera
  111236. */
  111237. stopAllAnimations(): void;
  111238. }
  111239. }
  111240. declare module BABYLON {
  111241. /**
  111242. * 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.
  111243. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111244. */
  111245. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111246. /**
  111247. * Gets the name of the behavior.
  111248. */
  111249. get name(): string;
  111250. private _mode;
  111251. private _radiusScale;
  111252. private _positionScale;
  111253. private _defaultElevation;
  111254. private _elevationReturnTime;
  111255. private _elevationReturnWaitTime;
  111256. private _zoomStopsAnimation;
  111257. private _framingTime;
  111258. /**
  111259. * The easing function used by animations
  111260. */
  111261. static EasingFunction: ExponentialEase;
  111262. /**
  111263. * The easing mode used by animations
  111264. */
  111265. static EasingMode: number;
  111266. /**
  111267. * Sets the current mode used by the behavior
  111268. */
  111269. set mode(mode: number);
  111270. /**
  111271. * Gets current mode used by the behavior.
  111272. */
  111273. get mode(): number;
  111274. /**
  111275. * Sets the scale applied to the radius (1 by default)
  111276. */
  111277. set radiusScale(radius: number);
  111278. /**
  111279. * Gets the scale applied to the radius
  111280. */
  111281. get radiusScale(): number;
  111282. /**
  111283. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111284. */
  111285. set positionScale(scale: number);
  111286. /**
  111287. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111288. */
  111289. get positionScale(): number;
  111290. /**
  111291. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111292. * behaviour is triggered, in radians.
  111293. */
  111294. set defaultElevation(elevation: number);
  111295. /**
  111296. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111297. * behaviour is triggered, in radians.
  111298. */
  111299. get defaultElevation(): number;
  111300. /**
  111301. * Sets the time (in milliseconds) taken to return to the default beta position.
  111302. * Negative value indicates camera should not return to default.
  111303. */
  111304. set elevationReturnTime(speed: number);
  111305. /**
  111306. * Gets the time (in milliseconds) taken to return to the default beta position.
  111307. * Negative value indicates camera should not return to default.
  111308. */
  111309. get elevationReturnTime(): number;
  111310. /**
  111311. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111312. */
  111313. set elevationReturnWaitTime(time: number);
  111314. /**
  111315. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111316. */
  111317. get elevationReturnWaitTime(): number;
  111318. /**
  111319. * Sets the flag that indicates if user zooming should stop animation.
  111320. */
  111321. set zoomStopsAnimation(flag: boolean);
  111322. /**
  111323. * Gets the flag that indicates if user zooming should stop animation.
  111324. */
  111325. get zoomStopsAnimation(): boolean;
  111326. /**
  111327. * Sets the transition time when framing the mesh, in milliseconds
  111328. */
  111329. set framingTime(time: number);
  111330. /**
  111331. * Gets the transition time when framing the mesh, in milliseconds
  111332. */
  111333. get framingTime(): number;
  111334. /**
  111335. * Define if the behavior should automatically change the configured
  111336. * camera limits and sensibilities.
  111337. */
  111338. autoCorrectCameraLimitsAndSensibility: boolean;
  111339. private _onPrePointerObservableObserver;
  111340. private _onAfterCheckInputsObserver;
  111341. private _onMeshTargetChangedObserver;
  111342. private _attachedCamera;
  111343. private _isPointerDown;
  111344. private _lastInteractionTime;
  111345. /**
  111346. * Initializes the behavior.
  111347. */
  111348. init(): void;
  111349. /**
  111350. * Attaches the behavior to its arc rotate camera.
  111351. * @param camera Defines the camera to attach the behavior to
  111352. */
  111353. attach(camera: ArcRotateCamera): void;
  111354. /**
  111355. * Detaches the behavior from its current arc rotate camera.
  111356. */
  111357. detach(): void;
  111358. private _animatables;
  111359. private _betaIsAnimating;
  111360. private _betaTransition;
  111361. private _radiusTransition;
  111362. private _vectorTransition;
  111363. /**
  111364. * Targets the given mesh and updates zoom level accordingly.
  111365. * @param mesh The mesh to target.
  111366. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111367. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111368. */
  111369. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111370. /**
  111371. * Targets the given mesh with its children and updates zoom level accordingly.
  111372. * @param mesh The mesh to target.
  111373. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111374. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111375. */
  111376. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111377. /**
  111378. * Targets the given meshes with their children and updates zoom level accordingly.
  111379. * @param meshes The mesh to target.
  111380. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111381. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111382. */
  111383. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111384. /**
  111385. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111386. * @param minimumWorld Determines the smaller position of the bounding box extend
  111387. * @param maximumWorld Determines the bigger position of the bounding box extend
  111388. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111389. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111390. */
  111391. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111392. /**
  111393. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111394. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111395. * frustum width.
  111396. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111397. * to fully enclose the mesh in the viewing frustum.
  111398. */
  111399. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111400. /**
  111401. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111402. * is automatically returned to its default position (expected to be above ground plane).
  111403. */
  111404. private _maintainCameraAboveGround;
  111405. /**
  111406. * Returns the frustum slope based on the canvas ratio and camera FOV
  111407. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111408. */
  111409. private _getFrustumSlope;
  111410. /**
  111411. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111412. */
  111413. private _clearAnimationLocks;
  111414. /**
  111415. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111416. */
  111417. private _applyUserInteraction;
  111418. /**
  111419. * Stops and removes all animations that have been applied to the camera
  111420. */
  111421. stopAllAnimations(): void;
  111422. /**
  111423. * Gets a value indicating if the user is moving the camera
  111424. */
  111425. get isUserIsMoving(): boolean;
  111426. /**
  111427. * The camera can move all the way towards the mesh.
  111428. */
  111429. static IgnoreBoundsSizeMode: number;
  111430. /**
  111431. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111432. */
  111433. static FitFrustumSidesMode: number;
  111434. }
  111435. }
  111436. declare module BABYLON {
  111437. /**
  111438. * Base class for Camera Pointer Inputs.
  111439. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111440. * for example usage.
  111441. */
  111442. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111443. /**
  111444. * Defines the camera the input is attached to.
  111445. */
  111446. abstract camera: Camera;
  111447. /**
  111448. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111449. */
  111450. protected _altKey: boolean;
  111451. protected _ctrlKey: boolean;
  111452. protected _metaKey: boolean;
  111453. protected _shiftKey: boolean;
  111454. /**
  111455. * Which mouse buttons were pressed at time of last mouse event.
  111456. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111457. */
  111458. protected _buttonsPressed: number;
  111459. /**
  111460. * Defines the buttons associated with the input to handle camera move.
  111461. */
  111462. buttons: number[];
  111463. /**
  111464. * Attach the input controls to a specific dom element to get the input from.
  111465. * @param element Defines the element the controls should be listened from
  111466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111467. */
  111468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111469. /**
  111470. * Detach the current controls from the specified dom element.
  111471. * @param element Defines the element to stop listening the inputs from
  111472. */
  111473. detachControl(element: Nullable<HTMLElement>): void;
  111474. /**
  111475. * Gets the class name of the current input.
  111476. * @returns the class name
  111477. */
  111478. getClassName(): string;
  111479. /**
  111480. * Get the friendly name associated with the input class.
  111481. * @returns the input friendly name
  111482. */
  111483. getSimpleName(): string;
  111484. /**
  111485. * Called on pointer POINTERDOUBLETAP event.
  111486. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111487. */
  111488. protected onDoubleTap(type: string): void;
  111489. /**
  111490. * Called on pointer POINTERMOVE event if only a single touch is active.
  111491. * Override this method to provide functionality.
  111492. */
  111493. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111494. /**
  111495. * Called on pointer POINTERMOVE event if multiple touches are active.
  111496. * Override this method to provide functionality.
  111497. */
  111498. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111499. /**
  111500. * Called on JS contextmenu event.
  111501. * Override this method to provide functionality.
  111502. */
  111503. protected onContextMenu(evt: PointerEvent): void;
  111504. /**
  111505. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111506. * press.
  111507. * Override this method to provide functionality.
  111508. */
  111509. protected onButtonDown(evt: PointerEvent): void;
  111510. /**
  111511. * Called each time a new POINTERUP event occurs. Ie, for each button
  111512. * release.
  111513. * Override this method to provide functionality.
  111514. */
  111515. protected onButtonUp(evt: PointerEvent): void;
  111516. /**
  111517. * Called when window becomes inactive.
  111518. * Override this method to provide functionality.
  111519. */
  111520. protected onLostFocus(): void;
  111521. private _pointerInput;
  111522. private _observer;
  111523. private _onLostFocus;
  111524. private pointA;
  111525. private pointB;
  111526. }
  111527. }
  111528. declare module BABYLON {
  111529. /**
  111530. * Manage the pointers inputs to control an arc rotate camera.
  111531. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111532. */
  111533. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111534. /**
  111535. * Defines the camera the input is attached to.
  111536. */
  111537. camera: ArcRotateCamera;
  111538. /**
  111539. * Gets the class name of the current input.
  111540. * @returns the class name
  111541. */
  111542. getClassName(): string;
  111543. /**
  111544. * Defines the buttons associated with the input to handle camera move.
  111545. */
  111546. buttons: number[];
  111547. /**
  111548. * Defines the pointer angular sensibility along the X axis or how fast is
  111549. * the camera rotating.
  111550. */
  111551. angularSensibilityX: number;
  111552. /**
  111553. * Defines the pointer angular sensibility along the Y axis or how fast is
  111554. * the camera rotating.
  111555. */
  111556. angularSensibilityY: number;
  111557. /**
  111558. * Defines the pointer pinch precision or how fast is the camera zooming.
  111559. */
  111560. pinchPrecision: number;
  111561. /**
  111562. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111563. * from 0.
  111564. * It defines the percentage of current camera.radius to use as delta when
  111565. * pinch zoom is used.
  111566. */
  111567. pinchDeltaPercentage: number;
  111568. /**
  111569. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111570. * that any object in the plane at the camera's target point will scale
  111571. * perfectly with finger motion.
  111572. * Overrides pinchDeltaPercentage and pinchPrecision.
  111573. */
  111574. useNaturalPinchZoom: boolean;
  111575. /**
  111576. * Defines the pointer panning sensibility or how fast is the camera moving.
  111577. */
  111578. panningSensibility: number;
  111579. /**
  111580. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111581. */
  111582. multiTouchPanning: boolean;
  111583. /**
  111584. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111585. * zoom (pinch) through multitouch.
  111586. */
  111587. multiTouchPanAndZoom: boolean;
  111588. /**
  111589. * Revers pinch action direction.
  111590. */
  111591. pinchInwards: boolean;
  111592. private _isPanClick;
  111593. private _twoFingerActivityCount;
  111594. private _isPinching;
  111595. /**
  111596. * Called on pointer POINTERMOVE event if only a single touch is active.
  111597. */
  111598. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111599. /**
  111600. * Called on pointer POINTERDOUBLETAP event.
  111601. */
  111602. protected onDoubleTap(type: string): void;
  111603. /**
  111604. * Called on pointer POINTERMOVE event if multiple touches are active.
  111605. */
  111606. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111607. /**
  111608. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111609. * press.
  111610. */
  111611. protected onButtonDown(evt: PointerEvent): void;
  111612. /**
  111613. * Called each time a new POINTERUP event occurs. Ie, for each button
  111614. * release.
  111615. */
  111616. protected onButtonUp(evt: PointerEvent): void;
  111617. /**
  111618. * Called when window becomes inactive.
  111619. */
  111620. protected onLostFocus(): void;
  111621. }
  111622. }
  111623. declare module BABYLON {
  111624. /**
  111625. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111627. */
  111628. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111629. /**
  111630. * Defines the camera the input is attached to.
  111631. */
  111632. camera: ArcRotateCamera;
  111633. /**
  111634. * Defines the list of key codes associated with the up action (increase alpha)
  111635. */
  111636. keysUp: number[];
  111637. /**
  111638. * Defines the list of key codes associated with the down action (decrease alpha)
  111639. */
  111640. keysDown: number[];
  111641. /**
  111642. * Defines the list of key codes associated with the left action (increase beta)
  111643. */
  111644. keysLeft: number[];
  111645. /**
  111646. * Defines the list of key codes associated with the right action (decrease beta)
  111647. */
  111648. keysRight: number[];
  111649. /**
  111650. * Defines the list of key codes associated with the reset action.
  111651. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111652. */
  111653. keysReset: number[];
  111654. /**
  111655. * Defines the panning sensibility of the inputs.
  111656. * (How fast is the camera panning)
  111657. */
  111658. panningSensibility: number;
  111659. /**
  111660. * Defines the zooming sensibility of the inputs.
  111661. * (How fast is the camera zooming)
  111662. */
  111663. zoomingSensibility: number;
  111664. /**
  111665. * Defines whether maintaining the alt key down switch the movement mode from
  111666. * orientation to zoom.
  111667. */
  111668. useAltToZoom: boolean;
  111669. /**
  111670. * Rotation speed of the camera
  111671. */
  111672. angularSpeed: number;
  111673. private _keys;
  111674. private _ctrlPressed;
  111675. private _altPressed;
  111676. private _onCanvasBlurObserver;
  111677. private _onKeyboardObserver;
  111678. private _engine;
  111679. private _scene;
  111680. /**
  111681. * Attach the input controls to a specific dom element to get the input from.
  111682. * @param element Defines the element the controls should be listened from
  111683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111684. */
  111685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111686. /**
  111687. * Detach the current controls from the specified dom element.
  111688. * @param element Defines the element to stop listening the inputs from
  111689. */
  111690. detachControl(element: Nullable<HTMLElement>): void;
  111691. /**
  111692. * Update the current camera state depending on the inputs that have been used this frame.
  111693. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111694. */
  111695. checkInputs(): void;
  111696. /**
  111697. * Gets the class name of the current intput.
  111698. * @returns the class name
  111699. */
  111700. getClassName(): string;
  111701. /**
  111702. * Get the friendly name associated with the input class.
  111703. * @returns the input friendly name
  111704. */
  111705. getSimpleName(): string;
  111706. }
  111707. }
  111708. declare module BABYLON {
  111709. /**
  111710. * Manage the mouse wheel inputs to control an arc rotate camera.
  111711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111712. */
  111713. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111714. /**
  111715. * Defines the camera the input is attached to.
  111716. */
  111717. camera: ArcRotateCamera;
  111718. /**
  111719. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111720. */
  111721. wheelPrecision: number;
  111722. /**
  111723. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111724. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111725. */
  111726. wheelDeltaPercentage: number;
  111727. private _wheel;
  111728. private _observer;
  111729. private computeDeltaFromMouseWheelLegacyEvent;
  111730. /**
  111731. * Attach the input controls to a specific dom element to get the input from.
  111732. * @param element Defines the element the controls should be listened from
  111733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111734. */
  111735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111736. /**
  111737. * Detach the current controls from the specified dom element.
  111738. * @param element Defines the element to stop listening the inputs from
  111739. */
  111740. detachControl(element: Nullable<HTMLElement>): void;
  111741. /**
  111742. * Gets the class name of the current intput.
  111743. * @returns the class name
  111744. */
  111745. getClassName(): string;
  111746. /**
  111747. * Get the friendly name associated with the input class.
  111748. * @returns the input friendly name
  111749. */
  111750. getSimpleName(): string;
  111751. }
  111752. }
  111753. declare module BABYLON {
  111754. /**
  111755. * Default Inputs manager for the ArcRotateCamera.
  111756. * It groups all the default supported inputs for ease of use.
  111757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111758. */
  111759. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111760. /**
  111761. * Instantiates a new ArcRotateCameraInputsManager.
  111762. * @param camera Defines the camera the inputs belong to
  111763. */
  111764. constructor(camera: ArcRotateCamera);
  111765. /**
  111766. * Add mouse wheel input support to the input manager.
  111767. * @returns the current input manager
  111768. */
  111769. addMouseWheel(): ArcRotateCameraInputsManager;
  111770. /**
  111771. * Add pointers input support to the input manager.
  111772. * @returns the current input manager
  111773. */
  111774. addPointers(): ArcRotateCameraInputsManager;
  111775. /**
  111776. * Add keyboard input support to the input manager.
  111777. * @returns the current input manager
  111778. */
  111779. addKeyboard(): ArcRotateCameraInputsManager;
  111780. }
  111781. }
  111782. declare module BABYLON {
  111783. /**
  111784. * This represents an orbital type of camera.
  111785. *
  111786. * 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.
  111787. * 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.
  111788. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111789. */
  111790. export class ArcRotateCamera extends TargetCamera {
  111791. /**
  111792. * Defines the rotation angle of the camera along the longitudinal axis.
  111793. */
  111794. alpha: number;
  111795. /**
  111796. * Defines the rotation angle of the camera along the latitudinal axis.
  111797. */
  111798. beta: number;
  111799. /**
  111800. * Defines the radius of the camera from it s target point.
  111801. */
  111802. radius: number;
  111803. protected _target: Vector3;
  111804. protected _targetHost: Nullable<AbstractMesh>;
  111805. /**
  111806. * Defines the target point of the camera.
  111807. * The camera looks towards it form the radius distance.
  111808. */
  111809. get target(): Vector3;
  111810. set target(value: Vector3);
  111811. /**
  111812. * Define the current local position of the camera in the scene
  111813. */
  111814. get position(): Vector3;
  111815. set position(newPosition: Vector3);
  111816. protected _upVector: Vector3;
  111817. protected _upToYMatrix: Matrix;
  111818. protected _YToUpMatrix: Matrix;
  111819. /**
  111820. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111821. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111822. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111823. */
  111824. set upVector(vec: Vector3);
  111825. get upVector(): Vector3;
  111826. /**
  111827. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111828. */
  111829. setMatUp(): void;
  111830. /**
  111831. * Current inertia value on the longitudinal axis.
  111832. * The bigger this number the longer it will take for the camera to stop.
  111833. */
  111834. inertialAlphaOffset: number;
  111835. /**
  111836. * Current inertia value on the latitudinal axis.
  111837. * The bigger this number the longer it will take for the camera to stop.
  111838. */
  111839. inertialBetaOffset: number;
  111840. /**
  111841. * Current inertia value on the radius axis.
  111842. * The bigger this number the longer it will take for the camera to stop.
  111843. */
  111844. inertialRadiusOffset: number;
  111845. /**
  111846. * Minimum allowed angle on the longitudinal axis.
  111847. * This can help limiting how the Camera is able to move in the scene.
  111848. */
  111849. lowerAlphaLimit: Nullable<number>;
  111850. /**
  111851. * Maximum allowed angle on the longitudinal axis.
  111852. * This can help limiting how the Camera is able to move in the scene.
  111853. */
  111854. upperAlphaLimit: Nullable<number>;
  111855. /**
  111856. * Minimum allowed angle on the latitudinal axis.
  111857. * This can help limiting how the Camera is able to move in the scene.
  111858. */
  111859. lowerBetaLimit: number;
  111860. /**
  111861. * Maximum allowed angle on the latitudinal axis.
  111862. * This can help limiting how the Camera is able to move in the scene.
  111863. */
  111864. upperBetaLimit: number;
  111865. /**
  111866. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111867. * This can help limiting how the Camera is able to move in the scene.
  111868. */
  111869. lowerRadiusLimit: Nullable<number>;
  111870. /**
  111871. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111872. * This can help limiting how the Camera is able to move in the scene.
  111873. */
  111874. upperRadiusLimit: Nullable<number>;
  111875. /**
  111876. * Defines the current inertia value used during panning of the camera along the X axis.
  111877. */
  111878. inertialPanningX: number;
  111879. /**
  111880. * Defines the current inertia value used during panning of the camera along the Y axis.
  111881. */
  111882. inertialPanningY: number;
  111883. /**
  111884. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111885. * Basically if your fingers moves away from more than this distance you will be considered
  111886. * in pinch mode.
  111887. */
  111888. pinchToPanMaxDistance: number;
  111889. /**
  111890. * Defines the maximum distance the camera can pan.
  111891. * This could help keeping the cammera always in your scene.
  111892. */
  111893. panningDistanceLimit: Nullable<number>;
  111894. /**
  111895. * Defines the target of the camera before paning.
  111896. */
  111897. panningOriginTarget: Vector3;
  111898. /**
  111899. * Defines the value of the inertia used during panning.
  111900. * 0 would mean stop inertia and one would mean no decelleration at all.
  111901. */
  111902. panningInertia: number;
  111903. /**
  111904. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111905. */
  111906. get angularSensibilityX(): number;
  111907. set angularSensibilityX(value: number);
  111908. /**
  111909. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111910. */
  111911. get angularSensibilityY(): number;
  111912. set angularSensibilityY(value: number);
  111913. /**
  111914. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111915. */
  111916. get pinchPrecision(): number;
  111917. set pinchPrecision(value: number);
  111918. /**
  111919. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111920. * It will be used instead of pinchDeltaPrecision if different from 0.
  111921. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111922. */
  111923. get pinchDeltaPercentage(): number;
  111924. set pinchDeltaPercentage(value: number);
  111925. /**
  111926. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111927. * and pinch delta percentage.
  111928. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111929. * that any object in the plane at the camera's target point will scale
  111930. * perfectly with finger motion.
  111931. */
  111932. get useNaturalPinchZoom(): boolean;
  111933. set useNaturalPinchZoom(value: boolean);
  111934. /**
  111935. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111936. */
  111937. get panningSensibility(): number;
  111938. set panningSensibility(value: number);
  111939. /**
  111940. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111941. */
  111942. get keysUp(): number[];
  111943. set keysUp(value: number[]);
  111944. /**
  111945. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111946. */
  111947. get keysDown(): number[];
  111948. set keysDown(value: number[]);
  111949. /**
  111950. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111951. */
  111952. get keysLeft(): number[];
  111953. set keysLeft(value: number[]);
  111954. /**
  111955. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111956. */
  111957. get keysRight(): number[];
  111958. set keysRight(value: number[]);
  111959. /**
  111960. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111961. */
  111962. get wheelPrecision(): number;
  111963. set wheelPrecision(value: number);
  111964. /**
  111965. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111966. * It will be used instead of pinchDeltaPrecision if different from 0.
  111967. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111968. */
  111969. get wheelDeltaPercentage(): number;
  111970. set wheelDeltaPercentage(value: number);
  111971. /**
  111972. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111973. */
  111974. zoomOnFactor: number;
  111975. /**
  111976. * Defines a screen offset for the camera position.
  111977. */
  111978. targetScreenOffset: Vector2;
  111979. /**
  111980. * Allows the camera to be completely reversed.
  111981. * If false the camera can not arrive upside down.
  111982. */
  111983. allowUpsideDown: boolean;
  111984. /**
  111985. * Define if double tap/click is used to restore the previously saved state of the camera.
  111986. */
  111987. useInputToRestoreState: boolean;
  111988. /** @hidden */
  111989. _viewMatrix: Matrix;
  111990. /** @hidden */
  111991. _useCtrlForPanning: boolean;
  111992. /** @hidden */
  111993. _panningMouseButton: number;
  111994. /**
  111995. * Defines the input associated to the camera.
  111996. */
  111997. inputs: ArcRotateCameraInputsManager;
  111998. /** @hidden */
  111999. _reset: () => void;
  112000. /**
  112001. * Defines the allowed panning axis.
  112002. */
  112003. panningAxis: Vector3;
  112004. protected _localDirection: Vector3;
  112005. protected _transformedDirection: Vector3;
  112006. private _bouncingBehavior;
  112007. /**
  112008. * Gets the bouncing behavior of the camera if it has been enabled.
  112009. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112010. */
  112011. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112012. /**
  112013. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112014. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112015. */
  112016. get useBouncingBehavior(): boolean;
  112017. set useBouncingBehavior(value: boolean);
  112018. private _framingBehavior;
  112019. /**
  112020. * Gets the framing behavior of the camera if it has been enabled.
  112021. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112022. */
  112023. get framingBehavior(): Nullable<FramingBehavior>;
  112024. /**
  112025. * Defines if the framing behavior of the camera is enabled on the camera.
  112026. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112027. */
  112028. get useFramingBehavior(): boolean;
  112029. set useFramingBehavior(value: boolean);
  112030. private _autoRotationBehavior;
  112031. /**
  112032. * Gets the auto rotation behavior of the camera if it has been enabled.
  112033. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112034. */
  112035. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112036. /**
  112037. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112038. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112039. */
  112040. get useAutoRotationBehavior(): boolean;
  112041. set useAutoRotationBehavior(value: boolean);
  112042. /**
  112043. * Observable triggered when the mesh target has been changed on the camera.
  112044. */
  112045. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112046. /**
  112047. * Event raised when the camera is colliding with a mesh.
  112048. */
  112049. onCollide: (collidedMesh: AbstractMesh) => void;
  112050. /**
  112051. * Defines whether the camera should check collision with the objects oh the scene.
  112052. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112053. */
  112054. checkCollisions: boolean;
  112055. /**
  112056. * Defines the collision radius of the camera.
  112057. * This simulates a sphere around the camera.
  112058. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112059. */
  112060. collisionRadius: Vector3;
  112061. protected _collider: Collider;
  112062. protected _previousPosition: Vector3;
  112063. protected _collisionVelocity: Vector3;
  112064. protected _newPosition: Vector3;
  112065. protected _previousAlpha: number;
  112066. protected _previousBeta: number;
  112067. protected _previousRadius: number;
  112068. protected _collisionTriggered: boolean;
  112069. protected _targetBoundingCenter: Nullable<Vector3>;
  112070. private _computationVector;
  112071. /**
  112072. * Instantiates a new ArcRotateCamera in a given scene
  112073. * @param name Defines the name of the camera
  112074. * @param alpha Defines the camera rotation along the logitudinal axis
  112075. * @param beta Defines the camera rotation along the latitudinal axis
  112076. * @param radius Defines the camera distance from its target
  112077. * @param target Defines the camera target
  112078. * @param scene Defines the scene the camera belongs to
  112079. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112080. */
  112081. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112082. /** @hidden */
  112083. _initCache(): void;
  112084. /** @hidden */
  112085. _updateCache(ignoreParentClass?: boolean): void;
  112086. protected _getTargetPosition(): Vector3;
  112087. private _storedAlpha;
  112088. private _storedBeta;
  112089. private _storedRadius;
  112090. private _storedTarget;
  112091. private _storedTargetScreenOffset;
  112092. /**
  112093. * Stores the current state of the camera (alpha, beta, radius and target)
  112094. * @returns the camera itself
  112095. */
  112096. storeState(): Camera;
  112097. /**
  112098. * @hidden
  112099. * Restored camera state. You must call storeState() first
  112100. */
  112101. _restoreStateValues(): boolean;
  112102. /** @hidden */
  112103. _isSynchronizedViewMatrix(): boolean;
  112104. /**
  112105. * Attached controls to the current camera.
  112106. * @param element Defines the element the controls should be listened from
  112107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112108. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112109. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112110. */
  112111. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112112. /**
  112113. * Detach the current controls from the camera.
  112114. * The camera will stop reacting to inputs.
  112115. * @param element Defines the element to stop listening the inputs from
  112116. */
  112117. detachControl(element: HTMLElement): void;
  112118. /** @hidden */
  112119. _checkInputs(): void;
  112120. protected _checkLimits(): void;
  112121. /**
  112122. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112123. */
  112124. rebuildAnglesAndRadius(): void;
  112125. /**
  112126. * Use a position to define the current camera related information like alpha, beta and radius
  112127. * @param position Defines the position to set the camera at
  112128. */
  112129. setPosition(position: Vector3): void;
  112130. /**
  112131. * Defines the target the camera should look at.
  112132. * This will automatically adapt alpha beta and radius to fit within the new target.
  112133. * @param target Defines the new target as a Vector or a mesh
  112134. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112135. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112136. */
  112137. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112138. /** @hidden */
  112139. _getViewMatrix(): Matrix;
  112140. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112141. /**
  112142. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112143. * @param meshes Defines the mesh to zoom on
  112144. * @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)
  112145. */
  112146. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112147. /**
  112148. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112149. * The target will be changed but the radius
  112150. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112151. * @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)
  112152. */
  112153. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112154. min: Vector3;
  112155. max: Vector3;
  112156. distance: number;
  112157. }, doNotUpdateMaxZ?: boolean): void;
  112158. /**
  112159. * @override
  112160. * Override Camera.createRigCamera
  112161. */
  112162. createRigCamera(name: string, cameraIndex: number): Camera;
  112163. /**
  112164. * @hidden
  112165. * @override
  112166. * Override Camera._updateRigCameras
  112167. */
  112168. _updateRigCameras(): void;
  112169. /**
  112170. * Destroy the camera and release the current resources hold by it.
  112171. */
  112172. dispose(): void;
  112173. /**
  112174. * Gets the current object class name.
  112175. * @return the class name
  112176. */
  112177. getClassName(): string;
  112178. }
  112179. }
  112180. declare module BABYLON {
  112181. /**
  112182. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112183. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112184. */
  112185. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112186. /**
  112187. * Gets the name of the behavior.
  112188. */
  112189. get name(): string;
  112190. private _zoomStopsAnimation;
  112191. private _idleRotationSpeed;
  112192. private _idleRotationWaitTime;
  112193. private _idleRotationSpinupTime;
  112194. /**
  112195. * Sets the flag that indicates if user zooming should stop animation.
  112196. */
  112197. set zoomStopsAnimation(flag: boolean);
  112198. /**
  112199. * Gets the flag that indicates if user zooming should stop animation.
  112200. */
  112201. get zoomStopsAnimation(): boolean;
  112202. /**
  112203. * Sets the default speed at which the camera rotates around the model.
  112204. */
  112205. set idleRotationSpeed(speed: number);
  112206. /**
  112207. * Gets the default speed at which the camera rotates around the model.
  112208. */
  112209. get idleRotationSpeed(): number;
  112210. /**
  112211. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112212. */
  112213. set idleRotationWaitTime(time: number);
  112214. /**
  112215. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112216. */
  112217. get idleRotationWaitTime(): number;
  112218. /**
  112219. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112220. */
  112221. set idleRotationSpinupTime(time: number);
  112222. /**
  112223. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112224. */
  112225. get idleRotationSpinupTime(): number;
  112226. /**
  112227. * Gets a value indicating if the camera is currently rotating because of this behavior
  112228. */
  112229. get rotationInProgress(): boolean;
  112230. private _onPrePointerObservableObserver;
  112231. private _onAfterCheckInputsObserver;
  112232. private _attachedCamera;
  112233. private _isPointerDown;
  112234. private _lastFrameTime;
  112235. private _lastInteractionTime;
  112236. private _cameraRotationSpeed;
  112237. /**
  112238. * Initializes the behavior.
  112239. */
  112240. init(): void;
  112241. /**
  112242. * Attaches the behavior to its arc rotate camera.
  112243. * @param camera Defines the camera to attach the behavior to
  112244. */
  112245. attach(camera: ArcRotateCamera): void;
  112246. /**
  112247. * Detaches the behavior from its current arc rotate camera.
  112248. */
  112249. detach(): void;
  112250. /**
  112251. * Returns true if user is scrolling.
  112252. * @return true if user is scrolling.
  112253. */
  112254. private _userIsZooming;
  112255. private _lastFrameRadius;
  112256. private _shouldAnimationStopForInteraction;
  112257. /**
  112258. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112259. */
  112260. private _applyUserInteraction;
  112261. private _userIsMoving;
  112262. }
  112263. }
  112264. declare module BABYLON {
  112265. /**
  112266. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112267. */
  112268. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112269. private ui;
  112270. /**
  112271. * The name of the behavior
  112272. */
  112273. name: string;
  112274. /**
  112275. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112276. */
  112277. distanceAwayFromFace: number;
  112278. /**
  112279. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112280. */
  112281. distanceAwayFromBottomOfFace: number;
  112282. private _faceVectors;
  112283. private _target;
  112284. private _scene;
  112285. private _onRenderObserver;
  112286. private _tmpMatrix;
  112287. private _tmpVector;
  112288. /**
  112289. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112290. * @param ui The transform node that should be attched to the mesh
  112291. */
  112292. constructor(ui: TransformNode);
  112293. /**
  112294. * Initializes the behavior
  112295. */
  112296. init(): void;
  112297. private _closestFace;
  112298. private _zeroVector;
  112299. private _lookAtTmpMatrix;
  112300. private _lookAtToRef;
  112301. /**
  112302. * Attaches the AttachToBoxBehavior to the passed in mesh
  112303. * @param target The mesh that the specified node will be attached to
  112304. */
  112305. attach(target: Mesh): void;
  112306. /**
  112307. * Detaches the behavior from the mesh
  112308. */
  112309. detach(): void;
  112310. }
  112311. }
  112312. declare module BABYLON {
  112313. /**
  112314. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112315. */
  112316. export class FadeInOutBehavior implements Behavior<Mesh> {
  112317. /**
  112318. * Time in milliseconds to delay before fading in (Default: 0)
  112319. */
  112320. delay: number;
  112321. /**
  112322. * Time in milliseconds for the mesh to fade in (Default: 300)
  112323. */
  112324. fadeInTime: number;
  112325. private _millisecondsPerFrame;
  112326. private _hovered;
  112327. private _hoverValue;
  112328. private _ownerNode;
  112329. /**
  112330. * Instatiates the FadeInOutBehavior
  112331. */
  112332. constructor();
  112333. /**
  112334. * The name of the behavior
  112335. */
  112336. get name(): string;
  112337. /**
  112338. * Initializes the behavior
  112339. */
  112340. init(): void;
  112341. /**
  112342. * Attaches the fade behavior on the passed in mesh
  112343. * @param ownerNode The mesh that will be faded in/out once attached
  112344. */
  112345. attach(ownerNode: Mesh): void;
  112346. /**
  112347. * Detaches the behavior from the mesh
  112348. */
  112349. detach(): void;
  112350. /**
  112351. * Triggers the mesh to begin fading in or out
  112352. * @param value if the object should fade in or out (true to fade in)
  112353. */
  112354. fadeIn(value: boolean): void;
  112355. private _update;
  112356. private _setAllVisibility;
  112357. }
  112358. }
  112359. declare module BABYLON {
  112360. /**
  112361. * Class containing a set of static utilities functions for managing Pivots
  112362. * @hidden
  112363. */
  112364. export class PivotTools {
  112365. private static _PivotCached;
  112366. private static _OldPivotPoint;
  112367. private static _PivotTranslation;
  112368. private static _PivotTmpVector;
  112369. /** @hidden */
  112370. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112371. /** @hidden */
  112372. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112373. }
  112374. }
  112375. declare module BABYLON {
  112376. /**
  112377. * Class containing static functions to help procedurally build meshes
  112378. */
  112379. export class PlaneBuilder {
  112380. /**
  112381. * Creates a plane mesh
  112382. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112383. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112384. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112388. * @param name defines the name of the mesh
  112389. * @param options defines the options used to create the mesh
  112390. * @param scene defines the hosting scene
  112391. * @returns the plane mesh
  112392. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112393. */
  112394. static CreatePlane(name: string, options: {
  112395. size?: number;
  112396. width?: number;
  112397. height?: number;
  112398. sideOrientation?: number;
  112399. frontUVs?: Vector4;
  112400. backUVs?: Vector4;
  112401. updatable?: boolean;
  112402. sourcePlane?: Plane;
  112403. }, scene?: Nullable<Scene>): Mesh;
  112404. }
  112405. }
  112406. declare module BABYLON {
  112407. /**
  112408. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112409. */
  112410. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112411. private static _AnyMouseID;
  112412. /**
  112413. * Abstract mesh the behavior is set on
  112414. */
  112415. attachedNode: AbstractMesh;
  112416. private _dragPlane;
  112417. private _scene;
  112418. private _pointerObserver;
  112419. private _beforeRenderObserver;
  112420. private static _planeScene;
  112421. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112422. /**
  112423. * 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)
  112424. */
  112425. maxDragAngle: number;
  112426. /**
  112427. * @hidden
  112428. */
  112429. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112430. /**
  112431. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112432. */
  112433. currentDraggingPointerID: number;
  112434. /**
  112435. * The last position where the pointer hit the drag plane in world space
  112436. */
  112437. lastDragPosition: Vector3;
  112438. /**
  112439. * If the behavior is currently in a dragging state
  112440. */
  112441. dragging: boolean;
  112442. /**
  112443. * 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)
  112444. */
  112445. dragDeltaRatio: number;
  112446. /**
  112447. * If the drag plane orientation should be updated during the dragging (Default: true)
  112448. */
  112449. updateDragPlane: boolean;
  112450. private _debugMode;
  112451. private _moving;
  112452. /**
  112453. * Fires each time the attached mesh is dragged with the pointer
  112454. * * delta between last drag position and current drag position in world space
  112455. * * dragDistance along the drag axis
  112456. * * dragPlaneNormal normal of the current drag plane used during the drag
  112457. * * dragPlanePoint in world space where the drag intersects the drag plane
  112458. */
  112459. onDragObservable: Observable<{
  112460. delta: Vector3;
  112461. dragPlanePoint: Vector3;
  112462. dragPlaneNormal: Vector3;
  112463. dragDistance: number;
  112464. pointerId: number;
  112465. }>;
  112466. /**
  112467. * Fires each time a drag begins (eg. mouse down on mesh)
  112468. */
  112469. onDragStartObservable: Observable<{
  112470. dragPlanePoint: Vector3;
  112471. pointerId: number;
  112472. }>;
  112473. /**
  112474. * Fires each time a drag ends (eg. mouse release after drag)
  112475. */
  112476. onDragEndObservable: Observable<{
  112477. dragPlanePoint: Vector3;
  112478. pointerId: number;
  112479. }>;
  112480. /**
  112481. * If the attached mesh should be moved when dragged
  112482. */
  112483. moveAttached: boolean;
  112484. /**
  112485. * If the drag behavior will react to drag events (Default: true)
  112486. */
  112487. enabled: boolean;
  112488. /**
  112489. * If pointer events should start and release the drag (Default: true)
  112490. */
  112491. startAndReleaseDragOnPointerEvents: boolean;
  112492. /**
  112493. * If camera controls should be detached during the drag
  112494. */
  112495. detachCameraControls: boolean;
  112496. /**
  112497. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112498. */
  112499. useObjectOrientationForDragging: boolean;
  112500. private _options;
  112501. /**
  112502. * Gets the options used by the behavior
  112503. */
  112504. get options(): {
  112505. dragAxis?: Vector3;
  112506. dragPlaneNormal?: Vector3;
  112507. };
  112508. /**
  112509. * Sets the options used by the behavior
  112510. */
  112511. set options(options: {
  112512. dragAxis?: Vector3;
  112513. dragPlaneNormal?: Vector3;
  112514. });
  112515. /**
  112516. * Creates a pointer drag behavior that can be attached to a mesh
  112517. * @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)
  112518. */
  112519. constructor(options?: {
  112520. dragAxis?: Vector3;
  112521. dragPlaneNormal?: Vector3;
  112522. });
  112523. /**
  112524. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112525. */
  112526. validateDrag: (targetPosition: Vector3) => boolean;
  112527. /**
  112528. * The name of the behavior
  112529. */
  112530. get name(): string;
  112531. /**
  112532. * Initializes the behavior
  112533. */
  112534. init(): void;
  112535. private _tmpVector;
  112536. private _alternatePickedPoint;
  112537. private _worldDragAxis;
  112538. private _targetPosition;
  112539. private _attachedElement;
  112540. /**
  112541. * Attaches the drag behavior the passed in mesh
  112542. * @param ownerNode The mesh that will be dragged around once attached
  112543. * @param predicate Predicate to use for pick filtering
  112544. */
  112545. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112546. /**
  112547. * Force relase the drag action by code.
  112548. */
  112549. releaseDrag(): void;
  112550. private _startDragRay;
  112551. private _lastPointerRay;
  112552. /**
  112553. * Simulates the start of a pointer drag event on the behavior
  112554. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112555. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112556. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112557. */
  112558. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112559. private _startDrag;
  112560. private _dragDelta;
  112561. private _moveDrag;
  112562. private _pickWithRayOnDragPlane;
  112563. private _pointA;
  112564. private _pointB;
  112565. private _pointC;
  112566. private _lineA;
  112567. private _lineB;
  112568. private _localAxis;
  112569. private _lookAt;
  112570. private _updateDragPlanePosition;
  112571. /**
  112572. * Detaches the behavior from the mesh
  112573. */
  112574. detach(): void;
  112575. }
  112576. }
  112577. declare module BABYLON {
  112578. /**
  112579. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112580. */
  112581. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112582. private _dragBehaviorA;
  112583. private _dragBehaviorB;
  112584. private _startDistance;
  112585. private _initialScale;
  112586. private _targetScale;
  112587. private _ownerNode;
  112588. private _sceneRenderObserver;
  112589. /**
  112590. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112591. */
  112592. constructor();
  112593. /**
  112594. * The name of the behavior
  112595. */
  112596. get name(): string;
  112597. /**
  112598. * Initializes the behavior
  112599. */
  112600. init(): void;
  112601. private _getCurrentDistance;
  112602. /**
  112603. * Attaches the scale behavior the passed in mesh
  112604. * @param ownerNode The mesh that will be scaled around once attached
  112605. */
  112606. attach(ownerNode: Mesh): void;
  112607. /**
  112608. * Detaches the behavior from the mesh
  112609. */
  112610. detach(): void;
  112611. }
  112612. }
  112613. declare module BABYLON {
  112614. /**
  112615. * 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
  112616. */
  112617. export class SixDofDragBehavior implements Behavior<Mesh> {
  112618. private static _virtualScene;
  112619. private _ownerNode;
  112620. private _sceneRenderObserver;
  112621. private _scene;
  112622. private _targetPosition;
  112623. private _virtualOriginMesh;
  112624. private _virtualDragMesh;
  112625. private _pointerObserver;
  112626. private _moving;
  112627. private _startingOrientation;
  112628. /**
  112629. * 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)
  112630. */
  112631. private zDragFactor;
  112632. /**
  112633. * If the object should rotate to face the drag origin
  112634. */
  112635. rotateDraggedObject: boolean;
  112636. /**
  112637. * If the behavior is currently in a dragging state
  112638. */
  112639. dragging: boolean;
  112640. /**
  112641. * 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)
  112642. */
  112643. dragDeltaRatio: number;
  112644. /**
  112645. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112646. */
  112647. currentDraggingPointerID: number;
  112648. /**
  112649. * If camera controls should be detached during the drag
  112650. */
  112651. detachCameraControls: boolean;
  112652. /**
  112653. * Fires each time a drag starts
  112654. */
  112655. onDragStartObservable: Observable<{}>;
  112656. /**
  112657. * Fires each time a drag ends (eg. mouse release after drag)
  112658. */
  112659. onDragEndObservable: Observable<{}>;
  112660. /**
  112661. * 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
  112662. */
  112663. constructor();
  112664. /**
  112665. * The name of the behavior
  112666. */
  112667. get name(): string;
  112668. /**
  112669. * Initializes the behavior
  112670. */
  112671. init(): void;
  112672. /**
  112673. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112674. */
  112675. private get _pointerCamera();
  112676. /**
  112677. * Attaches the scale behavior the passed in mesh
  112678. * @param ownerNode The mesh that will be scaled around once attached
  112679. */
  112680. attach(ownerNode: Mesh): void;
  112681. /**
  112682. * Detaches the behavior from the mesh
  112683. */
  112684. detach(): void;
  112685. }
  112686. }
  112687. declare module BABYLON {
  112688. /**
  112689. * Class used to apply inverse kinematics to bones
  112690. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112691. */
  112692. export class BoneIKController {
  112693. private static _tmpVecs;
  112694. private static _tmpQuat;
  112695. private static _tmpMats;
  112696. /**
  112697. * Gets or sets the target mesh
  112698. */
  112699. targetMesh: AbstractMesh;
  112700. /** Gets or sets the mesh used as pole */
  112701. poleTargetMesh: AbstractMesh;
  112702. /**
  112703. * Gets or sets the bone used as pole
  112704. */
  112705. poleTargetBone: Nullable<Bone>;
  112706. /**
  112707. * Gets or sets the target position
  112708. */
  112709. targetPosition: Vector3;
  112710. /**
  112711. * Gets or sets the pole target position
  112712. */
  112713. poleTargetPosition: Vector3;
  112714. /**
  112715. * Gets or sets the pole target local offset
  112716. */
  112717. poleTargetLocalOffset: Vector3;
  112718. /**
  112719. * Gets or sets the pole angle
  112720. */
  112721. poleAngle: number;
  112722. /**
  112723. * Gets or sets the mesh associated with the controller
  112724. */
  112725. mesh: AbstractMesh;
  112726. /**
  112727. * 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)
  112728. */
  112729. slerpAmount: number;
  112730. private _bone1Quat;
  112731. private _bone1Mat;
  112732. private _bone2Ang;
  112733. private _bone1;
  112734. private _bone2;
  112735. private _bone1Length;
  112736. private _bone2Length;
  112737. private _maxAngle;
  112738. private _maxReach;
  112739. private _rightHandedSystem;
  112740. private _bendAxis;
  112741. private _slerping;
  112742. private _adjustRoll;
  112743. /**
  112744. * Gets or sets maximum allowed angle
  112745. */
  112746. get maxAngle(): number;
  112747. set maxAngle(value: number);
  112748. /**
  112749. * Creates a new BoneIKController
  112750. * @param mesh defines the mesh to control
  112751. * @param bone defines the bone to control
  112752. * @param options defines options to set up the controller
  112753. */
  112754. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112755. targetMesh?: AbstractMesh;
  112756. poleTargetMesh?: AbstractMesh;
  112757. poleTargetBone?: Bone;
  112758. poleTargetLocalOffset?: Vector3;
  112759. poleAngle?: number;
  112760. bendAxis?: Vector3;
  112761. maxAngle?: number;
  112762. slerpAmount?: number;
  112763. });
  112764. private _setMaxAngle;
  112765. /**
  112766. * Force the controller to update the bones
  112767. */
  112768. update(): void;
  112769. }
  112770. }
  112771. declare module BABYLON {
  112772. /**
  112773. * Class used to make a bone look toward a point in space
  112774. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112775. */
  112776. export class BoneLookController {
  112777. private static _tmpVecs;
  112778. private static _tmpQuat;
  112779. private static _tmpMats;
  112780. /**
  112781. * The target Vector3 that the bone will look at
  112782. */
  112783. target: Vector3;
  112784. /**
  112785. * The mesh that the bone is attached to
  112786. */
  112787. mesh: AbstractMesh;
  112788. /**
  112789. * The bone that will be looking to the target
  112790. */
  112791. bone: Bone;
  112792. /**
  112793. * The up axis of the coordinate system that is used when the bone is rotated
  112794. */
  112795. upAxis: Vector3;
  112796. /**
  112797. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112798. */
  112799. upAxisSpace: Space;
  112800. /**
  112801. * Used to make an adjustment to the yaw of the bone
  112802. */
  112803. adjustYaw: number;
  112804. /**
  112805. * Used to make an adjustment to the pitch of the bone
  112806. */
  112807. adjustPitch: number;
  112808. /**
  112809. * Used to make an adjustment to the roll of the bone
  112810. */
  112811. adjustRoll: number;
  112812. /**
  112813. * 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)
  112814. */
  112815. slerpAmount: number;
  112816. private _minYaw;
  112817. private _maxYaw;
  112818. private _minPitch;
  112819. private _maxPitch;
  112820. private _minYawSin;
  112821. private _minYawCos;
  112822. private _maxYawSin;
  112823. private _maxYawCos;
  112824. private _midYawConstraint;
  112825. private _minPitchTan;
  112826. private _maxPitchTan;
  112827. private _boneQuat;
  112828. private _slerping;
  112829. private _transformYawPitch;
  112830. private _transformYawPitchInv;
  112831. private _firstFrameSkipped;
  112832. private _yawRange;
  112833. private _fowardAxis;
  112834. /**
  112835. * Gets or sets the minimum yaw angle that the bone can look to
  112836. */
  112837. get minYaw(): number;
  112838. set minYaw(value: number);
  112839. /**
  112840. * Gets or sets the maximum yaw angle that the bone can look to
  112841. */
  112842. get maxYaw(): number;
  112843. set maxYaw(value: number);
  112844. /**
  112845. * Gets or sets the minimum pitch angle that the bone can look to
  112846. */
  112847. get minPitch(): number;
  112848. set minPitch(value: number);
  112849. /**
  112850. * Gets or sets the maximum pitch angle that the bone can look to
  112851. */
  112852. get maxPitch(): number;
  112853. set maxPitch(value: number);
  112854. /**
  112855. * Create a BoneLookController
  112856. * @param mesh the mesh that the bone belongs to
  112857. * @param bone the bone that will be looking to the target
  112858. * @param target the target Vector3 to look at
  112859. * @param options optional settings:
  112860. * * maxYaw: the maximum angle the bone will yaw to
  112861. * * minYaw: the minimum angle the bone will yaw to
  112862. * * maxPitch: the maximum angle the bone will pitch to
  112863. * * minPitch: the minimum angle the bone will yaw to
  112864. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112865. * * upAxis: the up axis of the coordinate system
  112866. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112867. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112868. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112869. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112870. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112871. * * adjustRoll: used to make an adjustment to the roll of the bone
  112872. **/
  112873. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112874. maxYaw?: number;
  112875. minYaw?: number;
  112876. maxPitch?: number;
  112877. minPitch?: number;
  112878. slerpAmount?: number;
  112879. upAxis?: Vector3;
  112880. upAxisSpace?: Space;
  112881. yawAxis?: Vector3;
  112882. pitchAxis?: Vector3;
  112883. adjustYaw?: number;
  112884. adjustPitch?: number;
  112885. adjustRoll?: number;
  112886. });
  112887. /**
  112888. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112889. */
  112890. update(): void;
  112891. private _getAngleDiff;
  112892. private _getAngleBetween;
  112893. private _isAngleBetween;
  112894. }
  112895. }
  112896. declare module BABYLON {
  112897. /**
  112898. * Manage the gamepad inputs to control an arc rotate camera.
  112899. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112900. */
  112901. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112902. /**
  112903. * Defines the camera the input is attached to.
  112904. */
  112905. camera: ArcRotateCamera;
  112906. /**
  112907. * Defines the gamepad the input is gathering event from.
  112908. */
  112909. gamepad: Nullable<Gamepad>;
  112910. /**
  112911. * Defines the gamepad rotation sensiblity.
  112912. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112913. */
  112914. gamepadRotationSensibility: number;
  112915. /**
  112916. * Defines the gamepad move sensiblity.
  112917. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112918. */
  112919. gamepadMoveSensibility: number;
  112920. private _yAxisScale;
  112921. /**
  112922. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112923. */
  112924. get invertYAxis(): boolean;
  112925. set invertYAxis(value: boolean);
  112926. private _onGamepadConnectedObserver;
  112927. private _onGamepadDisconnectedObserver;
  112928. /**
  112929. * Attach the input controls to a specific dom element to get the input from.
  112930. * @param element Defines the element the controls should be listened from
  112931. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112932. */
  112933. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112934. /**
  112935. * Detach the current controls from the specified dom element.
  112936. * @param element Defines the element to stop listening the inputs from
  112937. */
  112938. detachControl(element: Nullable<HTMLElement>): void;
  112939. /**
  112940. * Update the current camera state depending on the inputs that have been used this frame.
  112941. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112942. */
  112943. checkInputs(): void;
  112944. /**
  112945. * Gets the class name of the current intput.
  112946. * @returns the class name
  112947. */
  112948. getClassName(): string;
  112949. /**
  112950. * Get the friendly name associated with the input class.
  112951. * @returns the input friendly name
  112952. */
  112953. getSimpleName(): string;
  112954. }
  112955. }
  112956. declare module BABYLON {
  112957. interface ArcRotateCameraInputsManager {
  112958. /**
  112959. * Add orientation input support to the input manager.
  112960. * @returns the current input manager
  112961. */
  112962. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112963. }
  112964. /**
  112965. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112967. */
  112968. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112969. /**
  112970. * Defines the camera the input is attached to.
  112971. */
  112972. camera: ArcRotateCamera;
  112973. /**
  112974. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112975. */
  112976. alphaCorrection: number;
  112977. /**
  112978. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112979. */
  112980. gammaCorrection: number;
  112981. private _alpha;
  112982. private _gamma;
  112983. private _dirty;
  112984. private _deviceOrientationHandler;
  112985. /**
  112986. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112987. */
  112988. constructor();
  112989. /**
  112990. * Attach the input controls to a specific dom element to get the input from.
  112991. * @param element Defines the element the controls should be listened from
  112992. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112993. */
  112994. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112995. /** @hidden */
  112996. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112997. /**
  112998. * Update the current camera state depending on the inputs that have been used this frame.
  112999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113000. */
  113001. checkInputs(): void;
  113002. /**
  113003. * Detach the current controls from the specified dom element.
  113004. * @param element Defines the element to stop listening the inputs from
  113005. */
  113006. detachControl(element: Nullable<HTMLElement>): void;
  113007. /**
  113008. * Gets the class name of the current intput.
  113009. * @returns the class name
  113010. */
  113011. getClassName(): string;
  113012. /**
  113013. * Get the friendly name associated with the input class.
  113014. * @returns the input friendly name
  113015. */
  113016. getSimpleName(): string;
  113017. }
  113018. }
  113019. declare module BABYLON {
  113020. /**
  113021. * Listen to mouse events to control the camera.
  113022. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113023. */
  113024. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113025. /**
  113026. * Defines the camera the input is attached to.
  113027. */
  113028. camera: FlyCamera;
  113029. /**
  113030. * Defines if touch is enabled. (Default is true.)
  113031. */
  113032. touchEnabled: boolean;
  113033. /**
  113034. * Defines the buttons associated with the input to handle camera rotation.
  113035. */
  113036. buttons: number[];
  113037. /**
  113038. * Assign buttons for Yaw control.
  113039. */
  113040. buttonsYaw: number[];
  113041. /**
  113042. * Assign buttons for Pitch control.
  113043. */
  113044. buttonsPitch: number[];
  113045. /**
  113046. * Assign buttons for Roll control.
  113047. */
  113048. buttonsRoll: number[];
  113049. /**
  113050. * Detect if any button is being pressed while mouse is moved.
  113051. * -1 = Mouse locked.
  113052. * 0 = Left button.
  113053. * 1 = Middle Button.
  113054. * 2 = Right Button.
  113055. */
  113056. activeButton: number;
  113057. /**
  113058. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113059. * Higher values reduce its sensitivity.
  113060. */
  113061. angularSensibility: number;
  113062. private _mousemoveCallback;
  113063. private _observer;
  113064. private _rollObserver;
  113065. private previousPosition;
  113066. private noPreventDefault;
  113067. private element;
  113068. /**
  113069. * Listen to mouse events to control the camera.
  113070. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113071. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113072. */
  113073. constructor(touchEnabled?: boolean);
  113074. /**
  113075. * Attach the mouse control to the HTML DOM element.
  113076. * @param element Defines the element that listens to the input events.
  113077. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113078. */
  113079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113080. /**
  113081. * Detach the current controls from the specified dom element.
  113082. * @param element Defines the element to stop listening the inputs from
  113083. */
  113084. detachControl(element: Nullable<HTMLElement>): void;
  113085. /**
  113086. * Gets the class name of the current input.
  113087. * @returns the class name.
  113088. */
  113089. getClassName(): string;
  113090. /**
  113091. * Get the friendly name associated with the input class.
  113092. * @returns the input's friendly name.
  113093. */
  113094. getSimpleName(): string;
  113095. private _pointerInput;
  113096. private _onMouseMove;
  113097. /**
  113098. * Rotate camera by mouse offset.
  113099. */
  113100. private rotateCamera;
  113101. }
  113102. }
  113103. declare module BABYLON {
  113104. /**
  113105. * Default Inputs manager for the FlyCamera.
  113106. * It groups all the default supported inputs for ease of use.
  113107. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113108. */
  113109. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113110. /**
  113111. * Instantiates a new FlyCameraInputsManager.
  113112. * @param camera Defines the camera the inputs belong to.
  113113. */
  113114. constructor(camera: FlyCamera);
  113115. /**
  113116. * Add keyboard input support to the input manager.
  113117. * @returns the new FlyCameraKeyboardMoveInput().
  113118. */
  113119. addKeyboard(): FlyCameraInputsManager;
  113120. /**
  113121. * Add mouse input support to the input manager.
  113122. * @param touchEnabled Enable touch screen support.
  113123. * @returns the new FlyCameraMouseInput().
  113124. */
  113125. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113126. }
  113127. }
  113128. declare module BABYLON {
  113129. /**
  113130. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113131. * such as in a 3D Space Shooter or a Flight Simulator.
  113132. */
  113133. export class FlyCamera extends TargetCamera {
  113134. /**
  113135. * Define the collision ellipsoid of the camera.
  113136. * This is helpful for simulating a camera body, like a player's body.
  113137. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113138. */
  113139. ellipsoid: Vector3;
  113140. /**
  113141. * Define an offset for the position of the ellipsoid around the camera.
  113142. * This can be helpful if the camera is attached away from the player's body center,
  113143. * such as at its head.
  113144. */
  113145. ellipsoidOffset: Vector3;
  113146. /**
  113147. * Enable or disable collisions of the camera with the rest of the scene objects.
  113148. */
  113149. checkCollisions: boolean;
  113150. /**
  113151. * Enable or disable gravity on the camera.
  113152. */
  113153. applyGravity: boolean;
  113154. /**
  113155. * Define the current direction the camera is moving to.
  113156. */
  113157. cameraDirection: Vector3;
  113158. /**
  113159. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113160. * This overrides and empties cameraRotation.
  113161. */
  113162. rotationQuaternion: Quaternion;
  113163. /**
  113164. * Track Roll to maintain the wanted Rolling when looking around.
  113165. */
  113166. _trackRoll: number;
  113167. /**
  113168. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113169. */
  113170. rollCorrect: number;
  113171. /**
  113172. * Mimic a banked turn, Rolling the camera when Yawing.
  113173. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113174. */
  113175. bankedTurn: boolean;
  113176. /**
  113177. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113178. */
  113179. bankedTurnLimit: number;
  113180. /**
  113181. * Value of 0 disables the banked Roll.
  113182. * Value of 1 is equal to the Yaw angle in radians.
  113183. */
  113184. bankedTurnMultiplier: number;
  113185. /**
  113186. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113187. */
  113188. inputs: FlyCameraInputsManager;
  113189. /**
  113190. * Gets the input sensibility for mouse input.
  113191. * Higher values reduce sensitivity.
  113192. */
  113193. get angularSensibility(): number;
  113194. /**
  113195. * Sets the input sensibility for a mouse input.
  113196. * Higher values reduce sensitivity.
  113197. */
  113198. set angularSensibility(value: number);
  113199. /**
  113200. * Get the keys for camera movement forward.
  113201. */
  113202. get keysForward(): number[];
  113203. /**
  113204. * Set the keys for camera movement forward.
  113205. */
  113206. set keysForward(value: number[]);
  113207. /**
  113208. * Get the keys for camera movement backward.
  113209. */
  113210. get keysBackward(): number[];
  113211. set keysBackward(value: number[]);
  113212. /**
  113213. * Get the keys for camera movement up.
  113214. */
  113215. get keysUp(): number[];
  113216. /**
  113217. * Set the keys for camera movement up.
  113218. */
  113219. set keysUp(value: number[]);
  113220. /**
  113221. * Get the keys for camera movement down.
  113222. */
  113223. get keysDown(): number[];
  113224. /**
  113225. * Set the keys for camera movement down.
  113226. */
  113227. set keysDown(value: number[]);
  113228. /**
  113229. * Get the keys for camera movement left.
  113230. */
  113231. get keysLeft(): number[];
  113232. /**
  113233. * Set the keys for camera movement left.
  113234. */
  113235. set keysLeft(value: number[]);
  113236. /**
  113237. * Set the keys for camera movement right.
  113238. */
  113239. get keysRight(): number[];
  113240. /**
  113241. * Set the keys for camera movement right.
  113242. */
  113243. set keysRight(value: number[]);
  113244. /**
  113245. * Event raised when the camera collides with a mesh in the scene.
  113246. */
  113247. onCollide: (collidedMesh: AbstractMesh) => void;
  113248. private _collider;
  113249. private _needMoveForGravity;
  113250. private _oldPosition;
  113251. private _diffPosition;
  113252. private _newPosition;
  113253. /** @hidden */
  113254. _localDirection: Vector3;
  113255. /** @hidden */
  113256. _transformedDirection: Vector3;
  113257. /**
  113258. * Instantiates a FlyCamera.
  113259. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113260. * such as in a 3D Space Shooter or a Flight Simulator.
  113261. * @param name Define the name of the camera in the scene.
  113262. * @param position Define the starting position of the camera in the scene.
  113263. * @param scene Define the scene the camera belongs to.
  113264. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113265. */
  113266. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113267. /**
  113268. * Attach a control to the HTML DOM element.
  113269. * @param element Defines the element that listens to the input events.
  113270. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113271. */
  113272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113273. /**
  113274. * Detach a control from the HTML DOM element.
  113275. * The camera will stop reacting to that input.
  113276. * @param element Defines the element that listens to the input events.
  113277. */
  113278. detachControl(element: HTMLElement): void;
  113279. private _collisionMask;
  113280. /**
  113281. * Get the mask that the camera ignores in collision events.
  113282. */
  113283. get collisionMask(): number;
  113284. /**
  113285. * Set the mask that the camera ignores in collision events.
  113286. */
  113287. set collisionMask(mask: number);
  113288. /** @hidden */
  113289. _collideWithWorld(displacement: Vector3): void;
  113290. /** @hidden */
  113291. private _onCollisionPositionChange;
  113292. /** @hidden */
  113293. _checkInputs(): void;
  113294. /** @hidden */
  113295. _decideIfNeedsToMove(): boolean;
  113296. /** @hidden */
  113297. _updatePosition(): void;
  113298. /**
  113299. * Restore the Roll to its target value at the rate specified.
  113300. * @param rate - Higher means slower restoring.
  113301. * @hidden
  113302. */
  113303. restoreRoll(rate: number): void;
  113304. /**
  113305. * Destroy the camera and release the current resources held by it.
  113306. */
  113307. dispose(): void;
  113308. /**
  113309. * Get the current object class name.
  113310. * @returns the class name.
  113311. */
  113312. getClassName(): string;
  113313. }
  113314. }
  113315. declare module BABYLON {
  113316. /**
  113317. * Listen to keyboard events to control the camera.
  113318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113319. */
  113320. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113321. /**
  113322. * Defines the camera the input is attached to.
  113323. */
  113324. camera: FlyCamera;
  113325. /**
  113326. * The list of keyboard keys used to control the forward move of the camera.
  113327. */
  113328. keysForward: number[];
  113329. /**
  113330. * The list of keyboard keys used to control the backward move of the camera.
  113331. */
  113332. keysBackward: number[];
  113333. /**
  113334. * The list of keyboard keys used to control the forward move of the camera.
  113335. */
  113336. keysUp: number[];
  113337. /**
  113338. * The list of keyboard keys used to control the backward move of the camera.
  113339. */
  113340. keysDown: number[];
  113341. /**
  113342. * The list of keyboard keys used to control the right strafe move of the camera.
  113343. */
  113344. keysRight: number[];
  113345. /**
  113346. * The list of keyboard keys used to control the left strafe move of the camera.
  113347. */
  113348. keysLeft: number[];
  113349. private _keys;
  113350. private _onCanvasBlurObserver;
  113351. private _onKeyboardObserver;
  113352. private _engine;
  113353. private _scene;
  113354. /**
  113355. * Attach the input controls to a specific dom element to get the input from.
  113356. * @param element Defines the element the controls should be listened from
  113357. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113358. */
  113359. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113360. /**
  113361. * Detach the current controls from the specified dom element.
  113362. * @param element Defines the element to stop listening the inputs from
  113363. */
  113364. detachControl(element: Nullable<HTMLElement>): void;
  113365. /**
  113366. * Gets the class name of the current intput.
  113367. * @returns the class name
  113368. */
  113369. getClassName(): string;
  113370. /** @hidden */
  113371. _onLostFocus(e: FocusEvent): void;
  113372. /**
  113373. * Get the friendly name associated with the input class.
  113374. * @returns the input friendly name
  113375. */
  113376. getSimpleName(): string;
  113377. /**
  113378. * Update the current camera state depending on the inputs that have been used this frame.
  113379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113380. */
  113381. checkInputs(): void;
  113382. }
  113383. }
  113384. declare module BABYLON {
  113385. /**
  113386. * Manage the mouse wheel inputs to control a follow camera.
  113387. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113388. */
  113389. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113390. /**
  113391. * Defines the camera the input is attached to.
  113392. */
  113393. camera: FollowCamera;
  113394. /**
  113395. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113396. */
  113397. axisControlRadius: boolean;
  113398. /**
  113399. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113400. */
  113401. axisControlHeight: boolean;
  113402. /**
  113403. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113404. */
  113405. axisControlRotation: boolean;
  113406. /**
  113407. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113408. * relation to mouseWheel events.
  113409. */
  113410. wheelPrecision: number;
  113411. /**
  113412. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113413. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113414. */
  113415. wheelDeltaPercentage: number;
  113416. private _wheel;
  113417. private _observer;
  113418. /**
  113419. * Attach the input controls to a specific dom element to get the input from.
  113420. * @param element Defines the element the controls should be listened from
  113421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113422. */
  113423. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113424. /**
  113425. * Detach the current controls from the specified dom element.
  113426. * @param element Defines the element to stop listening the inputs from
  113427. */
  113428. detachControl(element: Nullable<HTMLElement>): void;
  113429. /**
  113430. * Gets the class name of the current intput.
  113431. * @returns the class name
  113432. */
  113433. getClassName(): string;
  113434. /**
  113435. * Get the friendly name associated with the input class.
  113436. * @returns the input friendly name
  113437. */
  113438. getSimpleName(): string;
  113439. }
  113440. }
  113441. declare module BABYLON {
  113442. /**
  113443. * Manage the pointers inputs to control an follow camera.
  113444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113445. */
  113446. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113447. /**
  113448. * Defines the camera the input is attached to.
  113449. */
  113450. camera: FollowCamera;
  113451. /**
  113452. * Gets the class name of the current input.
  113453. * @returns the class name
  113454. */
  113455. getClassName(): string;
  113456. /**
  113457. * Defines the pointer angular sensibility along the X axis or how fast is
  113458. * the camera rotating.
  113459. * A negative number will reverse the axis direction.
  113460. */
  113461. angularSensibilityX: number;
  113462. /**
  113463. * Defines the pointer angular sensibility along the Y axis or how fast is
  113464. * the camera rotating.
  113465. * A negative number will reverse the axis direction.
  113466. */
  113467. angularSensibilityY: number;
  113468. /**
  113469. * Defines the pointer pinch precision or how fast is the camera zooming.
  113470. * A negative number will reverse the axis direction.
  113471. */
  113472. pinchPrecision: number;
  113473. /**
  113474. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113475. * from 0.
  113476. * It defines the percentage of current camera.radius to use as delta when
  113477. * pinch zoom is used.
  113478. */
  113479. pinchDeltaPercentage: number;
  113480. /**
  113481. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113482. */
  113483. axisXControlRadius: boolean;
  113484. /**
  113485. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113486. */
  113487. axisXControlHeight: boolean;
  113488. /**
  113489. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113490. */
  113491. axisXControlRotation: boolean;
  113492. /**
  113493. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113494. */
  113495. axisYControlRadius: boolean;
  113496. /**
  113497. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113498. */
  113499. axisYControlHeight: boolean;
  113500. /**
  113501. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113502. */
  113503. axisYControlRotation: boolean;
  113504. /**
  113505. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113506. */
  113507. axisPinchControlRadius: boolean;
  113508. /**
  113509. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113510. */
  113511. axisPinchControlHeight: boolean;
  113512. /**
  113513. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113514. */
  113515. axisPinchControlRotation: boolean;
  113516. /**
  113517. * Log error messages if basic misconfiguration has occurred.
  113518. */
  113519. warningEnable: boolean;
  113520. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113521. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113522. private _warningCounter;
  113523. private _warning;
  113524. }
  113525. }
  113526. declare module BABYLON {
  113527. /**
  113528. * Default Inputs manager for the FollowCamera.
  113529. * It groups all the default supported inputs for ease of use.
  113530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113531. */
  113532. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113533. /**
  113534. * Instantiates a new FollowCameraInputsManager.
  113535. * @param camera Defines the camera the inputs belong to
  113536. */
  113537. constructor(camera: FollowCamera);
  113538. /**
  113539. * Add keyboard input support to the input manager.
  113540. * @returns the current input manager
  113541. */
  113542. addKeyboard(): FollowCameraInputsManager;
  113543. /**
  113544. * Add mouse wheel input support to the input manager.
  113545. * @returns the current input manager
  113546. */
  113547. addMouseWheel(): FollowCameraInputsManager;
  113548. /**
  113549. * Add pointers input support to the input manager.
  113550. * @returns the current input manager
  113551. */
  113552. addPointers(): FollowCameraInputsManager;
  113553. /**
  113554. * Add orientation input support to the input manager.
  113555. * @returns the current input manager
  113556. */
  113557. addVRDeviceOrientation(): FollowCameraInputsManager;
  113558. }
  113559. }
  113560. declare module BABYLON {
  113561. /**
  113562. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113563. * an arc rotate version arcFollowCamera are available.
  113564. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113565. */
  113566. export class FollowCamera extends TargetCamera {
  113567. /**
  113568. * Distance the follow camera should follow an object at
  113569. */
  113570. radius: number;
  113571. /**
  113572. * Minimum allowed distance of the camera to the axis of rotation
  113573. * (The camera can not get closer).
  113574. * This can help limiting how the Camera is able to move in the scene.
  113575. */
  113576. lowerRadiusLimit: Nullable<number>;
  113577. /**
  113578. * Maximum allowed distance of the camera to the axis of rotation
  113579. * (The camera can not get further).
  113580. * This can help limiting how the Camera is able to move in the scene.
  113581. */
  113582. upperRadiusLimit: Nullable<number>;
  113583. /**
  113584. * Define a rotation offset between the camera and the object it follows
  113585. */
  113586. rotationOffset: number;
  113587. /**
  113588. * Minimum allowed angle to camera position relative to target object.
  113589. * This can help limiting how the Camera is able to move in the scene.
  113590. */
  113591. lowerRotationOffsetLimit: Nullable<number>;
  113592. /**
  113593. * Maximum allowed angle to camera position relative to target object.
  113594. * This can help limiting how the Camera is able to move in the scene.
  113595. */
  113596. upperRotationOffsetLimit: Nullable<number>;
  113597. /**
  113598. * Define a height offset between the camera and the object it follows.
  113599. * It can help following an object from the top (like a car chaing a plane)
  113600. */
  113601. heightOffset: number;
  113602. /**
  113603. * Minimum allowed height of camera position relative to target object.
  113604. * This can help limiting how the Camera is able to move in the scene.
  113605. */
  113606. lowerHeightOffsetLimit: Nullable<number>;
  113607. /**
  113608. * Maximum allowed height of camera position relative to target object.
  113609. * This can help limiting how the Camera is able to move in the scene.
  113610. */
  113611. upperHeightOffsetLimit: Nullable<number>;
  113612. /**
  113613. * Define how fast the camera can accelerate to follow it s target.
  113614. */
  113615. cameraAcceleration: number;
  113616. /**
  113617. * Define the speed limit of the camera following an object.
  113618. */
  113619. maxCameraSpeed: number;
  113620. /**
  113621. * Define the target of the camera.
  113622. */
  113623. lockedTarget: Nullable<AbstractMesh>;
  113624. /**
  113625. * Defines the input associated with the camera.
  113626. */
  113627. inputs: FollowCameraInputsManager;
  113628. /**
  113629. * Instantiates the follow camera.
  113630. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113631. * @param name Define the name of the camera in the scene
  113632. * @param position Define the position of the camera
  113633. * @param scene Define the scene the camera belong to
  113634. * @param lockedTarget Define the target of the camera
  113635. */
  113636. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113637. private _follow;
  113638. /**
  113639. * Attached controls to the current camera.
  113640. * @param element Defines the element the controls should be listened from
  113641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113642. */
  113643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113644. /**
  113645. * Detach the current controls from the camera.
  113646. * The camera will stop reacting to inputs.
  113647. * @param element Defines the element to stop listening the inputs from
  113648. */
  113649. detachControl(element: HTMLElement): void;
  113650. /** @hidden */
  113651. _checkInputs(): void;
  113652. private _checkLimits;
  113653. /**
  113654. * Gets the camera class name.
  113655. * @returns the class name
  113656. */
  113657. getClassName(): string;
  113658. }
  113659. /**
  113660. * Arc Rotate version of the follow camera.
  113661. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113662. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113663. */
  113664. export class ArcFollowCamera extends TargetCamera {
  113665. /** The longitudinal angle of the camera */
  113666. alpha: number;
  113667. /** The latitudinal angle of the camera */
  113668. beta: number;
  113669. /** The radius of the camera from its target */
  113670. radius: number;
  113671. /** Define the camera target (the messh it should follow) */
  113672. target: Nullable<AbstractMesh>;
  113673. private _cartesianCoordinates;
  113674. /**
  113675. * Instantiates a new ArcFollowCamera
  113676. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113677. * @param name Define the name of the camera
  113678. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113679. * @param beta Define the rotation angle of the camera around the elevation axis
  113680. * @param radius Define the radius of the camera from its target point
  113681. * @param target Define the target of the camera
  113682. * @param scene Define the scene the camera belongs to
  113683. */
  113684. constructor(name: string,
  113685. /** The longitudinal angle of the camera */
  113686. alpha: number,
  113687. /** The latitudinal angle of the camera */
  113688. beta: number,
  113689. /** The radius of the camera from its target */
  113690. radius: number,
  113691. /** Define the camera target (the messh it should follow) */
  113692. target: Nullable<AbstractMesh>, scene: Scene);
  113693. private _follow;
  113694. /** @hidden */
  113695. _checkInputs(): void;
  113696. /**
  113697. * Returns the class name of the object.
  113698. * It is mostly used internally for serialization purposes.
  113699. */
  113700. getClassName(): string;
  113701. }
  113702. }
  113703. declare module BABYLON {
  113704. /**
  113705. * Manage the keyboard inputs to control the movement of a follow camera.
  113706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113707. */
  113708. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113709. /**
  113710. * Defines the camera the input is attached to.
  113711. */
  113712. camera: FollowCamera;
  113713. /**
  113714. * Defines the list of key codes associated with the up action (increase heightOffset)
  113715. */
  113716. keysHeightOffsetIncr: number[];
  113717. /**
  113718. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113719. */
  113720. keysHeightOffsetDecr: number[];
  113721. /**
  113722. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113723. */
  113724. keysHeightOffsetModifierAlt: boolean;
  113725. /**
  113726. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113727. */
  113728. keysHeightOffsetModifierCtrl: boolean;
  113729. /**
  113730. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113731. */
  113732. keysHeightOffsetModifierShift: boolean;
  113733. /**
  113734. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113735. */
  113736. keysRotationOffsetIncr: number[];
  113737. /**
  113738. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113739. */
  113740. keysRotationOffsetDecr: number[];
  113741. /**
  113742. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113743. */
  113744. keysRotationOffsetModifierAlt: boolean;
  113745. /**
  113746. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113747. */
  113748. keysRotationOffsetModifierCtrl: boolean;
  113749. /**
  113750. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113751. */
  113752. keysRotationOffsetModifierShift: boolean;
  113753. /**
  113754. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113755. */
  113756. keysRadiusIncr: number[];
  113757. /**
  113758. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113759. */
  113760. keysRadiusDecr: number[];
  113761. /**
  113762. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113763. */
  113764. keysRadiusModifierAlt: boolean;
  113765. /**
  113766. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113767. */
  113768. keysRadiusModifierCtrl: boolean;
  113769. /**
  113770. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113771. */
  113772. keysRadiusModifierShift: boolean;
  113773. /**
  113774. * Defines the rate of change of heightOffset.
  113775. */
  113776. heightSensibility: number;
  113777. /**
  113778. * Defines the rate of change of rotationOffset.
  113779. */
  113780. rotationSensibility: number;
  113781. /**
  113782. * Defines the rate of change of radius.
  113783. */
  113784. radiusSensibility: number;
  113785. private _keys;
  113786. private _ctrlPressed;
  113787. private _altPressed;
  113788. private _shiftPressed;
  113789. private _onCanvasBlurObserver;
  113790. private _onKeyboardObserver;
  113791. private _engine;
  113792. private _scene;
  113793. /**
  113794. * Attach the input controls to a specific dom element to get the input from.
  113795. * @param element Defines the element the controls should be listened from
  113796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113797. */
  113798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113799. /**
  113800. * Detach the current controls from the specified dom element.
  113801. * @param element Defines the element to stop listening the inputs from
  113802. */
  113803. detachControl(element: Nullable<HTMLElement>): void;
  113804. /**
  113805. * Update the current camera state depending on the inputs that have been used this frame.
  113806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113807. */
  113808. checkInputs(): void;
  113809. /**
  113810. * Gets the class name of the current input.
  113811. * @returns the class name
  113812. */
  113813. getClassName(): string;
  113814. /**
  113815. * Get the friendly name associated with the input class.
  113816. * @returns the input friendly name
  113817. */
  113818. getSimpleName(): string;
  113819. /**
  113820. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113821. * allow modification of the heightOffset value.
  113822. */
  113823. private _modifierHeightOffset;
  113824. /**
  113825. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113826. * allow modification of the rotationOffset value.
  113827. */
  113828. private _modifierRotationOffset;
  113829. /**
  113830. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113831. * allow modification of the radius value.
  113832. */
  113833. private _modifierRadius;
  113834. }
  113835. }
  113836. declare module BABYLON {
  113837. interface FreeCameraInputsManager {
  113838. /**
  113839. * @hidden
  113840. */
  113841. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113842. /**
  113843. * Add orientation input support to the input manager.
  113844. * @returns the current input manager
  113845. */
  113846. addDeviceOrientation(): FreeCameraInputsManager;
  113847. }
  113848. /**
  113849. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113850. * Screen rotation is taken into account.
  113851. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113852. */
  113853. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113854. private _camera;
  113855. private _screenOrientationAngle;
  113856. private _constantTranform;
  113857. private _screenQuaternion;
  113858. private _alpha;
  113859. private _beta;
  113860. private _gamma;
  113861. /**
  113862. * Can be used to detect if a device orientation sensor is available on a device
  113863. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113864. * @returns a promise that will resolve on orientation change
  113865. */
  113866. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113867. /**
  113868. * @hidden
  113869. */
  113870. _onDeviceOrientationChangedObservable: Observable<void>;
  113871. /**
  113872. * Instantiates a new input
  113873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113874. */
  113875. constructor();
  113876. /**
  113877. * Define the camera controlled by the input.
  113878. */
  113879. get camera(): FreeCamera;
  113880. set camera(camera: FreeCamera);
  113881. /**
  113882. * Attach the input controls to a specific dom element to get the input from.
  113883. * @param element Defines the element the controls should be listened from
  113884. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113885. */
  113886. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113887. private _orientationChanged;
  113888. private _deviceOrientation;
  113889. /**
  113890. * Detach the current controls from the specified dom element.
  113891. * @param element Defines the element to stop listening the inputs from
  113892. */
  113893. detachControl(element: Nullable<HTMLElement>): void;
  113894. /**
  113895. * Update the current camera state depending on the inputs that have been used this frame.
  113896. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113897. */
  113898. checkInputs(): void;
  113899. /**
  113900. * Gets the class name of the current intput.
  113901. * @returns the class name
  113902. */
  113903. getClassName(): string;
  113904. /**
  113905. * Get the friendly name associated with the input class.
  113906. * @returns the input friendly name
  113907. */
  113908. getSimpleName(): string;
  113909. }
  113910. }
  113911. declare module BABYLON {
  113912. /**
  113913. * Manage the gamepad inputs to control a free camera.
  113914. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113915. */
  113916. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113917. /**
  113918. * Define the camera the input is attached to.
  113919. */
  113920. camera: FreeCamera;
  113921. /**
  113922. * Define the Gamepad controlling the input
  113923. */
  113924. gamepad: Nullable<Gamepad>;
  113925. /**
  113926. * Defines the gamepad rotation sensiblity.
  113927. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113928. */
  113929. gamepadAngularSensibility: number;
  113930. /**
  113931. * Defines the gamepad move sensiblity.
  113932. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113933. */
  113934. gamepadMoveSensibility: number;
  113935. private _yAxisScale;
  113936. /**
  113937. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113938. */
  113939. get invertYAxis(): boolean;
  113940. set invertYAxis(value: boolean);
  113941. private _onGamepadConnectedObserver;
  113942. private _onGamepadDisconnectedObserver;
  113943. private _cameraTransform;
  113944. private _deltaTransform;
  113945. private _vector3;
  113946. private _vector2;
  113947. /**
  113948. * Attach the input controls to a specific dom element to get the input from.
  113949. * @param element Defines the element the controls should be listened from
  113950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113951. */
  113952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113953. /**
  113954. * Detach the current controls from the specified dom element.
  113955. * @param element Defines the element to stop listening the inputs from
  113956. */
  113957. detachControl(element: Nullable<HTMLElement>): void;
  113958. /**
  113959. * Update the current camera state depending on the inputs that have been used this frame.
  113960. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113961. */
  113962. checkInputs(): void;
  113963. /**
  113964. * Gets the class name of the current intput.
  113965. * @returns the class name
  113966. */
  113967. getClassName(): string;
  113968. /**
  113969. * Get the friendly name associated with the input class.
  113970. * @returns the input friendly name
  113971. */
  113972. getSimpleName(): string;
  113973. }
  113974. }
  113975. declare module BABYLON {
  113976. /**
  113977. * Defines the potential axis of a Joystick
  113978. */
  113979. export enum JoystickAxis {
  113980. /** X axis */
  113981. X = 0,
  113982. /** Y axis */
  113983. Y = 1,
  113984. /** Z axis */
  113985. Z = 2
  113986. }
  113987. /**
  113988. * Class used to define virtual joystick (used in touch mode)
  113989. */
  113990. export class VirtualJoystick {
  113991. /**
  113992. * Gets or sets a boolean indicating that left and right values must be inverted
  113993. */
  113994. reverseLeftRight: boolean;
  113995. /**
  113996. * Gets or sets a boolean indicating that up and down values must be inverted
  113997. */
  113998. reverseUpDown: boolean;
  113999. /**
  114000. * Gets the offset value for the position (ie. the change of the position value)
  114001. */
  114002. deltaPosition: Vector3;
  114003. /**
  114004. * Gets a boolean indicating if the virtual joystick was pressed
  114005. */
  114006. pressed: boolean;
  114007. /**
  114008. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114009. */
  114010. static Canvas: Nullable<HTMLCanvasElement>;
  114011. private static _globalJoystickIndex;
  114012. private static vjCanvasContext;
  114013. private static vjCanvasWidth;
  114014. private static vjCanvasHeight;
  114015. private static halfWidth;
  114016. private _action;
  114017. private _axisTargetedByLeftAndRight;
  114018. private _axisTargetedByUpAndDown;
  114019. private _joystickSensibility;
  114020. private _inversedSensibility;
  114021. private _joystickPointerID;
  114022. private _joystickColor;
  114023. private _joystickPointerPos;
  114024. private _joystickPreviousPointerPos;
  114025. private _joystickPointerStartPos;
  114026. private _deltaJoystickVector;
  114027. private _leftJoystick;
  114028. private _touches;
  114029. private _onPointerDownHandlerRef;
  114030. private _onPointerMoveHandlerRef;
  114031. private _onPointerUpHandlerRef;
  114032. private _onResize;
  114033. /**
  114034. * Creates a new virtual joystick
  114035. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114036. */
  114037. constructor(leftJoystick?: boolean);
  114038. /**
  114039. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114040. * @param newJoystickSensibility defines the new sensibility
  114041. */
  114042. setJoystickSensibility(newJoystickSensibility: number): void;
  114043. private _onPointerDown;
  114044. private _onPointerMove;
  114045. private _onPointerUp;
  114046. /**
  114047. * Change the color of the virtual joystick
  114048. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114049. */
  114050. setJoystickColor(newColor: string): void;
  114051. /**
  114052. * Defines a callback to call when the joystick is touched
  114053. * @param action defines the callback
  114054. */
  114055. setActionOnTouch(action: () => any): void;
  114056. /**
  114057. * Defines which axis you'd like to control for left & right
  114058. * @param axis defines the axis to use
  114059. */
  114060. setAxisForLeftRight(axis: JoystickAxis): void;
  114061. /**
  114062. * Defines which axis you'd like to control for up & down
  114063. * @param axis defines the axis to use
  114064. */
  114065. setAxisForUpDown(axis: JoystickAxis): void;
  114066. private _drawVirtualJoystick;
  114067. /**
  114068. * Release internal HTML canvas
  114069. */
  114070. releaseCanvas(): void;
  114071. }
  114072. }
  114073. declare module BABYLON {
  114074. interface FreeCameraInputsManager {
  114075. /**
  114076. * Add virtual joystick input support to the input manager.
  114077. * @returns the current input manager
  114078. */
  114079. addVirtualJoystick(): FreeCameraInputsManager;
  114080. }
  114081. /**
  114082. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114084. */
  114085. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114086. /**
  114087. * Defines the camera the input is attached to.
  114088. */
  114089. camera: FreeCamera;
  114090. private _leftjoystick;
  114091. private _rightjoystick;
  114092. /**
  114093. * Gets the left stick of the virtual joystick.
  114094. * @returns The virtual Joystick
  114095. */
  114096. getLeftJoystick(): VirtualJoystick;
  114097. /**
  114098. * Gets the right stick of the virtual joystick.
  114099. * @returns The virtual Joystick
  114100. */
  114101. getRightJoystick(): VirtualJoystick;
  114102. /**
  114103. * Update the current camera state depending on the inputs that have been used this frame.
  114104. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114105. */
  114106. checkInputs(): void;
  114107. /**
  114108. * Attach the input controls to a specific dom element to get the input from.
  114109. * @param element Defines the element the controls should be listened from
  114110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114111. */
  114112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114113. /**
  114114. * Detach the current controls from the specified dom element.
  114115. * @param element Defines the element to stop listening the inputs from
  114116. */
  114117. detachControl(element: Nullable<HTMLElement>): void;
  114118. /**
  114119. * Gets the class name of the current intput.
  114120. * @returns the class name
  114121. */
  114122. getClassName(): string;
  114123. /**
  114124. * Get the friendly name associated with the input class.
  114125. * @returns the input friendly name
  114126. */
  114127. getSimpleName(): string;
  114128. }
  114129. }
  114130. declare module BABYLON {
  114131. /**
  114132. * This represents a FPS type of camera controlled by touch.
  114133. * This is like a universal camera minus the Gamepad controls.
  114134. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114135. */
  114136. export class TouchCamera extends FreeCamera {
  114137. /**
  114138. * Defines the touch sensibility for rotation.
  114139. * The higher the faster.
  114140. */
  114141. get touchAngularSensibility(): number;
  114142. set touchAngularSensibility(value: number);
  114143. /**
  114144. * Defines the touch sensibility for move.
  114145. * The higher the faster.
  114146. */
  114147. get touchMoveSensibility(): number;
  114148. set touchMoveSensibility(value: number);
  114149. /**
  114150. * Instantiates a new touch camera.
  114151. * This represents a FPS type of camera controlled by touch.
  114152. * This is like a universal camera minus the Gamepad controls.
  114153. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114154. * @param name Define the name of the camera in the scene
  114155. * @param position Define the start position of the camera in the scene
  114156. * @param scene Define the scene the camera belongs to
  114157. */
  114158. constructor(name: string, position: Vector3, scene: Scene);
  114159. /**
  114160. * Gets the current object class name.
  114161. * @return the class name
  114162. */
  114163. getClassName(): string;
  114164. /** @hidden */
  114165. _setupInputs(): void;
  114166. }
  114167. }
  114168. declare module BABYLON {
  114169. /**
  114170. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114171. * being tilted forward or back and left or right.
  114172. */
  114173. export class DeviceOrientationCamera extends FreeCamera {
  114174. private _initialQuaternion;
  114175. private _quaternionCache;
  114176. private _tmpDragQuaternion;
  114177. private _disablePointerInputWhenUsingDeviceOrientation;
  114178. /**
  114179. * Creates a new device orientation camera
  114180. * @param name The name of the camera
  114181. * @param position The start position camera
  114182. * @param scene The scene the camera belongs to
  114183. */
  114184. constructor(name: string, position: Vector3, scene: Scene);
  114185. /**
  114186. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114187. */
  114188. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114189. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114190. private _dragFactor;
  114191. /**
  114192. * Enabled turning on the y axis when the orientation sensor is active
  114193. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114194. */
  114195. enableHorizontalDragging(dragFactor?: number): void;
  114196. /**
  114197. * Gets the current instance class name ("DeviceOrientationCamera").
  114198. * This helps avoiding instanceof at run time.
  114199. * @returns the class name
  114200. */
  114201. getClassName(): string;
  114202. /**
  114203. * @hidden
  114204. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114205. */
  114206. _checkInputs(): void;
  114207. /**
  114208. * Reset the camera to its default orientation on the specified axis only.
  114209. * @param axis The axis to reset
  114210. */
  114211. resetToCurrentRotation(axis?: Axis): void;
  114212. }
  114213. }
  114214. declare module BABYLON {
  114215. /**
  114216. * Defines supported buttons for XBox360 compatible gamepads
  114217. */
  114218. export enum Xbox360Button {
  114219. /** A */
  114220. A = 0,
  114221. /** B */
  114222. B = 1,
  114223. /** X */
  114224. X = 2,
  114225. /** Y */
  114226. Y = 3,
  114227. /** Left button */
  114228. LB = 4,
  114229. /** Right button */
  114230. RB = 5,
  114231. /** Back */
  114232. Back = 8,
  114233. /** Start */
  114234. Start = 9,
  114235. /** Left stick */
  114236. LeftStick = 10,
  114237. /** Right stick */
  114238. RightStick = 11
  114239. }
  114240. /** Defines values for XBox360 DPad */
  114241. export enum Xbox360Dpad {
  114242. /** Up */
  114243. Up = 12,
  114244. /** Down */
  114245. Down = 13,
  114246. /** Left */
  114247. Left = 14,
  114248. /** Right */
  114249. Right = 15
  114250. }
  114251. /**
  114252. * Defines a XBox360 gamepad
  114253. */
  114254. export class Xbox360Pad extends Gamepad {
  114255. private _leftTrigger;
  114256. private _rightTrigger;
  114257. private _onlefttriggerchanged;
  114258. private _onrighttriggerchanged;
  114259. private _onbuttondown;
  114260. private _onbuttonup;
  114261. private _ondpaddown;
  114262. private _ondpadup;
  114263. /** Observable raised when a button is pressed */
  114264. onButtonDownObservable: Observable<Xbox360Button>;
  114265. /** Observable raised when a button is released */
  114266. onButtonUpObservable: Observable<Xbox360Button>;
  114267. /** Observable raised when a pad is pressed */
  114268. onPadDownObservable: Observable<Xbox360Dpad>;
  114269. /** Observable raised when a pad is released */
  114270. onPadUpObservable: Observable<Xbox360Dpad>;
  114271. private _buttonA;
  114272. private _buttonB;
  114273. private _buttonX;
  114274. private _buttonY;
  114275. private _buttonBack;
  114276. private _buttonStart;
  114277. private _buttonLB;
  114278. private _buttonRB;
  114279. private _buttonLeftStick;
  114280. private _buttonRightStick;
  114281. private _dPadUp;
  114282. private _dPadDown;
  114283. private _dPadLeft;
  114284. private _dPadRight;
  114285. private _isXboxOnePad;
  114286. /**
  114287. * Creates a new XBox360 gamepad object
  114288. * @param id defines the id of this gamepad
  114289. * @param index defines its index
  114290. * @param gamepad defines the internal HTML gamepad object
  114291. * @param xboxOne defines if it is a XBox One gamepad
  114292. */
  114293. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114294. /**
  114295. * Defines the callback to call when left trigger is pressed
  114296. * @param callback defines the callback to use
  114297. */
  114298. onlefttriggerchanged(callback: (value: number) => void): void;
  114299. /**
  114300. * Defines the callback to call when right trigger is pressed
  114301. * @param callback defines the callback to use
  114302. */
  114303. onrighttriggerchanged(callback: (value: number) => void): void;
  114304. /**
  114305. * Gets the left trigger value
  114306. */
  114307. get leftTrigger(): number;
  114308. /**
  114309. * Sets the left trigger value
  114310. */
  114311. set leftTrigger(newValue: number);
  114312. /**
  114313. * Gets the right trigger value
  114314. */
  114315. get rightTrigger(): number;
  114316. /**
  114317. * Sets the right trigger value
  114318. */
  114319. set rightTrigger(newValue: number);
  114320. /**
  114321. * Defines the callback to call when a button is pressed
  114322. * @param callback defines the callback to use
  114323. */
  114324. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114325. /**
  114326. * Defines the callback to call when a button is released
  114327. * @param callback defines the callback to use
  114328. */
  114329. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114330. /**
  114331. * Defines the callback to call when a pad is pressed
  114332. * @param callback defines the callback to use
  114333. */
  114334. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114335. /**
  114336. * Defines the callback to call when a pad is released
  114337. * @param callback defines the callback to use
  114338. */
  114339. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114340. private _setButtonValue;
  114341. private _setDPadValue;
  114342. /**
  114343. * Gets the value of the `A` button
  114344. */
  114345. get buttonA(): number;
  114346. /**
  114347. * Sets the value of the `A` button
  114348. */
  114349. set buttonA(value: number);
  114350. /**
  114351. * Gets the value of the `B` button
  114352. */
  114353. get buttonB(): number;
  114354. /**
  114355. * Sets the value of the `B` button
  114356. */
  114357. set buttonB(value: number);
  114358. /**
  114359. * Gets the value of the `X` button
  114360. */
  114361. get buttonX(): number;
  114362. /**
  114363. * Sets the value of the `X` button
  114364. */
  114365. set buttonX(value: number);
  114366. /**
  114367. * Gets the value of the `Y` button
  114368. */
  114369. get buttonY(): number;
  114370. /**
  114371. * Sets the value of the `Y` button
  114372. */
  114373. set buttonY(value: number);
  114374. /**
  114375. * Gets the value of the `Start` button
  114376. */
  114377. get buttonStart(): number;
  114378. /**
  114379. * Sets the value of the `Start` button
  114380. */
  114381. set buttonStart(value: number);
  114382. /**
  114383. * Gets the value of the `Back` button
  114384. */
  114385. get buttonBack(): number;
  114386. /**
  114387. * Sets the value of the `Back` button
  114388. */
  114389. set buttonBack(value: number);
  114390. /**
  114391. * Gets the value of the `Left` button
  114392. */
  114393. get buttonLB(): number;
  114394. /**
  114395. * Sets the value of the `Left` button
  114396. */
  114397. set buttonLB(value: number);
  114398. /**
  114399. * Gets the value of the `Right` button
  114400. */
  114401. get buttonRB(): number;
  114402. /**
  114403. * Sets the value of the `Right` button
  114404. */
  114405. set buttonRB(value: number);
  114406. /**
  114407. * Gets the value of the Left joystick
  114408. */
  114409. get buttonLeftStick(): number;
  114410. /**
  114411. * Sets the value of the Left joystick
  114412. */
  114413. set buttonLeftStick(value: number);
  114414. /**
  114415. * Gets the value of the Right joystick
  114416. */
  114417. get buttonRightStick(): number;
  114418. /**
  114419. * Sets the value of the Right joystick
  114420. */
  114421. set buttonRightStick(value: number);
  114422. /**
  114423. * Gets the value of D-pad up
  114424. */
  114425. get dPadUp(): number;
  114426. /**
  114427. * Sets the value of D-pad up
  114428. */
  114429. set dPadUp(value: number);
  114430. /**
  114431. * Gets the value of D-pad down
  114432. */
  114433. get dPadDown(): number;
  114434. /**
  114435. * Sets the value of D-pad down
  114436. */
  114437. set dPadDown(value: number);
  114438. /**
  114439. * Gets the value of D-pad left
  114440. */
  114441. get dPadLeft(): number;
  114442. /**
  114443. * Sets the value of D-pad left
  114444. */
  114445. set dPadLeft(value: number);
  114446. /**
  114447. * Gets the value of D-pad right
  114448. */
  114449. get dPadRight(): number;
  114450. /**
  114451. * Sets the value of D-pad right
  114452. */
  114453. set dPadRight(value: number);
  114454. /**
  114455. * Force the gamepad to synchronize with device values
  114456. */
  114457. update(): void;
  114458. /**
  114459. * Disposes the gamepad
  114460. */
  114461. dispose(): void;
  114462. }
  114463. }
  114464. declare module BABYLON {
  114465. /**
  114466. * Defines supported buttons for DualShock compatible gamepads
  114467. */
  114468. export enum DualShockButton {
  114469. /** Cross */
  114470. Cross = 0,
  114471. /** Circle */
  114472. Circle = 1,
  114473. /** Square */
  114474. Square = 2,
  114475. /** Triangle */
  114476. Triangle = 3,
  114477. /** L1 */
  114478. L1 = 4,
  114479. /** R1 */
  114480. R1 = 5,
  114481. /** Share */
  114482. Share = 8,
  114483. /** Options */
  114484. Options = 9,
  114485. /** Left stick */
  114486. LeftStick = 10,
  114487. /** Right stick */
  114488. RightStick = 11
  114489. }
  114490. /** Defines values for DualShock DPad */
  114491. export enum DualShockDpad {
  114492. /** Up */
  114493. Up = 12,
  114494. /** Down */
  114495. Down = 13,
  114496. /** Left */
  114497. Left = 14,
  114498. /** Right */
  114499. Right = 15
  114500. }
  114501. /**
  114502. * Defines a DualShock gamepad
  114503. */
  114504. export class DualShockPad extends Gamepad {
  114505. private _leftTrigger;
  114506. private _rightTrigger;
  114507. private _onlefttriggerchanged;
  114508. private _onrighttriggerchanged;
  114509. private _onbuttondown;
  114510. private _onbuttonup;
  114511. private _ondpaddown;
  114512. private _ondpadup;
  114513. /** Observable raised when a button is pressed */
  114514. onButtonDownObservable: Observable<DualShockButton>;
  114515. /** Observable raised when a button is released */
  114516. onButtonUpObservable: Observable<DualShockButton>;
  114517. /** Observable raised when a pad is pressed */
  114518. onPadDownObservable: Observable<DualShockDpad>;
  114519. /** Observable raised when a pad is released */
  114520. onPadUpObservable: Observable<DualShockDpad>;
  114521. private _buttonCross;
  114522. private _buttonCircle;
  114523. private _buttonSquare;
  114524. private _buttonTriangle;
  114525. private _buttonShare;
  114526. private _buttonOptions;
  114527. private _buttonL1;
  114528. private _buttonR1;
  114529. private _buttonLeftStick;
  114530. private _buttonRightStick;
  114531. private _dPadUp;
  114532. private _dPadDown;
  114533. private _dPadLeft;
  114534. private _dPadRight;
  114535. /**
  114536. * Creates a new DualShock gamepad object
  114537. * @param id defines the id of this gamepad
  114538. * @param index defines its index
  114539. * @param gamepad defines the internal HTML gamepad object
  114540. */
  114541. constructor(id: string, index: number, gamepad: any);
  114542. /**
  114543. * Defines the callback to call when left trigger is pressed
  114544. * @param callback defines the callback to use
  114545. */
  114546. onlefttriggerchanged(callback: (value: number) => void): void;
  114547. /**
  114548. * Defines the callback to call when right trigger is pressed
  114549. * @param callback defines the callback to use
  114550. */
  114551. onrighttriggerchanged(callback: (value: number) => void): void;
  114552. /**
  114553. * Gets the left trigger value
  114554. */
  114555. get leftTrigger(): number;
  114556. /**
  114557. * Sets the left trigger value
  114558. */
  114559. set leftTrigger(newValue: number);
  114560. /**
  114561. * Gets the right trigger value
  114562. */
  114563. get rightTrigger(): number;
  114564. /**
  114565. * Sets the right trigger value
  114566. */
  114567. set rightTrigger(newValue: number);
  114568. /**
  114569. * Defines the callback to call when a button is pressed
  114570. * @param callback defines the callback to use
  114571. */
  114572. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114573. /**
  114574. * Defines the callback to call when a button is released
  114575. * @param callback defines the callback to use
  114576. */
  114577. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114578. /**
  114579. * Defines the callback to call when a pad is pressed
  114580. * @param callback defines the callback to use
  114581. */
  114582. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114583. /**
  114584. * Defines the callback to call when a pad is released
  114585. * @param callback defines the callback to use
  114586. */
  114587. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114588. private _setButtonValue;
  114589. private _setDPadValue;
  114590. /**
  114591. * Gets the value of the `Cross` button
  114592. */
  114593. get buttonCross(): number;
  114594. /**
  114595. * Sets the value of the `Cross` button
  114596. */
  114597. set buttonCross(value: number);
  114598. /**
  114599. * Gets the value of the `Circle` button
  114600. */
  114601. get buttonCircle(): number;
  114602. /**
  114603. * Sets the value of the `Circle` button
  114604. */
  114605. set buttonCircle(value: number);
  114606. /**
  114607. * Gets the value of the `Square` button
  114608. */
  114609. get buttonSquare(): number;
  114610. /**
  114611. * Sets the value of the `Square` button
  114612. */
  114613. set buttonSquare(value: number);
  114614. /**
  114615. * Gets the value of the `Triangle` button
  114616. */
  114617. get buttonTriangle(): number;
  114618. /**
  114619. * Sets the value of the `Triangle` button
  114620. */
  114621. set buttonTriangle(value: number);
  114622. /**
  114623. * Gets the value of the `Options` button
  114624. */
  114625. get buttonOptions(): number;
  114626. /**
  114627. * Sets the value of the `Options` button
  114628. */
  114629. set buttonOptions(value: number);
  114630. /**
  114631. * Gets the value of the `Share` button
  114632. */
  114633. get buttonShare(): number;
  114634. /**
  114635. * Sets the value of the `Share` button
  114636. */
  114637. set buttonShare(value: number);
  114638. /**
  114639. * Gets the value of the `L1` button
  114640. */
  114641. get buttonL1(): number;
  114642. /**
  114643. * Sets the value of the `L1` button
  114644. */
  114645. set buttonL1(value: number);
  114646. /**
  114647. * Gets the value of the `R1` button
  114648. */
  114649. get buttonR1(): number;
  114650. /**
  114651. * Sets the value of the `R1` button
  114652. */
  114653. set buttonR1(value: number);
  114654. /**
  114655. * Gets the value of the Left joystick
  114656. */
  114657. get buttonLeftStick(): number;
  114658. /**
  114659. * Sets the value of the Left joystick
  114660. */
  114661. set buttonLeftStick(value: number);
  114662. /**
  114663. * Gets the value of the Right joystick
  114664. */
  114665. get buttonRightStick(): number;
  114666. /**
  114667. * Sets the value of the Right joystick
  114668. */
  114669. set buttonRightStick(value: number);
  114670. /**
  114671. * Gets the value of D-pad up
  114672. */
  114673. get dPadUp(): number;
  114674. /**
  114675. * Sets the value of D-pad up
  114676. */
  114677. set dPadUp(value: number);
  114678. /**
  114679. * Gets the value of D-pad down
  114680. */
  114681. get dPadDown(): number;
  114682. /**
  114683. * Sets the value of D-pad down
  114684. */
  114685. set dPadDown(value: number);
  114686. /**
  114687. * Gets the value of D-pad left
  114688. */
  114689. get dPadLeft(): number;
  114690. /**
  114691. * Sets the value of D-pad left
  114692. */
  114693. set dPadLeft(value: number);
  114694. /**
  114695. * Gets the value of D-pad right
  114696. */
  114697. get dPadRight(): number;
  114698. /**
  114699. * Sets the value of D-pad right
  114700. */
  114701. set dPadRight(value: number);
  114702. /**
  114703. * Force the gamepad to synchronize with device values
  114704. */
  114705. update(): void;
  114706. /**
  114707. * Disposes the gamepad
  114708. */
  114709. dispose(): void;
  114710. }
  114711. }
  114712. declare module BABYLON {
  114713. /**
  114714. * Manager for handling gamepads
  114715. */
  114716. export class GamepadManager {
  114717. private _scene?;
  114718. private _babylonGamepads;
  114719. private _oneGamepadConnected;
  114720. /** @hidden */
  114721. _isMonitoring: boolean;
  114722. private _gamepadEventSupported;
  114723. private _gamepadSupport?;
  114724. /**
  114725. * observable to be triggered when the gamepad controller has been connected
  114726. */
  114727. onGamepadConnectedObservable: Observable<Gamepad>;
  114728. /**
  114729. * observable to be triggered when the gamepad controller has been disconnected
  114730. */
  114731. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114732. private _onGamepadConnectedEvent;
  114733. private _onGamepadDisconnectedEvent;
  114734. /**
  114735. * Initializes the gamepad manager
  114736. * @param _scene BabylonJS scene
  114737. */
  114738. constructor(_scene?: Scene | undefined);
  114739. /**
  114740. * The gamepads in the game pad manager
  114741. */
  114742. get gamepads(): Gamepad[];
  114743. /**
  114744. * Get the gamepad controllers based on type
  114745. * @param type The type of gamepad controller
  114746. * @returns Nullable gamepad
  114747. */
  114748. getGamepadByType(type?: number): Nullable<Gamepad>;
  114749. /**
  114750. * Disposes the gamepad manager
  114751. */
  114752. dispose(): void;
  114753. private _addNewGamepad;
  114754. private _startMonitoringGamepads;
  114755. private _stopMonitoringGamepads;
  114756. /** @hidden */
  114757. _checkGamepadsStatus(): void;
  114758. private _updateGamepadObjects;
  114759. }
  114760. }
  114761. declare module BABYLON {
  114762. interface Scene {
  114763. /** @hidden */
  114764. _gamepadManager: Nullable<GamepadManager>;
  114765. /**
  114766. * Gets the gamepad manager associated with the scene
  114767. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114768. */
  114769. gamepadManager: GamepadManager;
  114770. }
  114771. /**
  114772. * Interface representing a free camera inputs manager
  114773. */
  114774. interface FreeCameraInputsManager {
  114775. /**
  114776. * Adds gamepad input support to the FreeCameraInputsManager.
  114777. * @returns the FreeCameraInputsManager
  114778. */
  114779. addGamepad(): FreeCameraInputsManager;
  114780. }
  114781. /**
  114782. * Interface representing an arc rotate camera inputs manager
  114783. */
  114784. interface ArcRotateCameraInputsManager {
  114785. /**
  114786. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114787. * @returns the camera inputs manager
  114788. */
  114789. addGamepad(): ArcRotateCameraInputsManager;
  114790. }
  114791. /**
  114792. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114793. */
  114794. export class GamepadSystemSceneComponent implements ISceneComponent {
  114795. /**
  114796. * The component name helpfull to identify the component in the list of scene components.
  114797. */
  114798. readonly name: string;
  114799. /**
  114800. * The scene the component belongs to.
  114801. */
  114802. scene: Scene;
  114803. /**
  114804. * Creates a new instance of the component for the given scene
  114805. * @param scene Defines the scene to register the component in
  114806. */
  114807. constructor(scene: Scene);
  114808. /**
  114809. * Registers the component in a given scene
  114810. */
  114811. register(): void;
  114812. /**
  114813. * Rebuilds the elements related to this component in case of
  114814. * context lost for instance.
  114815. */
  114816. rebuild(): void;
  114817. /**
  114818. * Disposes the component and the associated ressources
  114819. */
  114820. dispose(): void;
  114821. private _beforeCameraUpdate;
  114822. }
  114823. }
  114824. declare module BABYLON {
  114825. /**
  114826. * 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,
  114827. * which still works and will still be found in many Playgrounds.
  114828. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114829. */
  114830. export class UniversalCamera extends TouchCamera {
  114831. /**
  114832. * Defines the gamepad rotation sensiblity.
  114833. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114834. */
  114835. get gamepadAngularSensibility(): number;
  114836. set gamepadAngularSensibility(value: number);
  114837. /**
  114838. * Defines the gamepad move sensiblity.
  114839. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114840. */
  114841. get gamepadMoveSensibility(): number;
  114842. set gamepadMoveSensibility(value: number);
  114843. /**
  114844. * 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,
  114845. * which still works and will still be found in many Playgrounds.
  114846. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114847. * @param name Define the name of the camera in the scene
  114848. * @param position Define the start position of the camera in the scene
  114849. * @param scene Define the scene the camera belongs to
  114850. */
  114851. constructor(name: string, position: Vector3, scene: Scene);
  114852. /**
  114853. * Gets the current object class name.
  114854. * @return the class name
  114855. */
  114856. getClassName(): string;
  114857. }
  114858. }
  114859. declare module BABYLON {
  114860. /**
  114861. * This represents a FPS type of camera. This is only here for back compat purpose.
  114862. * Please use the UniversalCamera instead as both are identical.
  114863. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114864. */
  114865. export class GamepadCamera extends UniversalCamera {
  114866. /**
  114867. * Instantiates a new Gamepad Camera
  114868. * This represents a FPS type of camera. This is only here for back compat purpose.
  114869. * Please use the UniversalCamera instead as both are identical.
  114870. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114871. * @param name Define the name of the camera in the scene
  114872. * @param position Define the start position of the camera in the scene
  114873. * @param scene Define the scene the camera belongs to
  114874. */
  114875. constructor(name: string, position: Vector3, scene: Scene);
  114876. /**
  114877. * Gets the current object class name.
  114878. * @return the class name
  114879. */
  114880. getClassName(): string;
  114881. }
  114882. }
  114883. declare module BABYLON {
  114884. /** @hidden */
  114885. export var passPixelShader: {
  114886. name: string;
  114887. shader: string;
  114888. };
  114889. }
  114890. declare module BABYLON {
  114891. /** @hidden */
  114892. export var passCubePixelShader: {
  114893. name: string;
  114894. shader: string;
  114895. };
  114896. }
  114897. declare module BABYLON {
  114898. /**
  114899. * PassPostProcess which produces an output the same as it's input
  114900. */
  114901. export class PassPostProcess extends PostProcess {
  114902. /**
  114903. * Creates the PassPostProcess
  114904. * @param name The name of the effect.
  114905. * @param options The required width/height ratio to downsize to before computing the render pass.
  114906. * @param camera The camera to apply the render pass to.
  114907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114908. * @param engine The engine which the post process will be applied. (default: current engine)
  114909. * @param reusable If the post process can be reused on the same frame. (default: false)
  114910. * @param textureType The type of texture to be used when performing the post processing.
  114911. * @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)
  114912. */
  114913. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114914. }
  114915. /**
  114916. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114917. */
  114918. export class PassCubePostProcess extends PostProcess {
  114919. private _face;
  114920. /**
  114921. * Gets or sets the cube face to display.
  114922. * * 0 is +X
  114923. * * 1 is -X
  114924. * * 2 is +Y
  114925. * * 3 is -Y
  114926. * * 4 is +Z
  114927. * * 5 is -Z
  114928. */
  114929. get face(): number;
  114930. set face(value: number);
  114931. /**
  114932. * Creates the PassCubePostProcess
  114933. * @param name The name of the effect.
  114934. * @param options The required width/height ratio to downsize to before computing the render pass.
  114935. * @param camera The camera to apply the render pass to.
  114936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114937. * @param engine The engine which the post process will be applied. (default: current engine)
  114938. * @param reusable If the post process can be reused on the same frame. (default: false)
  114939. * @param textureType The type of texture to be used when performing the post processing.
  114940. * @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)
  114941. */
  114942. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114943. }
  114944. }
  114945. declare module BABYLON {
  114946. /** @hidden */
  114947. export var anaglyphPixelShader: {
  114948. name: string;
  114949. shader: string;
  114950. };
  114951. }
  114952. declare module BABYLON {
  114953. /**
  114954. * Postprocess used to generate anaglyphic rendering
  114955. */
  114956. export class AnaglyphPostProcess extends PostProcess {
  114957. private _passedProcess;
  114958. /**
  114959. * Creates a new AnaglyphPostProcess
  114960. * @param name defines postprocess name
  114961. * @param options defines creation options or target ratio scale
  114962. * @param rigCameras defines cameras using this postprocess
  114963. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114964. * @param engine defines hosting engine
  114965. * @param reusable defines if the postprocess will be reused multiple times per frame
  114966. */
  114967. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114968. }
  114969. }
  114970. declare module BABYLON {
  114971. /**
  114972. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114973. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114974. */
  114975. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114976. /**
  114977. * Creates a new AnaglyphArcRotateCamera
  114978. * @param name defines camera name
  114979. * @param alpha defines alpha angle (in radians)
  114980. * @param beta defines beta angle (in radians)
  114981. * @param radius defines radius
  114982. * @param target defines camera target
  114983. * @param interaxialDistance defines distance between each color axis
  114984. * @param scene defines the hosting scene
  114985. */
  114986. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114987. /**
  114988. * Gets camera class name
  114989. * @returns AnaglyphArcRotateCamera
  114990. */
  114991. getClassName(): string;
  114992. }
  114993. }
  114994. declare module BABYLON {
  114995. /**
  114996. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114997. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114998. */
  114999. export class AnaglyphFreeCamera extends FreeCamera {
  115000. /**
  115001. * Creates a new AnaglyphFreeCamera
  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 AnaglyphFreeCamera
  115011. */
  115012. getClassName(): string;
  115013. }
  115014. }
  115015. declare module BABYLON {
  115016. /**
  115017. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115018. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115019. */
  115020. export class AnaglyphGamepadCamera extends GamepadCamera {
  115021. /**
  115022. * Creates a new AnaglyphGamepadCamera
  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 AnaglyphGamepadCamera
  115032. */
  115033. getClassName(): string;
  115034. }
  115035. }
  115036. declare module BABYLON {
  115037. /**
  115038. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115039. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115040. */
  115041. export class AnaglyphUniversalCamera extends UniversalCamera {
  115042. /**
  115043. * Creates a new AnaglyphUniversalCamera
  115044. * @param name defines camera name
  115045. * @param position defines initial position
  115046. * @param interaxialDistance defines distance between each color axis
  115047. * @param scene defines the hosting scene
  115048. */
  115049. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115050. /**
  115051. * Gets camera class name
  115052. * @returns AnaglyphUniversalCamera
  115053. */
  115054. getClassName(): string;
  115055. }
  115056. }
  115057. declare module BABYLON {
  115058. /** @hidden */
  115059. export var stereoscopicInterlacePixelShader: {
  115060. name: string;
  115061. shader: string;
  115062. };
  115063. }
  115064. declare module BABYLON {
  115065. /**
  115066. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115067. */
  115068. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115069. private _stepSize;
  115070. private _passedProcess;
  115071. /**
  115072. * Initializes a StereoscopicInterlacePostProcessI
  115073. * @param name The name of the effect.
  115074. * @param rigCameras The rig cameras to be appled to the post process
  115075. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115076. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115077. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115078. * @param engine The engine which the post process will be applied. (default: current engine)
  115079. * @param reusable If the post process can be reused on the same frame. (default: false)
  115080. */
  115081. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115082. }
  115083. /**
  115084. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115085. */
  115086. export class StereoscopicInterlacePostProcess extends PostProcess {
  115087. private _stepSize;
  115088. private _passedProcess;
  115089. /**
  115090. * Initializes a StereoscopicInterlacePostProcess
  115091. * @param name The name of the effect.
  115092. * @param rigCameras The rig cameras to be appled to the post process
  115093. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115095. * @param engine The engine which the post process will be applied. (default: current engine)
  115096. * @param reusable If the post process can be reused on the same frame. (default: false)
  115097. */
  115098. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115099. }
  115100. }
  115101. declare module BABYLON {
  115102. /**
  115103. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115104. * @see http://doc.babylonjs.com/features/cameras
  115105. */
  115106. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115107. /**
  115108. * Creates a new StereoscopicArcRotateCamera
  115109. * @param name defines camera name
  115110. * @param alpha defines alpha angle (in radians)
  115111. * @param beta defines beta angle (in radians)
  115112. * @param radius defines radius
  115113. * @param target defines camera target
  115114. * @param interaxialDistance defines distance between each color axis
  115115. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115116. * @param scene defines the hosting scene
  115117. */
  115118. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115119. /**
  115120. * Gets camera class name
  115121. * @returns StereoscopicArcRotateCamera
  115122. */
  115123. getClassName(): string;
  115124. }
  115125. }
  115126. declare module BABYLON {
  115127. /**
  115128. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115129. * @see http://doc.babylonjs.com/features/cameras
  115130. */
  115131. export class StereoscopicFreeCamera extends FreeCamera {
  115132. /**
  115133. * Creates a new StereoscopicFreeCamera
  115134. * @param name defines camera name
  115135. * @param position defines initial position
  115136. * @param interaxialDistance defines distance between each color axis
  115137. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115138. * @param scene defines the hosting scene
  115139. */
  115140. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115141. /**
  115142. * Gets camera class name
  115143. * @returns StereoscopicFreeCamera
  115144. */
  115145. getClassName(): string;
  115146. }
  115147. }
  115148. declare module BABYLON {
  115149. /**
  115150. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115151. * @see http://doc.babylonjs.com/features/cameras
  115152. */
  115153. export class StereoscopicGamepadCamera extends GamepadCamera {
  115154. /**
  115155. * Creates a new StereoscopicGamepadCamera
  115156. * @param name defines camera name
  115157. * @param position defines initial position
  115158. * @param interaxialDistance defines distance between each color axis
  115159. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115160. * @param scene defines the hosting scene
  115161. */
  115162. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115163. /**
  115164. * Gets camera class name
  115165. * @returns StereoscopicGamepadCamera
  115166. */
  115167. getClassName(): string;
  115168. }
  115169. }
  115170. declare module BABYLON {
  115171. /**
  115172. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115173. * @see http://doc.babylonjs.com/features/cameras
  115174. */
  115175. export class StereoscopicUniversalCamera extends UniversalCamera {
  115176. /**
  115177. * Creates a new StereoscopicUniversalCamera
  115178. * @param name defines camera name
  115179. * @param position defines initial position
  115180. * @param interaxialDistance defines distance between each color axis
  115181. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115182. * @param scene defines the hosting scene
  115183. */
  115184. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115185. /**
  115186. * Gets camera class name
  115187. * @returns StereoscopicUniversalCamera
  115188. */
  115189. getClassName(): string;
  115190. }
  115191. }
  115192. declare module BABYLON {
  115193. /**
  115194. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115195. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115196. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115197. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115198. */
  115199. export class VirtualJoysticksCamera extends FreeCamera {
  115200. /**
  115201. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115202. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115203. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115204. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115205. * @param name Define the name of the camera in the scene
  115206. * @param position Define the start position of the camera in the scene
  115207. * @param scene Define the scene the camera belongs to
  115208. */
  115209. constructor(name: string, position: Vector3, scene: Scene);
  115210. /**
  115211. * Gets the current object class name.
  115212. * @return the class name
  115213. */
  115214. getClassName(): string;
  115215. }
  115216. }
  115217. declare module BABYLON {
  115218. /**
  115219. * This represents all the required metrics to create a VR camera.
  115220. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115221. */
  115222. export class VRCameraMetrics {
  115223. /**
  115224. * Define the horizontal resolution off the screen.
  115225. */
  115226. hResolution: number;
  115227. /**
  115228. * Define the vertical resolution off the screen.
  115229. */
  115230. vResolution: number;
  115231. /**
  115232. * Define the horizontal screen size.
  115233. */
  115234. hScreenSize: number;
  115235. /**
  115236. * Define the vertical screen size.
  115237. */
  115238. vScreenSize: number;
  115239. /**
  115240. * Define the vertical screen center position.
  115241. */
  115242. vScreenCenter: number;
  115243. /**
  115244. * Define the distance of the eyes to the screen.
  115245. */
  115246. eyeToScreenDistance: number;
  115247. /**
  115248. * Define the distance between both lenses
  115249. */
  115250. lensSeparationDistance: number;
  115251. /**
  115252. * Define the distance between both viewer's eyes.
  115253. */
  115254. interpupillaryDistance: number;
  115255. /**
  115256. * Define the distortion factor of the VR postprocess.
  115257. * Please, touch with care.
  115258. */
  115259. distortionK: number[];
  115260. /**
  115261. * Define the chromatic aberration correction factors for the VR post process.
  115262. */
  115263. chromaAbCorrection: number[];
  115264. /**
  115265. * Define the scale factor of the post process.
  115266. * The smaller the better but the slower.
  115267. */
  115268. postProcessScaleFactor: number;
  115269. /**
  115270. * Define an offset for the lens center.
  115271. */
  115272. lensCenterOffset: number;
  115273. /**
  115274. * Define if the current vr camera should compensate the distortion of the lense or not.
  115275. */
  115276. compensateDistortion: boolean;
  115277. /**
  115278. * Defines if multiview should be enabled when rendering (Default: false)
  115279. */
  115280. multiviewEnabled: boolean;
  115281. /**
  115282. * Gets the rendering aspect ratio based on the provided resolutions.
  115283. */
  115284. get aspectRatio(): number;
  115285. /**
  115286. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115287. */
  115288. get aspectRatioFov(): number;
  115289. /**
  115290. * @hidden
  115291. */
  115292. get leftHMatrix(): Matrix;
  115293. /**
  115294. * @hidden
  115295. */
  115296. get rightHMatrix(): Matrix;
  115297. /**
  115298. * @hidden
  115299. */
  115300. get leftPreViewMatrix(): Matrix;
  115301. /**
  115302. * @hidden
  115303. */
  115304. get rightPreViewMatrix(): Matrix;
  115305. /**
  115306. * Get the default VRMetrics based on the most generic setup.
  115307. * @returns the default vr metrics
  115308. */
  115309. static GetDefault(): VRCameraMetrics;
  115310. }
  115311. }
  115312. declare module BABYLON {
  115313. /** @hidden */
  115314. export var vrDistortionCorrectionPixelShader: {
  115315. name: string;
  115316. shader: string;
  115317. };
  115318. }
  115319. declare module BABYLON {
  115320. /**
  115321. * VRDistortionCorrectionPostProcess used for mobile VR
  115322. */
  115323. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115324. private _isRightEye;
  115325. private _distortionFactors;
  115326. private _postProcessScaleFactor;
  115327. private _lensCenterOffset;
  115328. private _scaleIn;
  115329. private _scaleFactor;
  115330. private _lensCenter;
  115331. /**
  115332. * Initializes the VRDistortionCorrectionPostProcess
  115333. * @param name The name of the effect.
  115334. * @param camera The camera to apply the render pass to.
  115335. * @param isRightEye If this is for the right eye distortion
  115336. * @param vrMetrics All the required metrics for the VR camera
  115337. */
  115338. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115339. }
  115340. }
  115341. declare module BABYLON {
  115342. /**
  115343. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115344. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115345. */
  115346. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115347. /**
  115348. * Creates a new VRDeviceOrientationArcRotateCamera
  115349. * @param name defines camera name
  115350. * @param alpha defines the camera rotation along the logitudinal axis
  115351. * @param beta defines the camera rotation along the latitudinal axis
  115352. * @param radius defines the camera distance from its target
  115353. * @param target defines the camera target
  115354. * @param scene defines the scene the camera belongs to
  115355. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115356. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115357. */
  115358. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115359. /**
  115360. * Gets camera class name
  115361. * @returns VRDeviceOrientationArcRotateCamera
  115362. */
  115363. getClassName(): string;
  115364. }
  115365. }
  115366. declare module BABYLON {
  115367. /**
  115368. * Camera used to simulate VR rendering (based on FreeCamera)
  115369. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115370. */
  115371. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115372. /**
  115373. * Creates a new VRDeviceOrientationFreeCamera
  115374. * @param name defines camera name
  115375. * @param position defines the start position of the camera
  115376. * @param scene defines the scene the camera belongs to
  115377. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115378. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115379. */
  115380. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115381. /**
  115382. * Gets camera class name
  115383. * @returns VRDeviceOrientationFreeCamera
  115384. */
  115385. getClassName(): string;
  115386. }
  115387. }
  115388. declare module BABYLON {
  115389. /**
  115390. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115391. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115392. */
  115393. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115394. /**
  115395. * Creates a new VRDeviceOrientationGamepadCamera
  115396. * @param name defines camera name
  115397. * @param position defines the start position of the camera
  115398. * @param scene defines the scene the camera belongs to
  115399. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115400. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115401. */
  115402. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115403. /**
  115404. * Gets camera class name
  115405. * @returns VRDeviceOrientationGamepadCamera
  115406. */
  115407. getClassName(): string;
  115408. }
  115409. }
  115410. declare module BABYLON {
  115411. /** @hidden */
  115412. export var imageProcessingPixelShader: {
  115413. name: string;
  115414. shader: string;
  115415. };
  115416. }
  115417. declare module BABYLON {
  115418. /**
  115419. * ImageProcessingPostProcess
  115420. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115421. */
  115422. export class ImageProcessingPostProcess extends PostProcess {
  115423. /**
  115424. * Default configuration related to image processing available in the PBR Material.
  115425. */
  115426. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115427. /**
  115428. * Gets the image processing configuration used either in this material.
  115429. */
  115430. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115431. /**
  115432. * Sets the Default image processing configuration used either in the this material.
  115433. *
  115434. * If sets to null, the scene one is in use.
  115435. */
  115436. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115437. /**
  115438. * Keep track of the image processing observer to allow dispose and replace.
  115439. */
  115440. private _imageProcessingObserver;
  115441. /**
  115442. * Attaches a new image processing configuration to the PBR Material.
  115443. * @param configuration
  115444. */
  115445. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115446. /**
  115447. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115448. */
  115449. get colorCurves(): Nullable<ColorCurves>;
  115450. /**
  115451. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115452. */
  115453. set colorCurves(value: Nullable<ColorCurves>);
  115454. /**
  115455. * Gets wether the color curves effect is enabled.
  115456. */
  115457. get colorCurvesEnabled(): boolean;
  115458. /**
  115459. * Sets wether the color curves effect is enabled.
  115460. */
  115461. set colorCurvesEnabled(value: boolean);
  115462. /**
  115463. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115464. */
  115465. get colorGradingTexture(): Nullable<BaseTexture>;
  115466. /**
  115467. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115468. */
  115469. set colorGradingTexture(value: Nullable<BaseTexture>);
  115470. /**
  115471. * Gets wether the color grading effect is enabled.
  115472. */
  115473. get colorGradingEnabled(): boolean;
  115474. /**
  115475. * Gets wether the color grading effect is enabled.
  115476. */
  115477. set colorGradingEnabled(value: boolean);
  115478. /**
  115479. * Gets exposure used in the effect.
  115480. */
  115481. get exposure(): number;
  115482. /**
  115483. * Sets exposure used in the effect.
  115484. */
  115485. set exposure(value: number);
  115486. /**
  115487. * Gets wether tonemapping is enabled or not.
  115488. */
  115489. get toneMappingEnabled(): boolean;
  115490. /**
  115491. * Sets wether tonemapping is enabled or not
  115492. */
  115493. set toneMappingEnabled(value: boolean);
  115494. /**
  115495. * Gets the type of tone mapping effect.
  115496. */
  115497. get toneMappingType(): number;
  115498. /**
  115499. * Sets the type of tone mapping effect.
  115500. */
  115501. set toneMappingType(value: number);
  115502. /**
  115503. * Gets contrast used in the effect.
  115504. */
  115505. get contrast(): number;
  115506. /**
  115507. * Sets contrast used in the effect.
  115508. */
  115509. set contrast(value: number);
  115510. /**
  115511. * Gets Vignette stretch size.
  115512. */
  115513. get vignetteStretch(): number;
  115514. /**
  115515. * Sets Vignette stretch size.
  115516. */
  115517. set vignetteStretch(value: number);
  115518. /**
  115519. * Gets Vignette centre X Offset.
  115520. */
  115521. get vignetteCentreX(): number;
  115522. /**
  115523. * Sets Vignette centre X Offset.
  115524. */
  115525. set vignetteCentreX(value: number);
  115526. /**
  115527. * Gets Vignette centre Y Offset.
  115528. */
  115529. get vignetteCentreY(): number;
  115530. /**
  115531. * Sets Vignette centre Y Offset.
  115532. */
  115533. set vignetteCentreY(value: number);
  115534. /**
  115535. * Gets Vignette weight or intensity of the vignette effect.
  115536. */
  115537. get vignetteWeight(): number;
  115538. /**
  115539. * Sets Vignette weight or intensity of the vignette effect.
  115540. */
  115541. set vignetteWeight(value: number);
  115542. /**
  115543. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115544. * if vignetteEnabled is set to true.
  115545. */
  115546. get vignetteColor(): Color4;
  115547. /**
  115548. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115549. * if vignetteEnabled is set to true.
  115550. */
  115551. set vignetteColor(value: Color4);
  115552. /**
  115553. * Gets Camera field of view used by the Vignette effect.
  115554. */
  115555. get vignetteCameraFov(): number;
  115556. /**
  115557. * Sets Camera field of view used by the Vignette effect.
  115558. */
  115559. set vignetteCameraFov(value: number);
  115560. /**
  115561. * Gets the vignette blend mode allowing different kind of effect.
  115562. */
  115563. get vignetteBlendMode(): number;
  115564. /**
  115565. * Sets the vignette blend mode allowing different kind of effect.
  115566. */
  115567. set vignetteBlendMode(value: number);
  115568. /**
  115569. * Gets wether the vignette effect is enabled.
  115570. */
  115571. get vignetteEnabled(): boolean;
  115572. /**
  115573. * Sets wether the vignette effect is enabled.
  115574. */
  115575. set vignetteEnabled(value: boolean);
  115576. private _fromLinearSpace;
  115577. /**
  115578. * Gets wether the input of the processing is in Gamma or Linear Space.
  115579. */
  115580. get fromLinearSpace(): boolean;
  115581. /**
  115582. * Sets wether the input of the processing is in Gamma or Linear Space.
  115583. */
  115584. set fromLinearSpace(value: boolean);
  115585. /**
  115586. * Defines cache preventing GC.
  115587. */
  115588. private _defines;
  115589. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115590. /**
  115591. * "ImageProcessingPostProcess"
  115592. * @returns "ImageProcessingPostProcess"
  115593. */
  115594. getClassName(): string;
  115595. protected _updateParameters(): void;
  115596. dispose(camera?: Camera): void;
  115597. }
  115598. }
  115599. declare module BABYLON {
  115600. /**
  115601. * Class containing static functions to help procedurally build meshes
  115602. */
  115603. export class GroundBuilder {
  115604. /**
  115605. * Creates a ground mesh
  115606. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115607. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 ground mesh
  115613. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115614. */
  115615. static CreateGround(name: string, options: {
  115616. width?: number;
  115617. height?: number;
  115618. subdivisions?: number;
  115619. subdivisionsX?: number;
  115620. subdivisionsY?: number;
  115621. updatable?: boolean;
  115622. }, scene: any): Mesh;
  115623. /**
  115624. * Creates a tiled ground mesh
  115625. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115626. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115627. * * 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
  115628. * * 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
  115629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115630. * @param name defines the name of the mesh
  115631. * @param options defines the options used to create the mesh
  115632. * @param scene defines the hosting scene
  115633. * @returns the tiled ground mesh
  115634. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115635. */
  115636. static CreateTiledGround(name: string, options: {
  115637. xmin: number;
  115638. zmin: number;
  115639. xmax: number;
  115640. zmax: number;
  115641. subdivisions?: {
  115642. w: number;
  115643. h: number;
  115644. };
  115645. precision?: {
  115646. w: number;
  115647. h: number;
  115648. };
  115649. updatable?: boolean;
  115650. }, scene?: Nullable<Scene>): Mesh;
  115651. /**
  115652. * Creates a ground mesh from a height map
  115653. * * The parameter `url` sets the URL of the height map image resource.
  115654. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115655. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115656. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115657. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115658. * * 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.
  115659. * * 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).
  115660. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115662. * @param name defines the name of the mesh
  115663. * @param url defines the url to the height map
  115664. * @param options defines the options used to create the mesh
  115665. * @param scene defines the hosting scene
  115666. * @returns the ground mesh
  115667. * @see https://doc.babylonjs.com/babylon101/height_map
  115668. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115669. */
  115670. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115671. width?: number;
  115672. height?: number;
  115673. subdivisions?: number;
  115674. minHeight?: number;
  115675. maxHeight?: number;
  115676. colorFilter?: Color3;
  115677. alphaFilter?: number;
  115678. updatable?: boolean;
  115679. onReady?: (mesh: GroundMesh) => void;
  115680. }, scene?: Nullable<Scene>): GroundMesh;
  115681. }
  115682. }
  115683. declare module BABYLON {
  115684. /**
  115685. * Class containing static functions to help procedurally build meshes
  115686. */
  115687. export class TorusBuilder {
  115688. /**
  115689. * Creates a torus mesh
  115690. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115691. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115692. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115696. * @param name defines the name of the mesh
  115697. * @param options defines the options used to create the mesh
  115698. * @param scene defines the hosting scene
  115699. * @returns the torus mesh
  115700. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115701. */
  115702. static CreateTorus(name: string, options: {
  115703. diameter?: number;
  115704. thickness?: number;
  115705. tessellation?: number;
  115706. updatable?: boolean;
  115707. sideOrientation?: number;
  115708. frontUVs?: Vector4;
  115709. backUVs?: Vector4;
  115710. }, scene: any): Mesh;
  115711. }
  115712. }
  115713. declare module BABYLON {
  115714. /**
  115715. * Class containing static functions to help procedurally build meshes
  115716. */
  115717. export class CylinderBuilder {
  115718. /**
  115719. * Creates a cylinder or a cone mesh
  115720. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115721. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115722. * * 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.
  115723. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115724. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115725. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115726. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115727. * * 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).
  115728. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115729. * * 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).
  115730. * * 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
  115731. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115732. * * 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
  115733. * * 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.
  115734. * * If `enclose` is false, a ring surface is one element.
  115735. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115736. * * 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
  115737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115740. * @param name defines the name of the mesh
  115741. * @param options defines the options used to create the mesh
  115742. * @param scene defines the hosting scene
  115743. * @returns the cylinder mesh
  115744. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115745. */
  115746. static CreateCylinder(name: string, options: {
  115747. height?: number;
  115748. diameterTop?: number;
  115749. diameterBottom?: number;
  115750. diameter?: number;
  115751. tessellation?: number;
  115752. subdivisions?: number;
  115753. arc?: number;
  115754. faceColors?: Color4[];
  115755. faceUV?: Vector4[];
  115756. updatable?: boolean;
  115757. hasRings?: boolean;
  115758. enclose?: boolean;
  115759. cap?: number;
  115760. sideOrientation?: number;
  115761. frontUVs?: Vector4;
  115762. backUVs?: Vector4;
  115763. }, scene: any): Mesh;
  115764. }
  115765. }
  115766. declare module BABYLON {
  115767. /**
  115768. * States of the webXR experience
  115769. */
  115770. export enum WebXRState {
  115771. /**
  115772. * Transitioning to being in XR mode
  115773. */
  115774. ENTERING_XR = 0,
  115775. /**
  115776. * Transitioning to non XR mode
  115777. */
  115778. EXITING_XR = 1,
  115779. /**
  115780. * In XR mode and presenting
  115781. */
  115782. IN_XR = 2,
  115783. /**
  115784. * Not entered XR mode
  115785. */
  115786. NOT_IN_XR = 3
  115787. }
  115788. /**
  115789. * Abstraction of the XR render target
  115790. */
  115791. export interface WebXRRenderTarget extends IDisposable {
  115792. /**
  115793. * xrpresent context of the canvas which can be used to display/mirror xr content
  115794. */
  115795. canvasContext: WebGLRenderingContext;
  115796. /**
  115797. * xr layer for the canvas
  115798. */
  115799. xrLayer: Nullable<XRWebGLLayer>;
  115800. /**
  115801. * Initializes the xr layer for the session
  115802. * @param xrSession xr session
  115803. * @returns a promise that will resolve once the XR Layer has been created
  115804. */
  115805. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115806. }
  115807. }
  115808. declare module BABYLON {
  115809. /**
  115810. * COnfiguration object for WebXR output canvas
  115811. */
  115812. export class WebXRManagedOutputCanvasOptions {
  115813. /**
  115814. * An optional canvas in case you wish to create it yourself and provide it here.
  115815. * If not provided, a new canvas will be created
  115816. */
  115817. canvasElement?: HTMLCanvasElement;
  115818. /**
  115819. * Options for this XR Layer output
  115820. */
  115821. canvasOptions?: XRWebGLLayerOptions;
  115822. /**
  115823. * CSS styling for a newly created canvas (if not provided)
  115824. */
  115825. newCanvasCssStyle?: string;
  115826. /**
  115827. * Get the default values of the configuration object
  115828. * @returns default values of this configuration object
  115829. */
  115830. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115831. }
  115832. /**
  115833. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115834. */
  115835. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115836. private _options;
  115837. private _canvas;
  115838. private _engine;
  115839. /**
  115840. * Rendering context of the canvas which can be used to display/mirror xr content
  115841. */
  115842. canvasContext: WebGLRenderingContext;
  115843. /**
  115844. * xr layer for the canvas
  115845. */
  115846. xrLayer: Nullable<XRWebGLLayer>;
  115847. /**
  115848. * Initializes the canvas to be added/removed upon entering/exiting xr
  115849. * @param _xrSessionManager The XR Session manager
  115850. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115851. */
  115852. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115853. /**
  115854. * Disposes of the object
  115855. */
  115856. dispose(): void;
  115857. /**
  115858. * Initializes the xr layer for the session
  115859. * @param xrSession xr session
  115860. * @returns a promise that will resolve once the XR Layer has been created
  115861. */
  115862. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115863. private _addCanvas;
  115864. private _removeCanvas;
  115865. private _setManagedOutputCanvas;
  115866. }
  115867. }
  115868. declare module BABYLON {
  115869. /**
  115870. * Manages an XRSession to work with Babylon's engine
  115871. * @see https://doc.babylonjs.com/how_to/webxr
  115872. */
  115873. export class WebXRSessionManager implements IDisposable {
  115874. /** The scene which the session should be created for */
  115875. scene: Scene;
  115876. private _referenceSpace;
  115877. private _rttProvider;
  115878. private _sessionEnded;
  115879. private _xrNavigator;
  115880. private baseLayer;
  115881. /**
  115882. * The base reference space from which the session started. good if you want to reset your
  115883. * reference space
  115884. */
  115885. baseReferenceSpace: XRReferenceSpace;
  115886. /**
  115887. * Current XR frame
  115888. */
  115889. currentFrame: Nullable<XRFrame>;
  115890. /** WebXR timestamp updated every frame */
  115891. currentTimestamp: number;
  115892. /**
  115893. * Used just in case of a failure to initialize an immersive session.
  115894. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115895. */
  115896. defaultHeightCompensation: number;
  115897. /**
  115898. * Fires every time a new xrFrame arrives which can be used to update the camera
  115899. */
  115900. onXRFrameObservable: Observable<XRFrame>;
  115901. /**
  115902. * Fires when the reference space changed
  115903. */
  115904. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115905. /**
  115906. * Fires when the xr session is ended either by the device or manually done
  115907. */
  115908. onXRSessionEnded: Observable<any>;
  115909. /**
  115910. * Fires when the xr session is ended either by the device or manually done
  115911. */
  115912. onXRSessionInit: Observable<XRSession>;
  115913. /**
  115914. * Underlying xr session
  115915. */
  115916. session: XRSession;
  115917. /**
  115918. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115919. * or get the offset the player is currently at.
  115920. */
  115921. viewerReferenceSpace: XRReferenceSpace;
  115922. /**
  115923. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115924. * @param scene The scene which the session should be created for
  115925. */
  115926. constructor(
  115927. /** The scene which the session should be created for */
  115928. scene: Scene);
  115929. /**
  115930. * The current reference space used in this session. This reference space can constantly change!
  115931. * It is mainly used to offset the camera's position.
  115932. */
  115933. get referenceSpace(): XRReferenceSpace;
  115934. /**
  115935. * Set a new reference space and triggers the observable
  115936. */
  115937. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115938. /**
  115939. * Disposes of the session manager
  115940. */
  115941. dispose(): void;
  115942. /**
  115943. * Stops the xrSession and restores the render loop
  115944. * @returns Promise which resolves after it exits XR
  115945. */
  115946. exitXRAsync(): Promise<void>;
  115947. /**
  115948. * Gets the correct render target texture to be rendered this frame for this eye
  115949. * @param eye the eye for which to get the render target
  115950. * @returns the render target for the specified eye
  115951. */
  115952. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115953. /**
  115954. * Creates a WebXRRenderTarget object for the XR session
  115955. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115956. * @param options optional options to provide when creating a new render target
  115957. * @returns a WebXR render target to which the session can render
  115958. */
  115959. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115960. /**
  115961. * Initializes the manager
  115962. * After initialization enterXR can be called to start an XR session
  115963. * @returns Promise which resolves after it is initialized
  115964. */
  115965. initializeAsync(): Promise<void>;
  115966. /**
  115967. * Initializes an xr session
  115968. * @param xrSessionMode mode to initialize
  115969. * @param xrSessionInit defines optional and required values to pass to the session builder
  115970. * @returns a promise which will resolve once the session has been initialized
  115971. */
  115972. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115973. /**
  115974. * Checks if a session would be supported for the creation options specified
  115975. * @param sessionMode session mode to check if supported eg. immersive-vr
  115976. * @returns A Promise that resolves to true if supported and false if not
  115977. */
  115978. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115979. /**
  115980. * Resets the reference space to the one started the session
  115981. */
  115982. resetReferenceSpace(): void;
  115983. /**
  115984. * Starts rendering to the xr layer
  115985. */
  115986. runXRRenderLoop(): void;
  115987. /**
  115988. * Sets the reference space on the xr session
  115989. * @param referenceSpaceType space to set
  115990. * @returns a promise that will resolve once the reference space has been set
  115991. */
  115992. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115993. /**
  115994. * Updates the render state of the session
  115995. * @param state state to set
  115996. * @returns a promise that resolves once the render state has been updated
  115997. */
  115998. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115999. /**
  116000. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116001. * @param sessionMode defines the session to test
  116002. * @returns a promise with boolean as final value
  116003. */
  116004. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116005. private _createRenderTargetTexture;
  116006. }
  116007. }
  116008. declare module BABYLON {
  116009. /**
  116010. * WebXR Camera which holds the views for the xrSession
  116011. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116012. */
  116013. export class WebXRCamera extends FreeCamera {
  116014. private _xrSessionManager;
  116015. private _firstFrame;
  116016. private _referenceQuaternion;
  116017. private _referencedPosition;
  116018. private _xrInvPositionCache;
  116019. private _xrInvQuaternionCache;
  116020. /**
  116021. * Should position compensation execute on first frame.
  116022. * This is used when copying the position from a native (non XR) camera
  116023. */
  116024. compensateOnFirstFrame: boolean;
  116025. /**
  116026. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116027. * @param name the name of the camera
  116028. * @param scene the scene to add the camera to
  116029. * @param _xrSessionManager a constructed xr session manager
  116030. */
  116031. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116032. /**
  116033. * Return the user's height, unrelated to the current ground.
  116034. * This will be the y position of this camera, when ground level is 0.
  116035. */
  116036. get realWorldHeight(): number;
  116037. /** @hidden */
  116038. _updateForDualEyeDebugging(): void;
  116039. /**
  116040. * Sets this camera's transformation based on a non-vr camera
  116041. * @param otherCamera the non-vr camera to copy the transformation from
  116042. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116043. */
  116044. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116045. /**
  116046. * Gets the current instance class name ("WebXRCamera").
  116047. * @returns the class name
  116048. */
  116049. getClassName(): string;
  116050. private _updateFromXRSession;
  116051. private _updateNumberOfRigCameras;
  116052. private _updateReferenceSpace;
  116053. private _updateReferenceSpaceOffset;
  116054. }
  116055. }
  116056. declare module BABYLON {
  116057. /**
  116058. * Defining the interface required for a (webxr) feature
  116059. */
  116060. export interface IWebXRFeature extends IDisposable {
  116061. /**
  116062. * Is this feature attached
  116063. */
  116064. attached: boolean;
  116065. /**
  116066. * Should auto-attach be disabled?
  116067. */
  116068. disableAutoAttach: boolean;
  116069. /**
  116070. * Attach the feature to the session
  116071. * Will usually be called by the features manager
  116072. *
  116073. * @param force should attachment be forced (even when already attached)
  116074. * @returns true if successful.
  116075. */
  116076. attach(force?: boolean): boolean;
  116077. /**
  116078. * Detach the feature from the session
  116079. * Will usually be called by the features manager
  116080. *
  116081. * @returns true if successful.
  116082. */
  116083. detach(): boolean;
  116084. }
  116085. /**
  116086. * A list of the currently available features without referencing them
  116087. */
  116088. export class WebXRFeatureName {
  116089. /**
  116090. * The name of the anchor system feature
  116091. */
  116092. static ANCHOR_SYSTEM: string;
  116093. /**
  116094. * The name of the background remover feature
  116095. */
  116096. static BACKGROUND_REMOVER: string;
  116097. /**
  116098. * The name of the hit test feature
  116099. */
  116100. static HIT_TEST: string;
  116101. /**
  116102. * physics impostors for xr controllers feature
  116103. */
  116104. static PHYSICS_CONTROLLERS: string;
  116105. /**
  116106. * The name of the plane detection feature
  116107. */
  116108. static PLANE_DETECTION: string;
  116109. /**
  116110. * The name of the pointer selection feature
  116111. */
  116112. static POINTER_SELECTION: string;
  116113. /**
  116114. * The name of the teleportation feature
  116115. */
  116116. static TELEPORTATION: string;
  116117. }
  116118. /**
  116119. * Defining the constructor of a feature. Used to register the modules.
  116120. */
  116121. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116122. /**
  116123. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116124. * It is mainly used in AR sessions.
  116125. *
  116126. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116127. */
  116128. export class WebXRFeaturesManager implements IDisposable {
  116129. private _xrSessionManager;
  116130. private static readonly _AvailableFeatures;
  116131. private _features;
  116132. /**
  116133. * constructs a new features manages.
  116134. *
  116135. * @param _xrSessionManager an instance of WebXRSessionManager
  116136. */
  116137. constructor(_xrSessionManager: WebXRSessionManager);
  116138. /**
  116139. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116140. * Mainly used internally.
  116141. *
  116142. * @param featureName the name of the feature to register
  116143. * @param constructorFunction the function used to construct the module
  116144. * @param version the (babylon) version of the module
  116145. * @param stable is that a stable version of this module
  116146. */
  116147. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116148. /**
  116149. * Returns a constructor of a specific feature.
  116150. *
  116151. * @param featureName the name of the feature to construct
  116152. * @param version the version of the feature to load
  116153. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116154. * @param options optional options provided to the module.
  116155. * @returns a function that, when called, will return a new instance of this feature
  116156. */
  116157. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116158. /**
  116159. * Can be used to return the list of features currently registered
  116160. *
  116161. * @returns an Array of available features
  116162. */
  116163. static GetAvailableFeatures(): string[];
  116164. /**
  116165. * Gets the versions available for a specific feature
  116166. * @param featureName the name of the feature
  116167. * @returns an array with the available versions
  116168. */
  116169. static GetAvailableVersions(featureName: string): string[];
  116170. /**
  116171. * Return the latest unstable version of this feature
  116172. * @param featureName the name of the feature to search
  116173. * @returns the version number. if not found will return -1
  116174. */
  116175. static GetLatestVersionOfFeature(featureName: string): number;
  116176. /**
  116177. * Return the latest stable version of this feature
  116178. * @param featureName the name of the feature to search
  116179. * @returns the version number. if not found will return -1
  116180. */
  116181. static GetStableVersionOfFeature(featureName: string): number;
  116182. /**
  116183. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116184. * Can be used during a session to start a feature
  116185. * @param featureName the name of feature to attach
  116186. */
  116187. attachFeature(featureName: string): void;
  116188. /**
  116189. * Can be used inside a session or when the session ends to detach a specific feature
  116190. * @param featureName the name of the feature to detach
  116191. */
  116192. detachFeature(featureName: string): void;
  116193. /**
  116194. * Used to disable an already-enabled feature
  116195. * The feature will be disposed and will be recreated once enabled.
  116196. * @param featureName the feature to disable
  116197. * @returns true if disable was successful
  116198. */
  116199. disableFeature(featureName: string | {
  116200. Name: string;
  116201. }): boolean;
  116202. /**
  116203. * dispose this features manager
  116204. */
  116205. dispose(): void;
  116206. /**
  116207. * 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.
  116208. * 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.
  116209. *
  116210. * @param featureName the name of the feature to load or the class of the feature
  116211. * @param version optional version to load. if not provided the latest version will be enabled
  116212. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116213. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116214. * @returns a new constructed feature or throws an error if feature not found.
  116215. */
  116216. enableFeature(featureName: string | {
  116217. Name: string;
  116218. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116219. /**
  116220. * get the implementation of an enabled feature.
  116221. * @param featureName the name of the feature to load
  116222. * @returns the feature class, if found
  116223. */
  116224. getEnabledFeature(featureName: string): IWebXRFeature;
  116225. /**
  116226. * Get the list of enabled features
  116227. * @returns an array of enabled features
  116228. */
  116229. getEnabledFeatures(): string[];
  116230. }
  116231. }
  116232. declare module BABYLON {
  116233. /**
  116234. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116235. * @see https://doc.babylonjs.com/how_to/webxr
  116236. */
  116237. export class WebXRExperienceHelper implements IDisposable {
  116238. private scene;
  116239. private _nonVRCamera;
  116240. private _originalSceneAutoClear;
  116241. private _supported;
  116242. /**
  116243. * Camera used to render xr content
  116244. */
  116245. camera: WebXRCamera;
  116246. /** A features manager for this xr session */
  116247. featuresManager: WebXRFeaturesManager;
  116248. /**
  116249. * Observers registered here will be triggered after the camera's initial transformation is set
  116250. * This can be used to set a different ground level or an extra rotation.
  116251. *
  116252. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116253. * to the position set after this observable is done executing.
  116254. */
  116255. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116256. /**
  116257. * Fires when the state of the experience helper has changed
  116258. */
  116259. onStateChangedObservable: Observable<WebXRState>;
  116260. /** Session manager used to keep track of xr session */
  116261. sessionManager: WebXRSessionManager;
  116262. /**
  116263. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116264. */
  116265. state: WebXRState;
  116266. /**
  116267. * Creates a WebXRExperienceHelper
  116268. * @param scene The scene the helper should be created in
  116269. */
  116270. private constructor();
  116271. /**
  116272. * Creates the experience helper
  116273. * @param scene the scene to attach the experience helper to
  116274. * @returns a promise for the experience helper
  116275. */
  116276. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116277. /**
  116278. * Disposes of the experience helper
  116279. */
  116280. dispose(): void;
  116281. /**
  116282. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116283. * @param sessionMode options for the XR session
  116284. * @param referenceSpaceType frame of reference of the XR session
  116285. * @param renderTarget the output canvas that will be used to enter XR mode
  116286. * @returns promise that resolves after xr mode has entered
  116287. */
  116288. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116289. /**
  116290. * Exits XR mode and returns the scene to its original state
  116291. * @returns promise that resolves after xr mode has exited
  116292. */
  116293. exitXRAsync(): Promise<void>;
  116294. private _nonXRToXRCamera;
  116295. private _setState;
  116296. }
  116297. }
  116298. declare module BABYLON {
  116299. /**
  116300. * X-Y values for axes in WebXR
  116301. */
  116302. export interface IWebXRMotionControllerAxesValue {
  116303. /**
  116304. * The value of the x axis
  116305. */
  116306. x: number;
  116307. /**
  116308. * The value of the y-axis
  116309. */
  116310. y: number;
  116311. }
  116312. /**
  116313. * changed / previous values for the values of this component
  116314. */
  116315. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116316. /**
  116317. * current (this frame) value
  116318. */
  116319. current: T;
  116320. /**
  116321. * previous (last change) value
  116322. */
  116323. previous: T;
  116324. }
  116325. /**
  116326. * Represents changes in the component between current frame and last values recorded
  116327. */
  116328. export interface IWebXRMotionControllerComponentChanges {
  116329. /**
  116330. * will be populated with previous and current values if axes changed
  116331. */
  116332. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116333. /**
  116334. * will be populated with previous and current values if pressed changed
  116335. */
  116336. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116337. /**
  116338. * will be populated with previous and current values if touched changed
  116339. */
  116340. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116341. /**
  116342. * will be populated with previous and current values if value changed
  116343. */
  116344. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116345. }
  116346. /**
  116347. * This class represents a single component (for example button or thumbstick) of a motion controller
  116348. */
  116349. export class WebXRControllerComponent implements IDisposable {
  116350. /**
  116351. * the id of this component
  116352. */
  116353. id: string;
  116354. /**
  116355. * the type of the component
  116356. */
  116357. type: MotionControllerComponentType;
  116358. private _buttonIndex;
  116359. private _axesIndices;
  116360. private _axes;
  116361. private _changes;
  116362. private _currentValue;
  116363. private _hasChanges;
  116364. private _pressed;
  116365. private _touched;
  116366. /**
  116367. * button component type
  116368. */
  116369. static BUTTON_TYPE: MotionControllerComponentType;
  116370. /**
  116371. * squeeze component type
  116372. */
  116373. static SQUEEZE_TYPE: MotionControllerComponentType;
  116374. /**
  116375. * Thumbstick component type
  116376. */
  116377. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116378. /**
  116379. * Touchpad component type
  116380. */
  116381. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116382. /**
  116383. * trigger component type
  116384. */
  116385. static TRIGGER_TYPE: MotionControllerComponentType;
  116386. /**
  116387. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116388. * the axes data changes
  116389. */
  116390. onAxisValueChangedObservable: Observable<{
  116391. x: number;
  116392. y: number;
  116393. }>;
  116394. /**
  116395. * Observers registered here will be triggered when the state of a button changes
  116396. * State change is either pressed / touched / value
  116397. */
  116398. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116399. /**
  116400. * Creates a new component for a motion controller.
  116401. * It is created by the motion controller itself
  116402. *
  116403. * @param id the id of this component
  116404. * @param type the type of the component
  116405. * @param _buttonIndex index in the buttons array of the gamepad
  116406. * @param _axesIndices indices of the values in the axes array of the gamepad
  116407. */
  116408. constructor(
  116409. /**
  116410. * the id of this component
  116411. */
  116412. id: string,
  116413. /**
  116414. * the type of the component
  116415. */
  116416. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116417. /**
  116418. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116419. */
  116420. get axes(): IWebXRMotionControllerAxesValue;
  116421. /**
  116422. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116423. */
  116424. get changes(): IWebXRMotionControllerComponentChanges;
  116425. /**
  116426. * Return whether or not the component changed the last frame
  116427. */
  116428. get hasChanges(): boolean;
  116429. /**
  116430. * is the button currently pressed
  116431. */
  116432. get pressed(): boolean;
  116433. /**
  116434. * is the button currently touched
  116435. */
  116436. get touched(): boolean;
  116437. /**
  116438. * Get the current value of this component
  116439. */
  116440. get value(): number;
  116441. /**
  116442. * Dispose this component
  116443. */
  116444. dispose(): void;
  116445. /**
  116446. * Are there axes correlating to this component
  116447. * @return true is axes data is available
  116448. */
  116449. isAxes(): boolean;
  116450. /**
  116451. * Is this component a button (hence - pressable)
  116452. * @returns true if can be pressed
  116453. */
  116454. isButton(): boolean;
  116455. /**
  116456. * update this component using the gamepad object it is in. Called on every frame
  116457. * @param nativeController the native gamepad controller object
  116458. */
  116459. update(nativeController: IMinimalMotionControllerObject): void;
  116460. }
  116461. }
  116462. declare module BABYLON {
  116463. /**
  116464. * Class used to represent data loading progression
  116465. */
  116466. export class SceneLoaderProgressEvent {
  116467. /** defines if data length to load can be evaluated */
  116468. readonly lengthComputable: boolean;
  116469. /** defines the loaded data length */
  116470. readonly loaded: number;
  116471. /** defines the data length to load */
  116472. readonly total: number;
  116473. /**
  116474. * Create a new progress event
  116475. * @param lengthComputable defines if data length to load can be evaluated
  116476. * @param loaded defines the loaded data length
  116477. * @param total defines the data length to load
  116478. */
  116479. constructor(
  116480. /** defines if data length to load can be evaluated */
  116481. lengthComputable: boolean,
  116482. /** defines the loaded data length */
  116483. loaded: number,
  116484. /** defines the data length to load */
  116485. total: number);
  116486. /**
  116487. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116488. * @param event defines the source event
  116489. * @returns a new SceneLoaderProgressEvent
  116490. */
  116491. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116492. }
  116493. /**
  116494. * Interface used by SceneLoader plugins to define supported file extensions
  116495. */
  116496. export interface ISceneLoaderPluginExtensions {
  116497. /**
  116498. * Defines the list of supported extensions
  116499. */
  116500. [extension: string]: {
  116501. isBinary: boolean;
  116502. };
  116503. }
  116504. /**
  116505. * Interface used by SceneLoader plugin factory
  116506. */
  116507. export interface ISceneLoaderPluginFactory {
  116508. /**
  116509. * Defines the name of the factory
  116510. */
  116511. name: string;
  116512. /**
  116513. * Function called to create a new plugin
  116514. * @return the new plugin
  116515. */
  116516. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116517. /**
  116518. * The callback that returns true if the data can be directly loaded.
  116519. * @param data string containing the file data
  116520. * @returns if the data can be loaded directly
  116521. */
  116522. canDirectLoad?(data: string): boolean;
  116523. }
  116524. /**
  116525. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116526. */
  116527. export interface ISceneLoaderPluginBase {
  116528. /**
  116529. * The friendly name of this plugin.
  116530. */
  116531. name: string;
  116532. /**
  116533. * The file extensions supported by this plugin.
  116534. */
  116535. extensions: string | ISceneLoaderPluginExtensions;
  116536. /**
  116537. * The callback called when loading from a url.
  116538. * @param scene scene loading this url
  116539. * @param url url to load
  116540. * @param onSuccess callback called when the file successfully loads
  116541. * @param onProgress callback called while file is loading (if the server supports this mode)
  116542. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116543. * @param onError callback called when the file fails to load
  116544. * @returns a file request object
  116545. */
  116546. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116547. /**
  116548. * The callback called when loading from a file object.
  116549. * @param scene scene loading this file
  116550. * @param file defines the file to load
  116551. * @param onSuccess defines the callback to call when data is loaded
  116552. * @param onProgress defines the callback to call during loading process
  116553. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116554. * @param onError defines the callback to call when an error occurs
  116555. * @returns a file request object
  116556. */
  116557. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116558. /**
  116559. * The callback that returns true if the data can be directly loaded.
  116560. * @param data string containing the file data
  116561. * @returns if the data can be loaded directly
  116562. */
  116563. canDirectLoad?(data: string): boolean;
  116564. /**
  116565. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116566. * @param scene scene loading this data
  116567. * @param data string containing the data
  116568. * @returns data to pass to the plugin
  116569. */
  116570. directLoad?(scene: Scene, data: string): any;
  116571. /**
  116572. * The callback that allows custom handling of the root url based on the response url.
  116573. * @param rootUrl the original root url
  116574. * @param responseURL the response url if available
  116575. * @returns the new root url
  116576. */
  116577. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116578. }
  116579. /**
  116580. * Interface used to define a SceneLoader plugin
  116581. */
  116582. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116583. /**
  116584. * Import meshes into a scene.
  116585. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116586. * @param scene The scene to import into
  116587. * @param data The data to import
  116588. * @param rootUrl The root url for scene and resources
  116589. * @param meshes The meshes array to import into
  116590. * @param particleSystems The particle systems array to import into
  116591. * @param skeletons The skeletons array to import into
  116592. * @param onError The callback when import fails
  116593. * @returns True if successful or false otherwise
  116594. */
  116595. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116596. /**
  116597. * Load into a scene.
  116598. * @param scene The scene to load into
  116599. * @param data The data to import
  116600. * @param rootUrl The root url for scene and resources
  116601. * @param onError The callback when import fails
  116602. * @returns True if successful or false otherwise
  116603. */
  116604. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116605. /**
  116606. * Load into an asset container.
  116607. * @param scene The scene to load into
  116608. * @param data The data to import
  116609. * @param rootUrl The root url for scene and resources
  116610. * @param onError The callback when import fails
  116611. * @returns The loaded asset container
  116612. */
  116613. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116614. }
  116615. /**
  116616. * Interface used to define an async SceneLoader plugin
  116617. */
  116618. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116619. /**
  116620. * Import meshes into a scene.
  116621. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116622. * @param scene The scene to import into
  116623. * @param data The data to import
  116624. * @param rootUrl The root url for scene and resources
  116625. * @param onProgress The callback when the load progresses
  116626. * @param fileName Defines the name of the file to load
  116627. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116628. */
  116629. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116630. meshes: AbstractMesh[];
  116631. particleSystems: IParticleSystem[];
  116632. skeletons: Skeleton[];
  116633. animationGroups: AnimationGroup[];
  116634. }>;
  116635. /**
  116636. * Load into a scene.
  116637. * @param scene The scene to load into
  116638. * @param data The data to import
  116639. * @param rootUrl The root url for scene and resources
  116640. * @param onProgress The callback when the load progresses
  116641. * @param fileName Defines the name of the file to load
  116642. * @returns Nothing
  116643. */
  116644. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116645. /**
  116646. * Load into an asset container.
  116647. * @param scene The scene to load into
  116648. * @param data The data to import
  116649. * @param rootUrl The root url for scene and resources
  116650. * @param onProgress The callback when the load progresses
  116651. * @param fileName Defines the name of the file to load
  116652. * @returns The loaded asset container
  116653. */
  116654. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116655. }
  116656. /**
  116657. * Mode that determines how to handle old animation groups before loading new ones.
  116658. */
  116659. export enum SceneLoaderAnimationGroupLoadingMode {
  116660. /**
  116661. * Reset all old animations to initial state then dispose them.
  116662. */
  116663. Clean = 0,
  116664. /**
  116665. * Stop all old animations.
  116666. */
  116667. Stop = 1,
  116668. /**
  116669. * Restart old animations from first frame.
  116670. */
  116671. Sync = 2,
  116672. /**
  116673. * Old animations remains untouched.
  116674. */
  116675. NoSync = 3
  116676. }
  116677. /**
  116678. * Class used to load scene from various file formats using registered plugins
  116679. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116680. */
  116681. export class SceneLoader {
  116682. /**
  116683. * No logging while loading
  116684. */
  116685. static readonly NO_LOGGING: number;
  116686. /**
  116687. * Minimal logging while loading
  116688. */
  116689. static readonly MINIMAL_LOGGING: number;
  116690. /**
  116691. * Summary logging while loading
  116692. */
  116693. static readonly SUMMARY_LOGGING: number;
  116694. /**
  116695. * Detailled logging while loading
  116696. */
  116697. static readonly DETAILED_LOGGING: number;
  116698. /**
  116699. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116700. */
  116701. static get ForceFullSceneLoadingForIncremental(): boolean;
  116702. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116703. /**
  116704. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116705. */
  116706. static get ShowLoadingScreen(): boolean;
  116707. static set ShowLoadingScreen(value: boolean);
  116708. /**
  116709. * Defines the current logging level (while loading the scene)
  116710. * @ignorenaming
  116711. */
  116712. static get loggingLevel(): number;
  116713. static set loggingLevel(value: number);
  116714. /**
  116715. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116716. */
  116717. static get CleanBoneMatrixWeights(): boolean;
  116718. static set CleanBoneMatrixWeights(value: boolean);
  116719. /**
  116720. * Event raised when a plugin is used to load a scene
  116721. */
  116722. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116723. private static _registeredPlugins;
  116724. private static _getDefaultPlugin;
  116725. private static _getPluginForExtension;
  116726. private static _getPluginForDirectLoad;
  116727. private static _getPluginForFilename;
  116728. private static _getDirectLoad;
  116729. private static _loadData;
  116730. private static _getFileInfo;
  116731. /**
  116732. * Gets a plugin that can load the given extension
  116733. * @param extension defines the extension to load
  116734. * @returns a plugin or null if none works
  116735. */
  116736. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116737. /**
  116738. * Gets a boolean indicating that the given extension can be loaded
  116739. * @param extension defines the extension to load
  116740. * @returns true if the extension is supported
  116741. */
  116742. static IsPluginForExtensionAvailable(extension: string): boolean;
  116743. /**
  116744. * Adds a new plugin to the list of registered plugins
  116745. * @param plugin defines the plugin to add
  116746. */
  116747. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116748. /**
  116749. * Import meshes into a scene
  116750. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116751. * @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)
  116752. * @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)
  116753. * @param scene the instance of BABYLON.Scene to append to
  116754. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116755. * @param onProgress a callback with a progress event for each file being loaded
  116756. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116757. * @param pluginExtension the extension used to determine the plugin
  116758. * @returns The loaded plugin
  116759. */
  116760. 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>;
  116761. /**
  116762. * Import meshes into a scene
  116763. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116764. * @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)
  116765. * @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)
  116766. * @param scene the instance of BABYLON.Scene to append to
  116767. * @param onProgress a callback with a progress event for each file being loaded
  116768. * @param pluginExtension the extension used to determine the plugin
  116769. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116770. */
  116771. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116772. meshes: AbstractMesh[];
  116773. particleSystems: IParticleSystem[];
  116774. skeletons: Skeleton[];
  116775. animationGroups: AnimationGroup[];
  116776. }>;
  116777. /**
  116778. * Load a scene
  116779. * @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)
  116780. * @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)
  116781. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116782. * @param onSuccess a callback with the scene when import succeeds
  116783. * @param onProgress a callback with a progress event for each file being loaded
  116784. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116785. * @param pluginExtension the extension used to determine the plugin
  116786. * @returns The loaded plugin
  116787. */
  116788. 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>;
  116789. /**
  116790. * Load a scene
  116791. * @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)
  116792. * @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)
  116793. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116794. * @param onProgress a callback with a progress event for each file being loaded
  116795. * @param pluginExtension the extension used to determine the plugin
  116796. * @returns The loaded scene
  116797. */
  116798. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116799. /**
  116800. * Append a scene
  116801. * @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)
  116802. * @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)
  116803. * @param scene is the instance of BABYLON.Scene to append to
  116804. * @param onSuccess a callback with the scene when import succeeds
  116805. * @param onProgress a callback with a progress event for each file being loaded
  116806. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116807. * @param pluginExtension the extension used to determine the plugin
  116808. * @returns The loaded plugin
  116809. */
  116810. 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>;
  116811. /**
  116812. * Append a scene
  116813. * @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)
  116814. * @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)
  116815. * @param scene is the instance of BABYLON.Scene to append to
  116816. * @param onProgress a callback with a progress event for each file being loaded
  116817. * @param pluginExtension the extension used to determine the plugin
  116818. * @returns The given scene
  116819. */
  116820. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116821. /**
  116822. * Load a scene into an asset container
  116823. * @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)
  116824. * @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)
  116825. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116826. * @param onSuccess a callback with the scene when import succeeds
  116827. * @param onProgress a callback with a progress event for each file being loaded
  116828. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116829. * @param pluginExtension the extension used to determine the plugin
  116830. * @returns The loaded plugin
  116831. */
  116832. 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>;
  116833. /**
  116834. * Load a scene into an asset container
  116835. * @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)
  116836. * @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)
  116837. * @param scene is the instance of Scene to append to
  116838. * @param onProgress a callback with a progress event for each file being loaded
  116839. * @param pluginExtension the extension used to determine the plugin
  116840. * @returns The loaded asset container
  116841. */
  116842. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116843. /**
  116844. * Import animations from a file into a scene
  116845. * @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)
  116846. * @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)
  116847. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116848. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116849. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116850. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116851. * @param onSuccess a callback with the scene when import succeeds
  116852. * @param onProgress a callback with a progress event for each file being loaded
  116853. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116854. */
  116855. 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;
  116856. /**
  116857. * Import animations from a file into a scene
  116858. * @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)
  116859. * @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)
  116860. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116861. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116862. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116863. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116864. * @param onSuccess a callback with the scene when import succeeds
  116865. * @param onProgress a callback with a progress event for each file being loaded
  116866. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116867. * @returns the updated scene with imported animations
  116868. */
  116869. 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>;
  116870. }
  116871. }
  116872. declare module BABYLON {
  116873. /**
  116874. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116875. */
  116876. export type MotionControllerHandness = "none" | "left" | "right";
  116877. /**
  116878. * The type of components available in motion controllers.
  116879. * This is not the name of the component.
  116880. */
  116881. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116882. /**
  116883. * The state of a controller component
  116884. */
  116885. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116886. /**
  116887. * The schema of motion controller layout.
  116888. * No object will be initialized using this interface
  116889. * This is used just to define the profile.
  116890. */
  116891. export interface IMotionControllerLayout {
  116892. /**
  116893. * Path to load the assets. Usually relative to the base path
  116894. */
  116895. assetPath: string;
  116896. /**
  116897. * Available components (unsorted)
  116898. */
  116899. components: {
  116900. /**
  116901. * A map of component Ids
  116902. */
  116903. [componentId: string]: {
  116904. /**
  116905. * The type of input the component outputs
  116906. */
  116907. type: MotionControllerComponentType;
  116908. /**
  116909. * The indices of this component in the gamepad object
  116910. */
  116911. gamepadIndices: {
  116912. /**
  116913. * Index of button
  116914. */
  116915. button?: number;
  116916. /**
  116917. * If available, index of x-axis
  116918. */
  116919. xAxis?: number;
  116920. /**
  116921. * If available, index of y-axis
  116922. */
  116923. yAxis?: number;
  116924. };
  116925. /**
  116926. * The mesh's root node name
  116927. */
  116928. rootNodeName: string;
  116929. /**
  116930. * Animation definitions for this model
  116931. */
  116932. visualResponses: {
  116933. [stateKey: string]: {
  116934. /**
  116935. * What property will be animated
  116936. */
  116937. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116938. /**
  116939. * What states influence this visual response
  116940. */
  116941. states: MotionControllerComponentStateType[];
  116942. /**
  116943. * Type of animation - movement or visibility
  116944. */
  116945. valueNodeProperty: "transform" | "visibility";
  116946. /**
  116947. * Base node name to move. Its position will be calculated according to the min and max nodes
  116948. */
  116949. valueNodeName?: string;
  116950. /**
  116951. * Minimum movement node
  116952. */
  116953. minNodeName?: string;
  116954. /**
  116955. * Max movement node
  116956. */
  116957. maxNodeName?: string;
  116958. };
  116959. };
  116960. /**
  116961. * If touch enabled, what is the name of node to display user feedback
  116962. */
  116963. touchPointNodeName?: string;
  116964. };
  116965. };
  116966. /**
  116967. * Is it xr standard mapping or not
  116968. */
  116969. gamepadMapping: "" | "xr-standard";
  116970. /**
  116971. * Base root node of this entire model
  116972. */
  116973. rootNodeName: string;
  116974. /**
  116975. * Defines the main button component id
  116976. */
  116977. selectComponentId: string;
  116978. }
  116979. /**
  116980. * A definition for the layout map in the input profile
  116981. */
  116982. export interface IMotionControllerLayoutMap {
  116983. /**
  116984. * Layouts with handness type as a key
  116985. */
  116986. [handness: string]: IMotionControllerLayout;
  116987. }
  116988. /**
  116989. * The XR Input profile schema
  116990. * Profiles can be found here:
  116991. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116992. */
  116993. export interface IMotionControllerProfile {
  116994. /**
  116995. * fallback profiles for this profileId
  116996. */
  116997. fallbackProfileIds: string[];
  116998. /**
  116999. * The layout map, with handness as key
  117000. */
  117001. layouts: IMotionControllerLayoutMap;
  117002. /**
  117003. * The id of this profile
  117004. * correlates to the profile(s) in the xrInput.profiles array
  117005. */
  117006. profileId: string;
  117007. }
  117008. /**
  117009. * A helper-interface for the 3 meshes needed for controller button animation
  117010. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117011. */
  117012. export interface IMotionControllerButtonMeshMap {
  117013. /**
  117014. * the mesh that defines the pressed value mesh position.
  117015. * This is used to find the max-position of this button
  117016. */
  117017. pressedMesh: AbstractMesh;
  117018. /**
  117019. * the mesh that defines the unpressed value mesh position.
  117020. * This is used to find the min (or initial) position of this button
  117021. */
  117022. unpressedMesh: AbstractMesh;
  117023. /**
  117024. * The mesh that will be changed when value changes
  117025. */
  117026. valueMesh: AbstractMesh;
  117027. }
  117028. /**
  117029. * A helper-interface for the 3 meshes needed for controller axis animation.
  117030. * This will be expanded when touchpad animations are fully supported
  117031. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117032. */
  117033. export interface IMotionControllerMeshMap {
  117034. /**
  117035. * the mesh that defines the maximum value mesh position.
  117036. */
  117037. maxMesh?: AbstractMesh;
  117038. /**
  117039. * the mesh that defines the minimum value mesh position.
  117040. */
  117041. minMesh?: AbstractMesh;
  117042. /**
  117043. * The mesh that will be changed when axis value changes
  117044. */
  117045. valueMesh: AbstractMesh;
  117046. }
  117047. /**
  117048. * The elements needed for change-detection of the gamepad objects in motion controllers
  117049. */
  117050. export interface IMinimalMotionControllerObject {
  117051. /**
  117052. * Available axes of this controller
  117053. */
  117054. axes: number[];
  117055. /**
  117056. * An array of available buttons
  117057. */
  117058. buttons: Array<{
  117059. /**
  117060. * Value of the button/trigger
  117061. */
  117062. value: number;
  117063. /**
  117064. * If the button/trigger is currently touched
  117065. */
  117066. touched: boolean;
  117067. /**
  117068. * If the button/trigger is currently pressed
  117069. */
  117070. pressed: boolean;
  117071. }>;
  117072. }
  117073. /**
  117074. * An Abstract Motion controller
  117075. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117076. * Each component has an observable to check for changes in value and state
  117077. */
  117078. export abstract class WebXRAbstractMotionController implements IDisposable {
  117079. protected scene: Scene;
  117080. protected layout: IMotionControllerLayout;
  117081. /**
  117082. * The gamepad object correlating to this controller
  117083. */
  117084. gamepadObject: IMinimalMotionControllerObject;
  117085. /**
  117086. * handness (left/right/none) of this controller
  117087. */
  117088. handness: MotionControllerHandness;
  117089. private _initComponent;
  117090. private _modelReady;
  117091. /**
  117092. * A map of components (WebXRControllerComponent) in this motion controller
  117093. * Components have a ComponentType and can also have both button and axis definitions
  117094. */
  117095. readonly components: {
  117096. [id: string]: WebXRControllerComponent;
  117097. };
  117098. /**
  117099. * Disable the model's animation. Can be set at any time.
  117100. */
  117101. disableAnimation: boolean;
  117102. /**
  117103. * Observers registered here will be triggered when the model of this controller is done loading
  117104. */
  117105. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117106. /**
  117107. * The profile id of this motion controller
  117108. */
  117109. abstract profileId: string;
  117110. /**
  117111. * The root mesh of the model. It is null if the model was not yet initialized
  117112. */
  117113. rootMesh: Nullable<AbstractMesh>;
  117114. /**
  117115. * constructs a new abstract motion controller
  117116. * @param scene the scene to which the model of the controller will be added
  117117. * @param layout The profile layout to load
  117118. * @param gamepadObject The gamepad object correlating to this controller
  117119. * @param handness handness (left/right/none) of this controller
  117120. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117121. */
  117122. constructor(scene: Scene, layout: IMotionControllerLayout,
  117123. /**
  117124. * The gamepad object correlating to this controller
  117125. */
  117126. gamepadObject: IMinimalMotionControllerObject,
  117127. /**
  117128. * handness (left/right/none) of this controller
  117129. */
  117130. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117131. /**
  117132. * Dispose this controller, the model mesh and all its components
  117133. */
  117134. dispose(): void;
  117135. /**
  117136. * Returns all components of specific type
  117137. * @param type the type to search for
  117138. * @return an array of components with this type
  117139. */
  117140. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117141. /**
  117142. * get a component based an its component id as defined in layout.components
  117143. * @param id the id of the component
  117144. * @returns the component correlates to the id or undefined if not found
  117145. */
  117146. getComponent(id: string): WebXRControllerComponent;
  117147. /**
  117148. * Get the list of components available in this motion controller
  117149. * @returns an array of strings correlating to available components
  117150. */
  117151. getComponentIds(): string[];
  117152. /**
  117153. * Get the first component of specific type
  117154. * @param type type of component to find
  117155. * @return a controller component or null if not found
  117156. */
  117157. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117158. /**
  117159. * Get the main (Select) component of this controller as defined in the layout
  117160. * @returns the main component of this controller
  117161. */
  117162. getMainComponent(): WebXRControllerComponent;
  117163. /**
  117164. * Loads the model correlating to this controller
  117165. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117166. * @returns A promise fulfilled with the result of the model loading
  117167. */
  117168. loadModel(): Promise<boolean>;
  117169. /**
  117170. * Update this model using the current XRFrame
  117171. * @param xrFrame the current xr frame to use and update the model
  117172. */
  117173. updateFromXRFrame(xrFrame: XRFrame): void;
  117174. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117175. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117176. /**
  117177. * Moves the axis on the controller mesh based on its current state
  117178. * @param axis the index of the axis
  117179. * @param axisValue the value of the axis which determines the meshes new position
  117180. * @hidden
  117181. */
  117182. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117183. /**
  117184. * Update the model itself with the current frame data
  117185. * @param xrFrame the frame to use for updating the model mesh
  117186. */
  117187. protected updateModel(xrFrame: XRFrame): void;
  117188. /**
  117189. * Get the filename and path for this controller's model
  117190. * @returns a map of filename and path
  117191. */
  117192. protected abstract _getFilenameAndPath(): {
  117193. filename: string;
  117194. path: string;
  117195. };
  117196. /**
  117197. * This function is called before the mesh is loaded. It checks for loading constraints.
  117198. * For example, this function can check if the GLB loader is available
  117199. * If this function returns false, the generic controller will be loaded instead
  117200. * @returns Is the client ready to load the mesh
  117201. */
  117202. protected abstract _getModelLoadingConstraints(): boolean;
  117203. /**
  117204. * This function will be called after the model was successfully loaded and can be used
  117205. * for mesh transformations before it is available for the user
  117206. * @param meshes the loaded meshes
  117207. */
  117208. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117209. /**
  117210. * Set the root mesh for this controller. Important for the WebXR controller class
  117211. * @param meshes the loaded meshes
  117212. */
  117213. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117214. /**
  117215. * A function executed each frame that updates the mesh (if needed)
  117216. * @param xrFrame the current xrFrame
  117217. */
  117218. protected abstract _updateModel(xrFrame: XRFrame): void;
  117219. private _getGenericFilenameAndPath;
  117220. private _getGenericParentMesh;
  117221. }
  117222. }
  117223. declare module BABYLON {
  117224. /**
  117225. * A generic trigger-only motion controller for WebXR
  117226. */
  117227. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117228. /**
  117229. * Static version of the profile id of this controller
  117230. */
  117231. static ProfileId: string;
  117232. profileId: string;
  117233. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117234. protected _getFilenameAndPath(): {
  117235. filename: string;
  117236. path: string;
  117237. };
  117238. protected _getModelLoadingConstraints(): boolean;
  117239. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117240. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117241. protected _updateModel(): void;
  117242. }
  117243. }
  117244. declare module BABYLON {
  117245. /**
  117246. * Class containing static functions to help procedurally build meshes
  117247. */
  117248. export class SphereBuilder {
  117249. /**
  117250. * Creates a sphere mesh
  117251. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117252. * * 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`)
  117253. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117254. * * 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
  117255. * * 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)
  117256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117259. * @param name defines the name of the mesh
  117260. * @param options defines the options used to create the mesh
  117261. * @param scene defines the hosting scene
  117262. * @returns the sphere mesh
  117263. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117264. */
  117265. static CreateSphere(name: string, options: {
  117266. segments?: number;
  117267. diameter?: number;
  117268. diameterX?: number;
  117269. diameterY?: number;
  117270. diameterZ?: number;
  117271. arc?: number;
  117272. slice?: number;
  117273. sideOrientation?: number;
  117274. frontUVs?: Vector4;
  117275. backUVs?: Vector4;
  117276. updatable?: boolean;
  117277. }, scene?: Nullable<Scene>): Mesh;
  117278. }
  117279. }
  117280. declare module BABYLON {
  117281. /**
  117282. * A profiled motion controller has its profile loaded from an online repository.
  117283. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117284. */
  117285. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117286. private _repositoryUrl;
  117287. private _buttonMeshMapping;
  117288. private _touchDots;
  117289. /**
  117290. * The profile ID of this controller. Will be populated when the controller initializes.
  117291. */
  117292. profileId: string;
  117293. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117294. dispose(): void;
  117295. protected _getFilenameAndPath(): {
  117296. filename: string;
  117297. path: string;
  117298. };
  117299. protected _getModelLoadingConstraints(): boolean;
  117300. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117301. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117302. protected _updateModel(_xrFrame: XRFrame): void;
  117303. }
  117304. }
  117305. declare module BABYLON {
  117306. /**
  117307. * A construction function type to create a new controller based on an xrInput object
  117308. */
  117309. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117310. /**
  117311. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117312. *
  117313. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117314. * it should be replaced with auto-loaded controllers.
  117315. *
  117316. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117317. */
  117318. export class WebXRMotionControllerManager {
  117319. private static _AvailableControllers;
  117320. private static _Fallbacks;
  117321. private static _ProfileLoadingPromises;
  117322. private static _ProfilesList;
  117323. /**
  117324. * The base URL of the online controller repository. Can be changed at any time.
  117325. */
  117326. static BaseRepositoryUrl: string;
  117327. /**
  117328. * Which repository gets priority - local or online
  117329. */
  117330. static PrioritizeOnlineRepository: boolean;
  117331. /**
  117332. * Use the online repository, or use only locally-defined controllers
  117333. */
  117334. static UseOnlineRepository: boolean;
  117335. /**
  117336. * Clear the cache used for profile loading and reload when requested again
  117337. */
  117338. static ClearProfilesCache(): void;
  117339. /**
  117340. * Register the default fallbacks.
  117341. * This function is called automatically when this file is imported.
  117342. */
  117343. static DefaultFallbacks(): void;
  117344. /**
  117345. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117346. * @param profileId the profile to which a fallback needs to be found
  117347. * @return an array with corresponding fallback profiles
  117348. */
  117349. static FindFallbackWithProfileId(profileId: string): string[];
  117350. /**
  117351. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117352. * The order of search:
  117353. *
  117354. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117355. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117356. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117357. * 4) return the generic trigger controller if none were found
  117358. *
  117359. * @param xrInput the xrInput to which a new controller is initialized
  117360. * @param scene the scene to which the model will be added
  117361. * @param forceProfile force a certain profile for this controller
  117362. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117363. */
  117364. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117365. /**
  117366. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117367. *
  117368. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117369. *
  117370. * @param type the profile type to register
  117371. * @param constructFunction the function to be called when loading this profile
  117372. */
  117373. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117374. /**
  117375. * Register a fallback to a specific profile.
  117376. * @param profileId the profileId that will receive the fallbacks
  117377. * @param fallbacks A list of fallback profiles
  117378. */
  117379. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117380. /**
  117381. * Will update the list of profiles available in the repository
  117382. * @return a promise that resolves to a map of profiles available online
  117383. */
  117384. static UpdateProfilesList(): Promise<{
  117385. [profile: string]: string;
  117386. }>;
  117387. private static _LoadProfileFromRepository;
  117388. private static _LoadProfilesFromAvailableControllers;
  117389. }
  117390. }
  117391. declare module BABYLON {
  117392. /**
  117393. * Configuration options for the WebXR controller creation
  117394. */
  117395. export interface IWebXRControllerOptions {
  117396. /**
  117397. * Should the controller mesh be animated when a user interacts with it
  117398. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117399. */
  117400. disableMotionControllerAnimation?: boolean;
  117401. /**
  117402. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117403. */
  117404. doNotLoadControllerMesh?: boolean;
  117405. /**
  117406. * Force a specific controller type for this controller.
  117407. * This can be used when creating your own profile or when testing different controllers
  117408. */
  117409. forceControllerProfile?: string;
  117410. }
  117411. /**
  117412. * Represents an XR controller
  117413. */
  117414. export class WebXRInputSource {
  117415. private _scene;
  117416. /** The underlying input source for the controller */
  117417. inputSource: XRInputSource;
  117418. private _options;
  117419. private _tmpQuaternion;
  117420. private _tmpVector;
  117421. private _uniqueId;
  117422. /**
  117423. * 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
  117424. */
  117425. grip?: AbstractMesh;
  117426. /**
  117427. * If available, this is the gamepad object related to this controller.
  117428. * Using this object it is possible to get click events and trackpad changes of the
  117429. * webxr controller that is currently being used.
  117430. */
  117431. motionController?: WebXRAbstractMotionController;
  117432. /**
  117433. * Event that fires when the controller is removed/disposed.
  117434. * The object provided as event data is this controller, after associated assets were disposed.
  117435. * uniqueId is still available.
  117436. */
  117437. onDisposeObservable: Observable<WebXRInputSource>;
  117438. /**
  117439. * Will be triggered when the mesh associated with the motion controller is done loading.
  117440. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117441. * A shortened version of controller -> motion controller -> on mesh loaded.
  117442. */
  117443. onMeshLoadedObservable: Observable<AbstractMesh>;
  117444. /**
  117445. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117446. */
  117447. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117448. /**
  117449. * Pointer which can be used to select objects or attach a visible laser to
  117450. */
  117451. pointer: AbstractMesh;
  117452. /**
  117453. * Creates the controller
  117454. * @see https://doc.babylonjs.com/how_to/webxr
  117455. * @param _scene the scene which the controller should be associated to
  117456. * @param inputSource the underlying input source for the controller
  117457. * @param _options options for this controller creation
  117458. */
  117459. constructor(_scene: Scene,
  117460. /** The underlying input source for the controller */
  117461. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117462. /**
  117463. * Get this controllers unique id
  117464. */
  117465. get uniqueId(): string;
  117466. /**
  117467. * Disposes of the object
  117468. */
  117469. dispose(): void;
  117470. /**
  117471. * Gets a world space ray coming from the pointer or grip
  117472. * @param result the resulting ray
  117473. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117474. */
  117475. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117476. /**
  117477. * Updates the controller pose based on the given XRFrame
  117478. * @param xrFrame xr frame to update the pose with
  117479. * @param referenceSpace reference space to use
  117480. */
  117481. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117482. }
  117483. }
  117484. declare module BABYLON {
  117485. /**
  117486. * The schema for initialization options of the XR Input class
  117487. */
  117488. export interface IWebXRInputOptions {
  117489. /**
  117490. * If set to true no model will be automatically loaded
  117491. */
  117492. doNotLoadControllerMeshes?: boolean;
  117493. /**
  117494. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117495. * If not found, the xr input profile data will be used.
  117496. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117497. */
  117498. forceInputProfile?: string;
  117499. /**
  117500. * Do not send a request to the controller repository to load the profile.
  117501. *
  117502. * Instead, use the controllers available in babylon itself.
  117503. */
  117504. disableOnlineControllerRepository?: boolean;
  117505. /**
  117506. * A custom URL for the controllers repository
  117507. */
  117508. customControllersRepositoryURL?: string;
  117509. /**
  117510. * Should the controller model's components not move according to the user input
  117511. */
  117512. disableControllerAnimation?: boolean;
  117513. }
  117514. /**
  117515. * XR input used to track XR inputs such as controllers/rays
  117516. */
  117517. export class WebXRInput implements IDisposable {
  117518. /**
  117519. * the xr session manager for this session
  117520. */
  117521. xrSessionManager: WebXRSessionManager;
  117522. /**
  117523. * the WebXR camera for this session. Mainly used for teleportation
  117524. */
  117525. xrCamera: WebXRCamera;
  117526. private readonly options;
  117527. /**
  117528. * XR controllers being tracked
  117529. */
  117530. controllers: Array<WebXRInputSource>;
  117531. private _frameObserver;
  117532. private _sessionEndedObserver;
  117533. private _sessionInitObserver;
  117534. /**
  117535. * Event when a controller has been connected/added
  117536. */
  117537. onControllerAddedObservable: Observable<WebXRInputSource>;
  117538. /**
  117539. * Event when a controller has been removed/disconnected
  117540. */
  117541. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117542. /**
  117543. * Initializes the WebXRInput
  117544. * @param xrSessionManager the xr session manager for this session
  117545. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117546. * @param options = initialization options for this xr input
  117547. */
  117548. constructor(
  117549. /**
  117550. * the xr session manager for this session
  117551. */
  117552. xrSessionManager: WebXRSessionManager,
  117553. /**
  117554. * the WebXR camera for this session. Mainly used for teleportation
  117555. */
  117556. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117557. private _onInputSourcesChange;
  117558. private _addAndRemoveControllers;
  117559. /**
  117560. * Disposes of the object
  117561. */
  117562. dispose(): void;
  117563. }
  117564. }
  117565. declare module BABYLON {
  117566. /**
  117567. * This is the base class for all WebXR features.
  117568. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117569. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117570. */
  117571. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117572. protected _xrSessionManager: WebXRSessionManager;
  117573. private _attached;
  117574. private _removeOnDetach;
  117575. /**
  117576. * Should auto-attach be disabled?
  117577. */
  117578. disableAutoAttach: boolean;
  117579. /**
  117580. * Construct a new (abstract) WebXR feature
  117581. * @param _xrSessionManager the xr session manager for this feature
  117582. */
  117583. constructor(_xrSessionManager: WebXRSessionManager);
  117584. /**
  117585. * Is this feature attached
  117586. */
  117587. get attached(): boolean;
  117588. /**
  117589. * attach this feature
  117590. *
  117591. * @param force should attachment be forced (even when already attached)
  117592. * @returns true if successful, false is failed or already attached
  117593. */
  117594. attach(force?: boolean): boolean;
  117595. /**
  117596. * detach this feature.
  117597. *
  117598. * @returns true if successful, false if failed or already detached
  117599. */
  117600. detach(): boolean;
  117601. /**
  117602. * Dispose this feature and all of the resources attached
  117603. */
  117604. dispose(): void;
  117605. /**
  117606. * This is used to register callbacks that will automatically be removed when detach is called.
  117607. * @param observable the observable to which the observer will be attached
  117608. * @param callback the callback to register
  117609. */
  117610. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117611. /**
  117612. * Code in this function will be executed on each xrFrame received from the browser.
  117613. * This function will not execute after the feature is detached.
  117614. * @param _xrFrame the current frame
  117615. */
  117616. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117617. }
  117618. }
  117619. declare module BABYLON {
  117620. /**
  117621. * Renders a layer on top of an existing scene
  117622. */
  117623. export class UtilityLayerRenderer implements IDisposable {
  117624. /** the original scene that will be rendered on top of */
  117625. originalScene: Scene;
  117626. private _pointerCaptures;
  117627. private _lastPointerEvents;
  117628. private static _DefaultUtilityLayer;
  117629. private static _DefaultKeepDepthUtilityLayer;
  117630. private _sharedGizmoLight;
  117631. private _renderCamera;
  117632. /**
  117633. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117634. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  117635. * @returns the camera that is used when rendering the utility layer
  117636. */
  117637. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  117638. /**
  117639. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117640. * @param cam the camera that should be used when rendering the utility layer
  117641. */
  117642. setRenderCamera(cam: Nullable<Camera>): void;
  117643. /**
  117644. * @hidden
  117645. * Light which used by gizmos to get light shading
  117646. */
  117647. _getSharedGizmoLight(): HemisphericLight;
  117648. /**
  117649. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117650. */
  117651. pickUtilitySceneFirst: boolean;
  117652. /**
  117653. * 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)
  117654. */
  117655. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117656. /**
  117657. * 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)
  117658. */
  117659. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117660. /**
  117661. * The scene that is rendered on top of the original scene
  117662. */
  117663. utilityLayerScene: Scene;
  117664. /**
  117665. * If the utility layer should automatically be rendered on top of existing scene
  117666. */
  117667. shouldRender: boolean;
  117668. /**
  117669. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117670. */
  117671. onlyCheckPointerDownEvents: boolean;
  117672. /**
  117673. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117674. */
  117675. processAllEvents: boolean;
  117676. /**
  117677. * Observable raised when the pointer move from the utility layer scene to the main scene
  117678. */
  117679. onPointerOutObservable: Observable<number>;
  117680. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117681. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117682. private _afterRenderObserver;
  117683. private _sceneDisposeObserver;
  117684. private _originalPointerObserver;
  117685. /**
  117686. * Instantiates a UtilityLayerRenderer
  117687. * @param originalScene the original scene that will be rendered on top of
  117688. * @param handleEvents boolean indicating if the utility layer should handle events
  117689. */
  117690. constructor(
  117691. /** the original scene that will be rendered on top of */
  117692. originalScene: Scene, handleEvents?: boolean);
  117693. private _notifyObservers;
  117694. /**
  117695. * Renders the utility layers scene on top of the original scene
  117696. */
  117697. render(): void;
  117698. /**
  117699. * Disposes of the renderer
  117700. */
  117701. dispose(): void;
  117702. private _updateCamera;
  117703. }
  117704. }
  117705. declare module BABYLON {
  117706. /**
  117707. * Options interface for the pointer selection module
  117708. */
  117709. export interface IWebXRControllerPointerSelectionOptions {
  117710. /**
  117711. * if provided, this scene will be used to render meshes.
  117712. */
  117713. customUtilityLayerScene?: Scene;
  117714. /**
  117715. * 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)
  117716. * If not disabled, the last picked point will be used to execute a pointer up event
  117717. * If disabled, pointer up event will be triggered right after the pointer down event.
  117718. * Used in screen and gaze target ray mode only
  117719. */
  117720. disablePointerUpOnTouchOut: boolean;
  117721. /**
  117722. * For gaze mode (time to select instead of press)
  117723. */
  117724. forceGazeMode: boolean;
  117725. /**
  117726. * 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
  117727. * to start a new countdown to the pointer down event.
  117728. * Defaults to 1.
  117729. */
  117730. gazeModePointerMovedFactor?: number;
  117731. /**
  117732. * Different button type to use instead of the main component
  117733. */
  117734. overrideButtonId?: string;
  117735. /**
  117736. * use this rendering group id for the meshes (optional)
  117737. */
  117738. renderingGroupId?: number;
  117739. /**
  117740. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  117741. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117742. * 3000 means 3 seconds between pointing at something and selecting it
  117743. */
  117744. timeToSelect?: number;
  117745. /**
  117746. * Should meshes created here be added to a utility layer or the main scene
  117747. */
  117748. useUtilityLayer?: boolean;
  117749. /**
  117750. * the xr input to use with this pointer selection
  117751. */
  117752. xrInput: WebXRInput;
  117753. }
  117754. /**
  117755. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117756. */
  117757. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117758. private readonly _options;
  117759. private static _idCounter;
  117760. private _attachController;
  117761. private _controllers;
  117762. private _scene;
  117763. private _tmpVectorForPickCompare;
  117764. /**
  117765. * The module's name
  117766. */
  117767. static readonly Name: string;
  117768. /**
  117769. * The (Babylon) version of this module.
  117770. * This is an integer representing the implementation version.
  117771. * This number does not correspond to the WebXR specs version
  117772. */
  117773. static readonly Version: number;
  117774. /**
  117775. * Disable lighting on the laser pointer (so it will always be visible)
  117776. */
  117777. disablePointerLighting: boolean;
  117778. /**
  117779. * Disable lighting on the selection mesh (so it will always be visible)
  117780. */
  117781. disableSelectionMeshLighting: boolean;
  117782. /**
  117783. * Should the laser pointer be displayed
  117784. */
  117785. displayLaserPointer: boolean;
  117786. /**
  117787. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117788. */
  117789. displaySelectionMesh: boolean;
  117790. /**
  117791. * This color will be set to the laser pointer when selection is triggered
  117792. */
  117793. laserPointerPickedColor: Color3;
  117794. /**
  117795. * Default color of the laser pointer
  117796. */
  117797. lasterPointerDefaultColor: Color3;
  117798. /**
  117799. * default color of the selection ring
  117800. */
  117801. selectionMeshDefaultColor: Color3;
  117802. /**
  117803. * This color will be applied to the selection ring when selection is triggered
  117804. */
  117805. selectionMeshPickedColor: Color3;
  117806. /**
  117807. * constructs a new background remover module
  117808. * @param _xrSessionManager the session manager for this module
  117809. * @param _options read-only options to be used in this module
  117810. */
  117811. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117812. /**
  117813. * attach this feature
  117814. * Will usually be called by the features manager
  117815. *
  117816. * @returns true if successful.
  117817. */
  117818. attach(): boolean;
  117819. /**
  117820. * detach this feature.
  117821. * Will usually be called by the features manager
  117822. *
  117823. * @returns true if successful.
  117824. */
  117825. detach(): boolean;
  117826. /**
  117827. * Will get the mesh under a specific pointer.
  117828. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  117829. * @param controllerId the controllerId to check
  117830. * @returns The mesh under pointer or null if no mesh is under the pointer
  117831. */
  117832. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  117833. /**
  117834. * Get the xr controller that correlates to the pointer id in the pointer event
  117835. *
  117836. * @param id the pointer id to search for
  117837. * @returns the controller that correlates to this id or null if not found
  117838. */
  117839. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117840. protected _onXRFrame(_xrFrame: XRFrame): void;
  117841. private _attachGazeMode;
  117842. private _attachScreenRayMode;
  117843. private _attachTrackedPointerRayMode;
  117844. private _convertNormalToDirectionOfRay;
  117845. private _detachController;
  117846. private _generateNewMeshPair;
  117847. private _pickingMoved;
  117848. private _updatePointerDistance;
  117849. }
  117850. }
  117851. declare module BABYLON {
  117852. /**
  117853. * Button which can be used to enter a different mode of XR
  117854. */
  117855. export class WebXREnterExitUIButton {
  117856. /** button element */
  117857. element: HTMLElement;
  117858. /** XR initialization options for the button */
  117859. sessionMode: XRSessionMode;
  117860. /** Reference space type */
  117861. referenceSpaceType: XRReferenceSpaceType;
  117862. /**
  117863. * Creates a WebXREnterExitUIButton
  117864. * @param element button element
  117865. * @param sessionMode XR initialization session mode
  117866. * @param referenceSpaceType the type of reference space to be used
  117867. */
  117868. constructor(
  117869. /** button element */
  117870. element: HTMLElement,
  117871. /** XR initialization options for the button */
  117872. sessionMode: XRSessionMode,
  117873. /** Reference space type */
  117874. referenceSpaceType: XRReferenceSpaceType);
  117875. /**
  117876. * Extendable function which can be used to update the button's visuals when the state changes
  117877. * @param activeButton the current active button in the UI
  117878. */
  117879. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117880. }
  117881. /**
  117882. * Options to create the webXR UI
  117883. */
  117884. export class WebXREnterExitUIOptions {
  117885. /**
  117886. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117887. */
  117888. customButtons?: Array<WebXREnterExitUIButton>;
  117889. /**
  117890. * A reference space type to use when creating the default button.
  117891. * Default is local-floor
  117892. */
  117893. referenceSpaceType?: XRReferenceSpaceType;
  117894. /**
  117895. * Context to enter xr with
  117896. */
  117897. renderTarget?: Nullable<WebXRRenderTarget>;
  117898. /**
  117899. * A session mode to use when creating the default button.
  117900. * Default is immersive-vr
  117901. */
  117902. sessionMode?: XRSessionMode;
  117903. }
  117904. /**
  117905. * UI to allow the user to enter/exit XR mode
  117906. */
  117907. export class WebXREnterExitUI implements IDisposable {
  117908. private scene;
  117909. /** version of the options passed to this UI */
  117910. options: WebXREnterExitUIOptions;
  117911. private _activeButton;
  117912. private _buttons;
  117913. private _overlay;
  117914. /**
  117915. * Fired every time the active button is changed.
  117916. *
  117917. * When xr is entered via a button that launches xr that button will be the callback parameter
  117918. *
  117919. * When exiting xr the callback parameter will be null)
  117920. */
  117921. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117922. /**
  117923. *
  117924. * @param scene babylon scene object to use
  117925. * @param options (read-only) version of the options passed to this UI
  117926. */
  117927. private constructor();
  117928. /**
  117929. * Creates UI to allow the user to enter/exit XR mode
  117930. * @param scene the scene to add the ui to
  117931. * @param helper the xr experience helper to enter/exit xr with
  117932. * @param options options to configure the UI
  117933. * @returns the created ui
  117934. */
  117935. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117936. /**
  117937. * Disposes of the XR UI component
  117938. */
  117939. dispose(): void;
  117940. private _updateButtons;
  117941. }
  117942. }
  117943. declare module BABYLON {
  117944. /**
  117945. * Class containing static functions to help procedurally build meshes
  117946. */
  117947. export class LinesBuilder {
  117948. /**
  117949. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117950. * * 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
  117951. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117952. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117953. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117954. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117955. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117956. * * 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
  117957. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117960. * @param name defines the name of the new line system
  117961. * @param options defines the options used to create the line system
  117962. * @param scene defines the hosting scene
  117963. * @returns a new line system mesh
  117964. */
  117965. static CreateLineSystem(name: string, options: {
  117966. lines: Vector3[][];
  117967. updatable?: boolean;
  117968. instance?: Nullable<LinesMesh>;
  117969. colors?: Nullable<Color4[][]>;
  117970. useVertexAlpha?: boolean;
  117971. }, scene: Nullable<Scene>): LinesMesh;
  117972. /**
  117973. * Creates a line mesh
  117974. * 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
  117975. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117976. * * The parameter `points` is an array successive Vector3
  117977. * * 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
  117978. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117979. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117980. * * When updating an instance, remember that only point positions can change, not the number of points
  117981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117983. * @param name defines the name of the new line system
  117984. * @param options defines the options used to create the line system
  117985. * @param scene defines the hosting scene
  117986. * @returns a new line mesh
  117987. */
  117988. static CreateLines(name: string, options: {
  117989. points: Vector3[];
  117990. updatable?: boolean;
  117991. instance?: Nullable<LinesMesh>;
  117992. colors?: Color4[];
  117993. useVertexAlpha?: boolean;
  117994. }, scene?: Nullable<Scene>): LinesMesh;
  117995. /**
  117996. * Creates a dashed line mesh
  117997. * * 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
  117998. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117999. * * The parameter `points` is an array successive Vector3
  118000. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118001. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118002. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118003. * * 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
  118004. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118005. * * When updating an instance, remember that only point positions can change, not the number of points
  118006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118007. * @param name defines the name of the mesh
  118008. * @param options defines the options used to create the mesh
  118009. * @param scene defines the hosting scene
  118010. * @returns the dashed line mesh
  118011. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118012. */
  118013. static CreateDashedLines(name: string, options: {
  118014. points: Vector3[];
  118015. dashSize?: number;
  118016. gapSize?: number;
  118017. dashNb?: number;
  118018. updatable?: boolean;
  118019. instance?: LinesMesh;
  118020. useVertexAlpha?: boolean;
  118021. }, scene?: Nullable<Scene>): LinesMesh;
  118022. }
  118023. }
  118024. declare module BABYLON {
  118025. /**
  118026. * The options container for the teleportation module
  118027. */
  118028. export interface IWebXRTeleportationOptions {
  118029. /**
  118030. * if provided, this scene will be used to render meshes.
  118031. */
  118032. customUtilityLayerScene?: Scene;
  118033. /**
  118034. * Values to configure the default target mesh
  118035. */
  118036. defaultTargetMeshOptions?: {
  118037. /**
  118038. * Fill color of the teleportation area
  118039. */
  118040. teleportationFillColor?: string;
  118041. /**
  118042. * Border color for the teleportation area
  118043. */
  118044. teleportationBorderColor?: string;
  118045. /**
  118046. * Disable the mesh's animation sequence
  118047. */
  118048. disableAnimation?: boolean;
  118049. /**
  118050. * Disable lighting on the material or the ring and arrow
  118051. */
  118052. disableLighting?: boolean;
  118053. /**
  118054. * Override the default material of the torus and arrow
  118055. */
  118056. torusArrowMaterial?: Material;
  118057. };
  118058. /**
  118059. * A list of meshes to use as floor meshes.
  118060. * Meshes can be added and removed after initializing the feature using the
  118061. * addFloorMesh and removeFloorMesh functions
  118062. * If empty, rotation will still work
  118063. */
  118064. floorMeshes?: AbstractMesh[];
  118065. /**
  118066. * use this rendering group id for the meshes (optional)
  118067. */
  118068. renderingGroupId?: number;
  118069. /**
  118070. * Should teleportation move only to snap points
  118071. */
  118072. snapPointsOnly?: boolean;
  118073. /**
  118074. * An array of points to which the teleportation will snap to.
  118075. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118076. */
  118077. snapPositions?: Vector3[];
  118078. /**
  118079. * How close should the teleportation ray be in order to snap to position.
  118080. * Default to 0.8 units (meters)
  118081. */
  118082. snapToPositionRadius?: number;
  118083. /**
  118084. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118085. * If you want to support rotation, make sure your mesh has a direction indicator.
  118086. *
  118087. * When left untouched, the default mesh will be initialized.
  118088. */
  118089. teleportationTargetMesh?: AbstractMesh;
  118090. /**
  118091. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  118092. */
  118093. timeToTeleport?: number;
  118094. /**
  118095. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  118096. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  118097. */
  118098. useMainComponentOnly?: boolean;
  118099. /**
  118100. * Should meshes created here be added to a utility layer or the main scene
  118101. */
  118102. useUtilityLayer?: boolean;
  118103. /**
  118104. * Babylon XR Input class for controller
  118105. */
  118106. xrInput: WebXRInput;
  118107. }
  118108. /**
  118109. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118110. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118111. * the input of the attached controllers.
  118112. */
  118113. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118114. private _options;
  118115. private _controllers;
  118116. private _currentTeleportationControllerId;
  118117. private _floorMeshes;
  118118. private _quadraticBezierCurve;
  118119. private _selectionFeature;
  118120. private _snapToPositions;
  118121. private _snappedToPoint;
  118122. private _teleportationRingMaterial?;
  118123. private _tmpRay;
  118124. private _tmpVector;
  118125. /**
  118126. * The module's name
  118127. */
  118128. static readonly Name: string;
  118129. /**
  118130. * The (Babylon) version of this module.
  118131. * This is an integer representing the implementation version.
  118132. * This number does not correspond to the webxr specs version
  118133. */
  118134. static readonly Version: number;
  118135. /**
  118136. * Is movement backwards enabled
  118137. */
  118138. backwardsMovementEnabled: boolean;
  118139. /**
  118140. * Distance to travel when moving backwards
  118141. */
  118142. backwardsTeleportationDistance: number;
  118143. /**
  118144. * The distance from the user to the inspection point in the direction of the controller
  118145. * A higher number will allow the user to move further
  118146. * defaults to 5 (meters, in xr units)
  118147. */
  118148. parabolicCheckRadius: number;
  118149. /**
  118150. * Should the module support parabolic ray on top of direct ray
  118151. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118152. * Very helpful when moving between floors / different heights
  118153. */
  118154. parabolicRayEnabled: boolean;
  118155. /**
  118156. * How much rotation should be applied when rotating right and left
  118157. */
  118158. rotationAngle: number;
  118159. /**
  118160. * Is rotation enabled when moving forward?
  118161. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118162. */
  118163. rotationEnabled: boolean;
  118164. /**
  118165. * constructs a new anchor system
  118166. * @param _xrSessionManager an instance of WebXRSessionManager
  118167. * @param _options configuration object for this feature
  118168. */
  118169. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118170. /**
  118171. * Get the snapPointsOnly flag
  118172. */
  118173. get snapPointsOnly(): boolean;
  118174. /**
  118175. * Sets the snapPointsOnly flag
  118176. * @param snapToPoints should teleportation be exclusively to snap points
  118177. */
  118178. set snapPointsOnly(snapToPoints: boolean);
  118179. /**
  118180. * Add a new mesh to the floor meshes array
  118181. * @param mesh the mesh to use as floor mesh
  118182. */
  118183. addFloorMesh(mesh: AbstractMesh): void;
  118184. /**
  118185. * Add a new snap-to point to fix teleportation to this position
  118186. * @param newSnapPoint The new Snap-To point
  118187. */
  118188. addSnapPoint(newSnapPoint: Vector3): void;
  118189. attach(): boolean;
  118190. detach(): boolean;
  118191. dispose(): void;
  118192. /**
  118193. * Remove a mesh from the floor meshes array
  118194. * @param mesh the mesh to remove
  118195. */
  118196. removeFloorMesh(mesh: AbstractMesh): void;
  118197. /**
  118198. * Remove a mesh from the floor meshes array using its name
  118199. * @param name the mesh name to remove
  118200. */
  118201. removeFloorMeshByName(name: string): void;
  118202. /**
  118203. * 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
  118204. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118205. * @returns was the point found and removed or not
  118206. */
  118207. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118208. /**
  118209. * This function sets a selection feature that will be disabled when
  118210. * the forward ray is shown and will be reattached when hidden.
  118211. * This is used to remove the selection rays when moving.
  118212. * @param selectionFeature the feature to disable when forward movement is enabled
  118213. */
  118214. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118215. protected _onXRFrame(_xrFrame: XRFrame): void;
  118216. private _attachController;
  118217. private _createDefaultTargetMesh;
  118218. private _detachController;
  118219. private _findClosestSnapPointWithRadius;
  118220. private _setTargetMeshPosition;
  118221. private _setTargetMeshVisibility;
  118222. private _showParabolicPath;
  118223. private _teleportForward;
  118224. }
  118225. }
  118226. declare module BABYLON {
  118227. /**
  118228. * Options for the default xr helper
  118229. */
  118230. export class WebXRDefaultExperienceOptions {
  118231. /**
  118232. * Enable or disable default UI to enter XR
  118233. */
  118234. disableDefaultUI?: boolean;
  118235. /**
  118236. * Should teleportation not initialize. defaults to false.
  118237. */
  118238. disableTeleportation?: boolean;
  118239. /**
  118240. * Floor meshes that will be used for teleport
  118241. */
  118242. floorMeshes?: Array<AbstractMesh>;
  118243. /**
  118244. * If set to true, the first frame will not be used to reset position
  118245. * The first frame is mainly used when copying transformation from the old camera
  118246. * Mainly used in AR
  118247. */
  118248. ignoreNativeCameraTransformation?: boolean;
  118249. /**
  118250. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118251. */
  118252. inputOptions?: IWebXRInputOptions;
  118253. /**
  118254. * optional configuration for the output canvas
  118255. */
  118256. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118257. /**
  118258. * optional UI options. This can be used among other to change session mode and reference space type
  118259. */
  118260. uiOptions?: WebXREnterExitUIOptions;
  118261. /**
  118262. * When loading teleportation and pointer select, use stable versions instead of latest.
  118263. */
  118264. useStablePlugins?: boolean;
  118265. }
  118266. /**
  118267. * Default experience which provides a similar setup to the previous webVRExperience
  118268. */
  118269. export class WebXRDefaultExperience {
  118270. /**
  118271. * Base experience
  118272. */
  118273. baseExperience: WebXRExperienceHelper;
  118274. /**
  118275. * Enables ui for entering/exiting xr
  118276. */
  118277. enterExitUI: WebXREnterExitUI;
  118278. /**
  118279. * Input experience extension
  118280. */
  118281. input: WebXRInput;
  118282. /**
  118283. * Enables laser pointer and selection
  118284. */
  118285. pointerSelection: WebXRControllerPointerSelection;
  118286. /**
  118287. * Default target xr should render to
  118288. */
  118289. renderTarget: WebXRRenderTarget;
  118290. /**
  118291. * Enables teleportation
  118292. */
  118293. teleportation: WebXRMotionControllerTeleportation;
  118294. private constructor();
  118295. /**
  118296. * Creates the default xr experience
  118297. * @param scene scene
  118298. * @param options options for basic configuration
  118299. * @returns resulting WebXRDefaultExperience
  118300. */
  118301. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118302. /**
  118303. * DIsposes of the experience helper
  118304. */
  118305. dispose(): void;
  118306. }
  118307. }
  118308. declare module BABYLON {
  118309. /**
  118310. * Options to modify the vr teleportation behavior.
  118311. */
  118312. export interface VRTeleportationOptions {
  118313. /**
  118314. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118315. */
  118316. floorMeshName?: string;
  118317. /**
  118318. * A list of meshes to be used as the teleportation floor. (default: empty)
  118319. */
  118320. floorMeshes?: Mesh[];
  118321. /**
  118322. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118323. */
  118324. teleportationMode?: number;
  118325. /**
  118326. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118327. */
  118328. teleportationTime?: number;
  118329. /**
  118330. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118331. */
  118332. teleportationSpeed?: number;
  118333. /**
  118334. * The easing function used in the animation or null for Linear. (default CircleEase)
  118335. */
  118336. easingFunction?: EasingFunction;
  118337. }
  118338. /**
  118339. * Options to modify the vr experience helper's behavior.
  118340. */
  118341. export interface VRExperienceHelperOptions extends WebVROptions {
  118342. /**
  118343. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118344. */
  118345. createDeviceOrientationCamera?: boolean;
  118346. /**
  118347. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118348. */
  118349. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118350. /**
  118351. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118352. */
  118353. laserToggle?: boolean;
  118354. /**
  118355. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118356. */
  118357. floorMeshes?: Mesh[];
  118358. /**
  118359. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118360. */
  118361. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118362. /**
  118363. * Defines if WebXR should be used instead of WebVR (if available)
  118364. */
  118365. useXR?: boolean;
  118366. }
  118367. /**
  118368. * Event containing information after VR has been entered
  118369. */
  118370. export class OnAfterEnteringVRObservableEvent {
  118371. /**
  118372. * If entering vr was successful
  118373. */
  118374. success: boolean;
  118375. }
  118376. /**
  118377. * Helps to quickly add VR support to an existing scene.
  118378. * See http://doc.babylonjs.com/how_to/webvr_helper
  118379. */
  118380. export class VRExperienceHelper {
  118381. /** Options to modify the vr experience helper's behavior. */
  118382. webVROptions: VRExperienceHelperOptions;
  118383. private _scene;
  118384. private _position;
  118385. private _btnVR;
  118386. private _btnVRDisplayed;
  118387. private _webVRsupported;
  118388. private _webVRready;
  118389. private _webVRrequesting;
  118390. private _webVRpresenting;
  118391. private _hasEnteredVR;
  118392. private _fullscreenVRpresenting;
  118393. private _inputElement;
  118394. private _webVRCamera;
  118395. private _vrDeviceOrientationCamera;
  118396. private _deviceOrientationCamera;
  118397. private _existingCamera;
  118398. private _onKeyDown;
  118399. private _onVrDisplayPresentChange;
  118400. private _onVRDisplayChanged;
  118401. private _onVRRequestPresentStart;
  118402. private _onVRRequestPresentComplete;
  118403. /**
  118404. * 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)
  118405. */
  118406. enableGazeEvenWhenNoPointerLock: boolean;
  118407. /**
  118408. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118409. */
  118410. exitVROnDoubleTap: boolean;
  118411. /**
  118412. * Observable raised right before entering VR.
  118413. */
  118414. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118415. /**
  118416. * Observable raised when entering VR has completed.
  118417. */
  118418. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118419. /**
  118420. * Observable raised when exiting VR.
  118421. */
  118422. onExitingVRObservable: Observable<VRExperienceHelper>;
  118423. /**
  118424. * Observable raised when controller mesh is loaded.
  118425. */
  118426. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118427. /** Return this.onEnteringVRObservable
  118428. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118429. */
  118430. get onEnteringVR(): Observable<VRExperienceHelper>;
  118431. /** Return this.onExitingVRObservable
  118432. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118433. */
  118434. get onExitingVR(): Observable<VRExperienceHelper>;
  118435. /** Return this.onControllerMeshLoadedObservable
  118436. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118437. */
  118438. get onControllerMeshLoaded(): Observable<WebVRController>;
  118439. private _rayLength;
  118440. private _useCustomVRButton;
  118441. private _teleportationRequested;
  118442. private _teleportActive;
  118443. private _floorMeshName;
  118444. private _floorMeshesCollection;
  118445. private _teleportationMode;
  118446. private _teleportationTime;
  118447. private _teleportationSpeed;
  118448. private _teleportationEasing;
  118449. private _rotationAllowed;
  118450. private _teleportBackwardsVector;
  118451. private _teleportationTarget;
  118452. private _isDefaultTeleportationTarget;
  118453. private _postProcessMove;
  118454. private _teleportationFillColor;
  118455. private _teleportationBorderColor;
  118456. private _rotationAngle;
  118457. private _haloCenter;
  118458. private _cameraGazer;
  118459. private _padSensibilityUp;
  118460. private _padSensibilityDown;
  118461. private _leftController;
  118462. private _rightController;
  118463. private _gazeColor;
  118464. private _laserColor;
  118465. private _pickedLaserColor;
  118466. private _pickedGazeColor;
  118467. /**
  118468. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118469. */
  118470. onNewMeshSelected: Observable<AbstractMesh>;
  118471. /**
  118472. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118473. * This observable will provide the mesh and the controller used to select the mesh
  118474. */
  118475. onMeshSelectedWithController: Observable<{
  118476. mesh: AbstractMesh;
  118477. controller: WebVRController;
  118478. }>;
  118479. /**
  118480. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118481. */
  118482. onNewMeshPicked: Observable<PickingInfo>;
  118483. private _circleEase;
  118484. /**
  118485. * Observable raised before camera teleportation
  118486. */
  118487. onBeforeCameraTeleport: Observable<Vector3>;
  118488. /**
  118489. * Observable raised after camera teleportation
  118490. */
  118491. onAfterCameraTeleport: Observable<Vector3>;
  118492. /**
  118493. * Observable raised when current selected mesh gets unselected
  118494. */
  118495. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118496. private _raySelectionPredicate;
  118497. /**
  118498. * To be optionaly changed by user to define custom ray selection
  118499. */
  118500. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118501. /**
  118502. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118503. */
  118504. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118505. /**
  118506. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118507. */
  118508. teleportationEnabled: boolean;
  118509. private _defaultHeight;
  118510. private _teleportationInitialized;
  118511. private _interactionsEnabled;
  118512. private _interactionsRequested;
  118513. private _displayGaze;
  118514. private _displayLaserPointer;
  118515. /**
  118516. * The mesh used to display where the user is going to teleport.
  118517. */
  118518. get teleportationTarget(): Mesh;
  118519. /**
  118520. * Sets the mesh to be used to display where the user is going to teleport.
  118521. */
  118522. set teleportationTarget(value: Mesh);
  118523. /**
  118524. * 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
  118525. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118526. * See http://doc.babylonjs.com/resources/baking_transformations
  118527. */
  118528. get gazeTrackerMesh(): Mesh;
  118529. set gazeTrackerMesh(value: Mesh);
  118530. /**
  118531. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118532. */
  118533. updateGazeTrackerScale: boolean;
  118534. /**
  118535. * If the gaze trackers color should be updated when selecting meshes
  118536. */
  118537. updateGazeTrackerColor: boolean;
  118538. /**
  118539. * If the controller laser color should be updated when selecting meshes
  118540. */
  118541. updateControllerLaserColor: boolean;
  118542. /**
  118543. * The gaze tracking mesh corresponding to the left controller
  118544. */
  118545. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118546. /**
  118547. * The gaze tracking mesh corresponding to the right controller
  118548. */
  118549. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118550. /**
  118551. * If the ray of the gaze should be displayed.
  118552. */
  118553. get displayGaze(): boolean;
  118554. /**
  118555. * Sets if the ray of the gaze should be displayed.
  118556. */
  118557. set displayGaze(value: boolean);
  118558. /**
  118559. * If the ray of the LaserPointer should be displayed.
  118560. */
  118561. get displayLaserPointer(): boolean;
  118562. /**
  118563. * Sets if the ray of the LaserPointer should be displayed.
  118564. */
  118565. set displayLaserPointer(value: boolean);
  118566. /**
  118567. * The deviceOrientationCamera used as the camera when not in VR.
  118568. */
  118569. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118570. /**
  118571. * Based on the current WebVR support, returns the current VR camera used.
  118572. */
  118573. get currentVRCamera(): Nullable<Camera>;
  118574. /**
  118575. * The webVRCamera which is used when in VR.
  118576. */
  118577. get webVRCamera(): WebVRFreeCamera;
  118578. /**
  118579. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118580. */
  118581. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118582. /**
  118583. * The html button that is used to trigger entering into VR.
  118584. */
  118585. get vrButton(): Nullable<HTMLButtonElement>;
  118586. private get _teleportationRequestInitiated();
  118587. /**
  118588. * Defines whether or not Pointer lock should be requested when switching to
  118589. * full screen.
  118590. */
  118591. requestPointerLockOnFullScreen: boolean;
  118592. /**
  118593. * If asking to force XR, this will be populated with the default xr experience
  118594. */
  118595. xr: WebXRDefaultExperience;
  118596. /**
  118597. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118598. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118599. */
  118600. xrTestDone: boolean;
  118601. /**
  118602. * Instantiates a VRExperienceHelper.
  118603. * Helps to quickly add VR support to an existing scene.
  118604. * @param scene The scene the VRExperienceHelper belongs to.
  118605. * @param webVROptions Options to modify the vr experience helper's behavior.
  118606. */
  118607. constructor(scene: Scene,
  118608. /** Options to modify the vr experience helper's behavior. */
  118609. webVROptions?: VRExperienceHelperOptions);
  118610. private completeVRInit;
  118611. private _onDefaultMeshLoaded;
  118612. private _onResize;
  118613. private _onFullscreenChange;
  118614. /**
  118615. * Gets a value indicating if we are currently in VR mode.
  118616. */
  118617. get isInVRMode(): boolean;
  118618. private onVrDisplayPresentChange;
  118619. private onVRDisplayChanged;
  118620. private moveButtonToBottomRight;
  118621. private displayVRButton;
  118622. private updateButtonVisibility;
  118623. private _cachedAngularSensibility;
  118624. /**
  118625. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118626. * Otherwise, will use the fullscreen API.
  118627. */
  118628. enterVR(): void;
  118629. /**
  118630. * Attempt to exit VR, or fullscreen.
  118631. */
  118632. exitVR(): void;
  118633. /**
  118634. * The position of the vr experience helper.
  118635. */
  118636. get position(): Vector3;
  118637. /**
  118638. * Sets the position of the vr experience helper.
  118639. */
  118640. set position(value: Vector3);
  118641. /**
  118642. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118643. */
  118644. enableInteractions(): void;
  118645. private get _noControllerIsActive();
  118646. private beforeRender;
  118647. private _isTeleportationFloor;
  118648. /**
  118649. * Adds a floor mesh to be used for teleportation.
  118650. * @param floorMesh the mesh to be used for teleportation.
  118651. */
  118652. addFloorMesh(floorMesh: Mesh): void;
  118653. /**
  118654. * Removes a floor mesh from being used for teleportation.
  118655. * @param floorMesh the mesh to be removed.
  118656. */
  118657. removeFloorMesh(floorMesh: Mesh): void;
  118658. /**
  118659. * Enables interactions and teleportation using the VR controllers and gaze.
  118660. * @param vrTeleportationOptions options to modify teleportation behavior.
  118661. */
  118662. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118663. private _onNewGamepadConnected;
  118664. private _tryEnableInteractionOnController;
  118665. private _onNewGamepadDisconnected;
  118666. private _enableInteractionOnController;
  118667. private _checkTeleportWithRay;
  118668. private _checkRotate;
  118669. private _checkTeleportBackwards;
  118670. private _enableTeleportationOnController;
  118671. private _createTeleportationCircles;
  118672. private _displayTeleportationTarget;
  118673. private _hideTeleportationTarget;
  118674. private _rotateCamera;
  118675. private _moveTeleportationSelectorTo;
  118676. private _workingVector;
  118677. private _workingQuaternion;
  118678. private _workingMatrix;
  118679. /**
  118680. * Time Constant Teleportation Mode
  118681. */
  118682. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118683. /**
  118684. * Speed Constant Teleportation Mode
  118685. */
  118686. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118687. /**
  118688. * Teleports the users feet to the desired location
  118689. * @param location The location where the user's feet should be placed
  118690. */
  118691. teleportCamera(location: Vector3): void;
  118692. private _convertNormalToDirectionOfRay;
  118693. private _castRayAndSelectObject;
  118694. private _notifySelectedMeshUnselected;
  118695. /**
  118696. * Permanently set new colors for the laser pointer
  118697. * @param color the new laser color
  118698. * @param pickedColor the new laser color when picked mesh detected
  118699. */
  118700. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118701. /**
  118702. * Set lighting enabled / disabled on the laser pointer of both controllers
  118703. * @param enabled should the lighting be enabled on the laser pointer
  118704. */
  118705. setLaserLightingState(enabled?: boolean): void;
  118706. /**
  118707. * Permanently set new colors for the gaze pointer
  118708. * @param color the new gaze color
  118709. * @param pickedColor the new gaze color when picked mesh detected
  118710. */
  118711. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118712. /**
  118713. * Sets the color of the laser ray from the vr controllers.
  118714. * @param color new color for the ray.
  118715. */
  118716. changeLaserColor(color: Color3): void;
  118717. /**
  118718. * Sets the color of the ray from the vr headsets gaze.
  118719. * @param color new color for the ray.
  118720. */
  118721. changeGazeColor(color: Color3): void;
  118722. /**
  118723. * Exits VR and disposes of the vr experience helper
  118724. */
  118725. dispose(): void;
  118726. /**
  118727. * Gets the name of the VRExperienceHelper class
  118728. * @returns "VRExperienceHelper"
  118729. */
  118730. getClassName(): string;
  118731. }
  118732. }
  118733. declare module BABYLON {
  118734. /**
  118735. * Contains an array of blocks representing the octree
  118736. */
  118737. export interface IOctreeContainer<T> {
  118738. /**
  118739. * Blocks within the octree
  118740. */
  118741. blocks: Array<OctreeBlock<T>>;
  118742. }
  118743. /**
  118744. * Class used to store a cell in an octree
  118745. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118746. */
  118747. export class OctreeBlock<T> {
  118748. /**
  118749. * Gets the content of the current block
  118750. */
  118751. entries: T[];
  118752. /**
  118753. * Gets the list of block children
  118754. */
  118755. blocks: Array<OctreeBlock<T>>;
  118756. private _depth;
  118757. private _maxDepth;
  118758. private _capacity;
  118759. private _minPoint;
  118760. private _maxPoint;
  118761. private _boundingVectors;
  118762. private _creationFunc;
  118763. /**
  118764. * Creates a new block
  118765. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118766. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118767. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118768. * @param depth defines the current depth of this block in the octree
  118769. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118770. * @param creationFunc defines a callback to call when an element is added to the block
  118771. */
  118772. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118773. /**
  118774. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118775. */
  118776. get capacity(): number;
  118777. /**
  118778. * Gets the minimum vector (in world space) of the block's bounding box
  118779. */
  118780. get minPoint(): Vector3;
  118781. /**
  118782. * Gets the maximum vector (in world space) of the block's bounding box
  118783. */
  118784. get maxPoint(): Vector3;
  118785. /**
  118786. * Add a new element to this block
  118787. * @param entry defines the element to add
  118788. */
  118789. addEntry(entry: T): void;
  118790. /**
  118791. * Remove an element from this block
  118792. * @param entry defines the element to remove
  118793. */
  118794. removeEntry(entry: T): void;
  118795. /**
  118796. * Add an array of elements to this block
  118797. * @param entries defines the array of elements to add
  118798. */
  118799. addEntries(entries: T[]): void;
  118800. /**
  118801. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118802. * @param frustumPlanes defines the frustum planes to test
  118803. * @param selection defines the array to store current content if selection is positive
  118804. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118805. */
  118806. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118807. /**
  118808. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118809. * @param sphereCenter defines the bounding sphere center
  118810. * @param sphereRadius defines the bounding sphere radius
  118811. * @param selection defines the array to store current content if selection is positive
  118812. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118813. */
  118814. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118815. /**
  118816. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118817. * @param ray defines the ray to test with
  118818. * @param selection defines the array to store current content if selection is positive
  118819. */
  118820. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118821. /**
  118822. * Subdivide the content into child blocks (this block will then be empty)
  118823. */
  118824. createInnerBlocks(): void;
  118825. /**
  118826. * @hidden
  118827. */
  118828. 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;
  118829. }
  118830. }
  118831. declare module BABYLON {
  118832. /**
  118833. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118834. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118835. */
  118836. export class Octree<T> {
  118837. /** 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.) */
  118838. maxDepth: number;
  118839. /**
  118840. * Blocks within the octree containing objects
  118841. */
  118842. blocks: Array<OctreeBlock<T>>;
  118843. /**
  118844. * Content stored in the octree
  118845. */
  118846. dynamicContent: T[];
  118847. private _maxBlockCapacity;
  118848. private _selectionContent;
  118849. private _creationFunc;
  118850. /**
  118851. * Creates a octree
  118852. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118853. * @param creationFunc function to be used to instatiate the octree
  118854. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118855. * @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.)
  118856. */
  118857. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118858. /** 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.) */
  118859. maxDepth?: number);
  118860. /**
  118861. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118862. * @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);
  118863. * @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);
  118864. * @param entries meshes to be added to the octree blocks
  118865. */
  118866. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118867. /**
  118868. * Adds a mesh to the octree
  118869. * @param entry Mesh to add to the octree
  118870. */
  118871. addMesh(entry: T): void;
  118872. /**
  118873. * Remove an element from the octree
  118874. * @param entry defines the element to remove
  118875. */
  118876. removeMesh(entry: T): void;
  118877. /**
  118878. * Selects an array of meshes within the frustum
  118879. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118880. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118881. * @returns array of meshes within the frustum
  118882. */
  118883. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118884. /**
  118885. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118886. * @param sphereCenter defines the bounding sphere center
  118887. * @param sphereRadius defines the bounding sphere radius
  118888. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118889. * @returns an array of objects that intersect the sphere
  118890. */
  118891. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118892. /**
  118893. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118894. * @param ray defines the ray to test with
  118895. * @returns array of intersected objects
  118896. */
  118897. intersectsRay(ray: Ray): SmartArray<T>;
  118898. /**
  118899. * Adds a mesh into the octree block if it intersects the block
  118900. */
  118901. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118902. /**
  118903. * Adds a submesh into the octree block if it intersects the block
  118904. */
  118905. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118906. }
  118907. }
  118908. declare module BABYLON {
  118909. interface Scene {
  118910. /**
  118911. * @hidden
  118912. * Backing Filed
  118913. */
  118914. _selectionOctree: Octree<AbstractMesh>;
  118915. /**
  118916. * Gets the octree used to boost mesh selection (picking)
  118917. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118918. */
  118919. selectionOctree: Octree<AbstractMesh>;
  118920. /**
  118921. * Creates or updates the octree used to boost selection (picking)
  118922. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118923. * @param maxCapacity defines the maximum capacity per leaf
  118924. * @param maxDepth defines the maximum depth of the octree
  118925. * @returns an octree of AbstractMesh
  118926. */
  118927. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118928. }
  118929. interface AbstractMesh {
  118930. /**
  118931. * @hidden
  118932. * Backing Field
  118933. */
  118934. _submeshesOctree: Octree<SubMesh>;
  118935. /**
  118936. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118937. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118938. * @param maxCapacity defines the maximum size of each block (64 by default)
  118939. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118940. * @returns the new octree
  118941. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118943. */
  118944. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118945. }
  118946. /**
  118947. * Defines the octree scene component responsible to manage any octrees
  118948. * in a given scene.
  118949. */
  118950. export class OctreeSceneComponent {
  118951. /**
  118952. * The component name help to identify the component in the list of scene components.
  118953. */
  118954. readonly name: string;
  118955. /**
  118956. * The scene the component belongs to.
  118957. */
  118958. scene: Scene;
  118959. /**
  118960. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118961. */
  118962. readonly checksIsEnabled: boolean;
  118963. /**
  118964. * Creates a new instance of the component for the given scene
  118965. * @param scene Defines the scene to register the component in
  118966. */
  118967. constructor(scene: Scene);
  118968. /**
  118969. * Registers the component in a given scene
  118970. */
  118971. register(): void;
  118972. /**
  118973. * Return the list of active meshes
  118974. * @returns the list of active meshes
  118975. */
  118976. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118977. /**
  118978. * Return the list of active sub meshes
  118979. * @param mesh The mesh to get the candidates sub meshes from
  118980. * @returns the list of active sub meshes
  118981. */
  118982. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118983. private _tempRay;
  118984. /**
  118985. * Return the list of sub meshes intersecting with a given local ray
  118986. * @param mesh defines the mesh to find the submesh for
  118987. * @param localRay defines the ray in local space
  118988. * @returns the list of intersecting sub meshes
  118989. */
  118990. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118991. /**
  118992. * Return the list of sub meshes colliding with a collider
  118993. * @param mesh defines the mesh to find the submesh for
  118994. * @param collider defines the collider to evaluate the collision against
  118995. * @returns the list of colliding sub meshes
  118996. */
  118997. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118998. /**
  118999. * Rebuilds the elements related to this component in case of
  119000. * context lost for instance.
  119001. */
  119002. rebuild(): void;
  119003. /**
  119004. * Disposes the component and the associated ressources.
  119005. */
  119006. dispose(): void;
  119007. }
  119008. }
  119009. declare module BABYLON {
  119010. /**
  119011. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  119012. */
  119013. export class Gizmo implements IDisposable {
  119014. /** The utility layer the gizmo will be added to */
  119015. gizmoLayer: UtilityLayerRenderer;
  119016. /**
  119017. * The root mesh of the gizmo
  119018. */
  119019. _rootMesh: Mesh;
  119020. private _attachedMesh;
  119021. /**
  119022. * Ratio for the scale of the gizmo (Default: 1)
  119023. */
  119024. scaleRatio: number;
  119025. /**
  119026. * If a custom mesh has been set (Default: false)
  119027. */
  119028. protected _customMeshSet: boolean;
  119029. /**
  119030. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119031. * * When set, interactions will be enabled
  119032. */
  119033. get attachedMesh(): Nullable<AbstractMesh>;
  119034. set attachedMesh(value: Nullable<AbstractMesh>);
  119035. /**
  119036. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119037. * @param mesh The mesh to replace the default mesh of the gizmo
  119038. */
  119039. setCustomMesh(mesh: Mesh): void;
  119040. /**
  119041. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119042. */
  119043. updateGizmoRotationToMatchAttachedMesh: boolean;
  119044. /**
  119045. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119046. */
  119047. updateGizmoPositionToMatchAttachedMesh: boolean;
  119048. /**
  119049. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119050. */
  119051. updateScale: boolean;
  119052. protected _interactionsEnabled: boolean;
  119053. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119054. private _beforeRenderObserver;
  119055. private _tempVector;
  119056. /**
  119057. * Creates a gizmo
  119058. * @param gizmoLayer The utility layer the gizmo will be added to
  119059. */
  119060. constructor(
  119061. /** The utility layer the gizmo will be added to */
  119062. gizmoLayer?: UtilityLayerRenderer);
  119063. /**
  119064. * Updates the gizmo to match the attached mesh's position/rotation
  119065. */
  119066. protected _update(): void;
  119067. /**
  119068. * Disposes of the gizmo
  119069. */
  119070. dispose(): void;
  119071. }
  119072. }
  119073. declare module BABYLON {
  119074. /**
  119075. * Single plane drag gizmo
  119076. */
  119077. export class PlaneDragGizmo extends Gizmo {
  119078. /**
  119079. * Drag behavior responsible for the gizmos dragging interactions
  119080. */
  119081. dragBehavior: PointerDragBehavior;
  119082. private _pointerObserver;
  119083. /**
  119084. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119085. */
  119086. snapDistance: number;
  119087. /**
  119088. * Event that fires each time the gizmo snaps to a new location.
  119089. * * snapDistance is the the change in distance
  119090. */
  119091. onSnapObservable: Observable<{
  119092. snapDistance: number;
  119093. }>;
  119094. private _plane;
  119095. private _coloredMaterial;
  119096. private _hoverMaterial;
  119097. private _isEnabled;
  119098. private _parent;
  119099. /** @hidden */
  119100. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119101. /** @hidden */
  119102. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119103. /**
  119104. * Creates a PlaneDragGizmo
  119105. * @param gizmoLayer The utility layer the gizmo will be added to
  119106. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119107. * @param color The color of the gizmo
  119108. */
  119109. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119110. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119111. /**
  119112. * If the gizmo is enabled
  119113. */
  119114. set isEnabled(value: boolean);
  119115. get isEnabled(): boolean;
  119116. /**
  119117. * Disposes of the gizmo
  119118. */
  119119. dispose(): void;
  119120. }
  119121. }
  119122. declare module BABYLON {
  119123. /**
  119124. * Gizmo that enables dragging a mesh along 3 axis
  119125. */
  119126. export class PositionGizmo extends Gizmo {
  119127. /**
  119128. * Internal gizmo used for interactions on the x axis
  119129. */
  119130. xGizmo: AxisDragGizmo;
  119131. /**
  119132. * Internal gizmo used for interactions on the y axis
  119133. */
  119134. yGizmo: AxisDragGizmo;
  119135. /**
  119136. * Internal gizmo used for interactions on the z axis
  119137. */
  119138. zGizmo: AxisDragGizmo;
  119139. /**
  119140. * Internal gizmo used for interactions on the yz plane
  119141. */
  119142. xPlaneGizmo: PlaneDragGizmo;
  119143. /**
  119144. * Internal gizmo used for interactions on the xz plane
  119145. */
  119146. yPlaneGizmo: PlaneDragGizmo;
  119147. /**
  119148. * Internal gizmo used for interactions on the xy plane
  119149. */
  119150. zPlaneGizmo: PlaneDragGizmo;
  119151. /**
  119152. * private variables
  119153. */
  119154. private _meshAttached;
  119155. private _updateGizmoRotationToMatchAttachedMesh;
  119156. private _snapDistance;
  119157. private _scaleRatio;
  119158. /** Fires an event when any of it's sub gizmos are dragged */
  119159. onDragStartObservable: Observable<unknown>;
  119160. /** Fires an event when any of it's sub gizmos are released from dragging */
  119161. onDragEndObservable: Observable<unknown>;
  119162. /**
  119163. * If set to true, planar drag is enabled
  119164. */
  119165. private _planarGizmoEnabled;
  119166. get attachedMesh(): Nullable<AbstractMesh>;
  119167. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119168. /**
  119169. * Creates a PositionGizmo
  119170. * @param gizmoLayer The utility layer the gizmo will be added to
  119171. */
  119172. constructor(gizmoLayer?: UtilityLayerRenderer);
  119173. /**
  119174. * If the planar drag gizmo is enabled
  119175. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119176. */
  119177. set planarGizmoEnabled(value: boolean);
  119178. get planarGizmoEnabled(): boolean;
  119179. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119180. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119181. /**
  119182. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119183. */
  119184. set snapDistance(value: number);
  119185. get snapDistance(): number;
  119186. /**
  119187. * Ratio for the scale of the gizmo (Default: 1)
  119188. */
  119189. set scaleRatio(value: number);
  119190. get scaleRatio(): number;
  119191. /**
  119192. * Disposes of the gizmo
  119193. */
  119194. dispose(): void;
  119195. /**
  119196. * CustomMeshes are not supported by this gizmo
  119197. * @param mesh The mesh to replace the default mesh of the gizmo
  119198. */
  119199. setCustomMesh(mesh: Mesh): void;
  119200. }
  119201. }
  119202. declare module BABYLON {
  119203. /**
  119204. * Single axis drag gizmo
  119205. */
  119206. export class AxisDragGizmo extends Gizmo {
  119207. /**
  119208. * Drag behavior responsible for the gizmos dragging interactions
  119209. */
  119210. dragBehavior: PointerDragBehavior;
  119211. private _pointerObserver;
  119212. /**
  119213. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119214. */
  119215. snapDistance: number;
  119216. /**
  119217. * Event that fires each time the gizmo snaps to a new location.
  119218. * * snapDistance is the the change in distance
  119219. */
  119220. onSnapObservable: Observable<{
  119221. snapDistance: number;
  119222. }>;
  119223. private _isEnabled;
  119224. private _parent;
  119225. private _arrow;
  119226. private _coloredMaterial;
  119227. private _hoverMaterial;
  119228. /** @hidden */
  119229. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119230. /** @hidden */
  119231. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119232. /**
  119233. * Creates an AxisDragGizmo
  119234. * @param gizmoLayer The utility layer the gizmo will be added to
  119235. * @param dragAxis The axis which the gizmo will be able to drag on
  119236. * @param color The color of the gizmo
  119237. */
  119238. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119239. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119240. /**
  119241. * If the gizmo is enabled
  119242. */
  119243. set isEnabled(value: boolean);
  119244. get isEnabled(): boolean;
  119245. /**
  119246. * Disposes of the gizmo
  119247. */
  119248. dispose(): void;
  119249. }
  119250. }
  119251. declare module BABYLON.Debug {
  119252. /**
  119253. * The Axes viewer will show 3 axes in a specific point in space
  119254. */
  119255. export class AxesViewer {
  119256. private _xAxis;
  119257. private _yAxis;
  119258. private _zAxis;
  119259. private _scaleLinesFactor;
  119260. private _instanced;
  119261. /**
  119262. * Gets the hosting scene
  119263. */
  119264. scene: Scene;
  119265. /**
  119266. * Gets or sets a number used to scale line length
  119267. */
  119268. scaleLines: number;
  119269. /** Gets the node hierarchy used to render x-axis */
  119270. get xAxis(): TransformNode;
  119271. /** Gets the node hierarchy used to render y-axis */
  119272. get yAxis(): TransformNode;
  119273. /** Gets the node hierarchy used to render z-axis */
  119274. get zAxis(): TransformNode;
  119275. /**
  119276. * Creates a new AxesViewer
  119277. * @param scene defines the hosting scene
  119278. * @param scaleLines defines a number used to scale line length (1 by default)
  119279. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119280. * @param xAxis defines the node hierarchy used to render the x-axis
  119281. * @param yAxis defines the node hierarchy used to render the y-axis
  119282. * @param zAxis defines the node hierarchy used to render the z-axis
  119283. */
  119284. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119285. /**
  119286. * Force the viewer to update
  119287. * @param position defines the position of the viewer
  119288. * @param xaxis defines the x axis of the viewer
  119289. * @param yaxis defines the y axis of the viewer
  119290. * @param zaxis defines the z axis of the viewer
  119291. */
  119292. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119293. /**
  119294. * Creates an instance of this axes viewer.
  119295. * @returns a new axes viewer with instanced meshes
  119296. */
  119297. createInstance(): AxesViewer;
  119298. /** Releases resources */
  119299. dispose(): void;
  119300. private static _SetRenderingGroupId;
  119301. }
  119302. }
  119303. declare module BABYLON.Debug {
  119304. /**
  119305. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119306. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119307. */
  119308. export class BoneAxesViewer extends AxesViewer {
  119309. /**
  119310. * Gets or sets the target mesh where to display the axes viewer
  119311. */
  119312. mesh: Nullable<Mesh>;
  119313. /**
  119314. * Gets or sets the target bone where to display the axes viewer
  119315. */
  119316. bone: Nullable<Bone>;
  119317. /** Gets current position */
  119318. pos: Vector3;
  119319. /** Gets direction of X axis */
  119320. xaxis: Vector3;
  119321. /** Gets direction of Y axis */
  119322. yaxis: Vector3;
  119323. /** Gets direction of Z axis */
  119324. zaxis: Vector3;
  119325. /**
  119326. * Creates a new BoneAxesViewer
  119327. * @param scene defines the hosting scene
  119328. * @param bone defines the target bone
  119329. * @param mesh defines the target mesh
  119330. * @param scaleLines defines a scaling factor for line length (1 by default)
  119331. */
  119332. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119333. /**
  119334. * Force the viewer to update
  119335. */
  119336. update(): void;
  119337. /** Releases resources */
  119338. dispose(): void;
  119339. }
  119340. }
  119341. declare module BABYLON {
  119342. /**
  119343. * Interface used to define scene explorer extensibility option
  119344. */
  119345. export interface IExplorerExtensibilityOption {
  119346. /**
  119347. * Define the option label
  119348. */
  119349. label: string;
  119350. /**
  119351. * Defines the action to execute on click
  119352. */
  119353. action: (entity: any) => void;
  119354. }
  119355. /**
  119356. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119357. */
  119358. export interface IExplorerExtensibilityGroup {
  119359. /**
  119360. * Defines a predicate to test if a given type mut be extended
  119361. */
  119362. predicate: (entity: any) => boolean;
  119363. /**
  119364. * Gets the list of options added to a type
  119365. */
  119366. entries: IExplorerExtensibilityOption[];
  119367. }
  119368. /**
  119369. * Interface used to define the options to use to create the Inspector
  119370. */
  119371. export interface IInspectorOptions {
  119372. /**
  119373. * Display in overlay mode (default: false)
  119374. */
  119375. overlay?: boolean;
  119376. /**
  119377. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119378. */
  119379. globalRoot?: HTMLElement;
  119380. /**
  119381. * Display the Scene explorer
  119382. */
  119383. showExplorer?: boolean;
  119384. /**
  119385. * Display the property inspector
  119386. */
  119387. showInspector?: boolean;
  119388. /**
  119389. * Display in embed mode (both panes on the right)
  119390. */
  119391. embedMode?: boolean;
  119392. /**
  119393. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119394. */
  119395. handleResize?: boolean;
  119396. /**
  119397. * Allow the panes to popup (default: true)
  119398. */
  119399. enablePopup?: boolean;
  119400. /**
  119401. * Allow the panes to be closed by users (default: true)
  119402. */
  119403. enableClose?: boolean;
  119404. /**
  119405. * Optional list of extensibility entries
  119406. */
  119407. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119408. /**
  119409. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119410. */
  119411. inspectorURL?: string;
  119412. /**
  119413. * Optional initial tab (default to DebugLayerTab.Properties)
  119414. */
  119415. initialTab?: DebugLayerTab;
  119416. }
  119417. interface Scene {
  119418. /**
  119419. * @hidden
  119420. * Backing field
  119421. */
  119422. _debugLayer: DebugLayer;
  119423. /**
  119424. * Gets the debug layer (aka Inspector) associated with the scene
  119425. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119426. */
  119427. debugLayer: DebugLayer;
  119428. }
  119429. /**
  119430. * Enum of inspector action tab
  119431. */
  119432. export enum DebugLayerTab {
  119433. /**
  119434. * Properties tag (default)
  119435. */
  119436. Properties = 0,
  119437. /**
  119438. * Debug tab
  119439. */
  119440. Debug = 1,
  119441. /**
  119442. * Statistics tab
  119443. */
  119444. Statistics = 2,
  119445. /**
  119446. * Tools tab
  119447. */
  119448. Tools = 3,
  119449. /**
  119450. * Settings tab
  119451. */
  119452. Settings = 4
  119453. }
  119454. /**
  119455. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119456. * what is happening in your scene
  119457. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119458. */
  119459. export class DebugLayer {
  119460. /**
  119461. * Define the url to get the inspector script from.
  119462. * By default it uses the babylonjs CDN.
  119463. * @ignoreNaming
  119464. */
  119465. static InspectorURL: string;
  119466. private _scene;
  119467. private BJSINSPECTOR;
  119468. private _onPropertyChangedObservable?;
  119469. /**
  119470. * Observable triggered when a property is changed through the inspector.
  119471. */
  119472. get onPropertyChangedObservable(): any;
  119473. /**
  119474. * Instantiates a new debug layer.
  119475. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119476. * what is happening in your scene
  119477. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119478. * @param scene Defines the scene to inspect
  119479. */
  119480. constructor(scene: Scene);
  119481. /** Creates the inspector window. */
  119482. private _createInspector;
  119483. /**
  119484. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119485. * @param entity defines the entity to select
  119486. * @param lineContainerTitle defines the specific block to highlight
  119487. */
  119488. select(entity: any, lineContainerTitle?: string): void;
  119489. /** Get the inspector from bundle or global */
  119490. private _getGlobalInspector;
  119491. /**
  119492. * Get if the inspector is visible or not.
  119493. * @returns true if visible otherwise, false
  119494. */
  119495. isVisible(): boolean;
  119496. /**
  119497. * Hide the inspector and close its window.
  119498. */
  119499. hide(): void;
  119500. /**
  119501. * Launch the debugLayer.
  119502. * @param config Define the configuration of the inspector
  119503. * @return a promise fulfilled when the debug layer is visible
  119504. */
  119505. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119506. }
  119507. }
  119508. declare module BABYLON {
  119509. /**
  119510. * Class containing static functions to help procedurally build meshes
  119511. */
  119512. export class BoxBuilder {
  119513. /**
  119514. * Creates a box mesh
  119515. * * The parameter `size` sets the size (float) of each box side (default 1)
  119516. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119517. * * 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)
  119518. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119522. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119523. * @param name defines the name of the mesh
  119524. * @param options defines the options used to create the mesh
  119525. * @param scene defines the hosting scene
  119526. * @returns the box mesh
  119527. */
  119528. static CreateBox(name: string, options: {
  119529. size?: number;
  119530. width?: number;
  119531. height?: number;
  119532. depth?: number;
  119533. faceUV?: Vector4[];
  119534. faceColors?: Color4[];
  119535. sideOrientation?: number;
  119536. frontUVs?: Vector4;
  119537. backUVs?: Vector4;
  119538. wrap?: boolean;
  119539. topBaseAt?: number;
  119540. bottomBaseAt?: number;
  119541. updatable?: boolean;
  119542. }, scene?: Nullable<Scene>): Mesh;
  119543. }
  119544. }
  119545. declare module BABYLON.Debug {
  119546. /**
  119547. * Used to show the physics impostor around the specific mesh
  119548. */
  119549. export class PhysicsViewer {
  119550. /** @hidden */
  119551. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119552. /** @hidden */
  119553. protected _meshes: Array<Nullable<AbstractMesh>>;
  119554. /** @hidden */
  119555. protected _scene: Nullable<Scene>;
  119556. /** @hidden */
  119557. protected _numMeshes: number;
  119558. /** @hidden */
  119559. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119560. private _renderFunction;
  119561. private _utilityLayer;
  119562. private _debugBoxMesh;
  119563. private _debugSphereMesh;
  119564. private _debugCylinderMesh;
  119565. private _debugMaterial;
  119566. private _debugMeshMeshes;
  119567. /**
  119568. * Creates a new PhysicsViewer
  119569. * @param scene defines the hosting scene
  119570. */
  119571. constructor(scene: Scene);
  119572. /** @hidden */
  119573. protected _updateDebugMeshes(): void;
  119574. /**
  119575. * Renders a specified physic impostor
  119576. * @param impostor defines the impostor to render
  119577. * @param targetMesh defines the mesh represented by the impostor
  119578. * @returns the new debug mesh used to render the impostor
  119579. */
  119580. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119581. /**
  119582. * Hides a specified physic impostor
  119583. * @param impostor defines the impostor to hide
  119584. */
  119585. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119586. private _getDebugMaterial;
  119587. private _getDebugBoxMesh;
  119588. private _getDebugSphereMesh;
  119589. private _getDebugCylinderMesh;
  119590. private _getDebugMeshMesh;
  119591. private _getDebugMesh;
  119592. /** Releases all resources */
  119593. dispose(): void;
  119594. }
  119595. }
  119596. declare module BABYLON {
  119597. /**
  119598. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119599. * in order to better appreciate the issue one might have.
  119600. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119601. */
  119602. export class RayHelper {
  119603. /**
  119604. * Defines the ray we are currently tryin to visualize.
  119605. */
  119606. ray: Nullable<Ray>;
  119607. private _renderPoints;
  119608. private _renderLine;
  119609. private _renderFunction;
  119610. private _scene;
  119611. private _updateToMeshFunction;
  119612. private _attachedToMesh;
  119613. private _meshSpaceDirection;
  119614. private _meshSpaceOrigin;
  119615. /**
  119616. * Helper function to create a colored helper in a scene in one line.
  119617. * @param ray Defines the ray we are currently tryin to visualize
  119618. * @param scene Defines the scene the ray is used in
  119619. * @param color Defines the color we want to see the ray in
  119620. * @returns The newly created ray helper.
  119621. */
  119622. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119623. /**
  119624. * Instantiate a new ray helper.
  119625. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119626. * in order to better appreciate the issue one might have.
  119627. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119628. * @param ray Defines the ray we are currently tryin to visualize
  119629. */
  119630. constructor(ray: Ray);
  119631. /**
  119632. * Shows the ray we are willing to debug.
  119633. * @param scene Defines the scene the ray needs to be rendered in
  119634. * @param color Defines the color the ray needs to be rendered in
  119635. */
  119636. show(scene: Scene, color?: Color3): void;
  119637. /**
  119638. * Hides the ray we are debugging.
  119639. */
  119640. hide(): void;
  119641. private _render;
  119642. /**
  119643. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119644. * @param mesh Defines the mesh we want the helper attached to
  119645. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119646. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119647. * @param length Defines the length of the ray
  119648. */
  119649. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119650. /**
  119651. * Detach the ray helper from the mesh it has previously been attached to.
  119652. */
  119653. detachFromMesh(): void;
  119654. private _updateToMesh;
  119655. /**
  119656. * Dispose the helper and release its associated resources.
  119657. */
  119658. dispose(): void;
  119659. }
  119660. }
  119661. declare module BABYLON.Debug {
  119662. /**
  119663. * Class used to render a debug view of a given skeleton
  119664. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119665. */
  119666. export class SkeletonViewer {
  119667. /** defines the skeleton to render */
  119668. skeleton: Skeleton;
  119669. /** defines the mesh attached to the skeleton */
  119670. mesh: AbstractMesh;
  119671. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119672. autoUpdateBonesMatrices: boolean;
  119673. /** defines the rendering group id to use with the viewer */
  119674. renderingGroupId: number;
  119675. /** Gets or sets the color used to render the skeleton */
  119676. color: Color3;
  119677. private _scene;
  119678. private _debugLines;
  119679. private _debugMesh;
  119680. private _isEnabled;
  119681. private _renderFunction;
  119682. private _utilityLayer;
  119683. /**
  119684. * Returns the mesh used to render the bones
  119685. */
  119686. get debugMesh(): Nullable<LinesMesh>;
  119687. /**
  119688. * Creates a new SkeletonViewer
  119689. * @param skeleton defines the skeleton to render
  119690. * @param mesh defines the mesh attached to the skeleton
  119691. * @param scene defines the hosting scene
  119692. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119693. * @param renderingGroupId defines the rendering group id to use with the viewer
  119694. */
  119695. constructor(
  119696. /** defines the skeleton to render */
  119697. skeleton: Skeleton,
  119698. /** defines the mesh attached to the skeleton */
  119699. mesh: AbstractMesh, scene: Scene,
  119700. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119701. autoUpdateBonesMatrices?: boolean,
  119702. /** defines the rendering group id to use with the viewer */
  119703. renderingGroupId?: number);
  119704. /** Gets or sets a boolean indicating if the viewer is enabled */
  119705. set isEnabled(value: boolean);
  119706. get isEnabled(): boolean;
  119707. private _getBonePosition;
  119708. private _getLinesForBonesWithLength;
  119709. private _getLinesForBonesNoLength;
  119710. /** Update the viewer to sync with current skeleton state */
  119711. update(): void;
  119712. /** Release associated resources */
  119713. dispose(): void;
  119714. }
  119715. }
  119716. declare module BABYLON {
  119717. /**
  119718. * Options to create the null engine
  119719. */
  119720. export class NullEngineOptions {
  119721. /**
  119722. * Render width (Default: 512)
  119723. */
  119724. renderWidth: number;
  119725. /**
  119726. * Render height (Default: 256)
  119727. */
  119728. renderHeight: number;
  119729. /**
  119730. * Texture size (Default: 512)
  119731. */
  119732. textureSize: number;
  119733. /**
  119734. * If delta time between frames should be constant
  119735. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119736. */
  119737. deterministicLockstep: boolean;
  119738. /**
  119739. * Maximum about of steps between frames (Default: 4)
  119740. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119741. */
  119742. lockstepMaxSteps: number;
  119743. }
  119744. /**
  119745. * The null engine class provides support for headless version of babylon.js.
  119746. * This can be used in server side scenario or for testing purposes
  119747. */
  119748. export class NullEngine extends Engine {
  119749. private _options;
  119750. /**
  119751. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119752. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119753. * @returns true if engine is in deterministic lock step mode
  119754. */
  119755. isDeterministicLockStep(): boolean;
  119756. /**
  119757. * Gets the max steps when engine is running in deterministic lock step
  119758. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119759. * @returns the max steps
  119760. */
  119761. getLockstepMaxSteps(): number;
  119762. /**
  119763. * Gets the current hardware scaling level.
  119764. * By default the hardware scaling level is computed from the window device ratio.
  119765. * 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.
  119766. * @returns a number indicating the current hardware scaling level
  119767. */
  119768. getHardwareScalingLevel(): number;
  119769. constructor(options?: NullEngineOptions);
  119770. /**
  119771. * Creates a vertex buffer
  119772. * @param vertices the data for the vertex buffer
  119773. * @returns the new WebGL static buffer
  119774. */
  119775. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119776. /**
  119777. * Creates a new index buffer
  119778. * @param indices defines the content of the index buffer
  119779. * @param updatable defines if the index buffer must be updatable
  119780. * @returns a new webGL buffer
  119781. */
  119782. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119783. /**
  119784. * Clear the current render buffer or the current render target (if any is set up)
  119785. * @param color defines the color to use
  119786. * @param backBuffer defines if the back buffer must be cleared
  119787. * @param depth defines if the depth buffer must be cleared
  119788. * @param stencil defines if the stencil buffer must be cleared
  119789. */
  119790. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119791. /**
  119792. * Gets the current render width
  119793. * @param useScreen defines if screen size must be used (or the current render target if any)
  119794. * @returns a number defining the current render width
  119795. */
  119796. getRenderWidth(useScreen?: boolean): number;
  119797. /**
  119798. * Gets the current render height
  119799. * @param useScreen defines if screen size must be used (or the current render target if any)
  119800. * @returns a number defining the current render height
  119801. */
  119802. getRenderHeight(useScreen?: boolean): number;
  119803. /**
  119804. * Set the WebGL's viewport
  119805. * @param viewport defines the viewport element to be used
  119806. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119807. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119808. */
  119809. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119810. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119811. /**
  119812. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119813. * @param pipelineContext defines the pipeline context to use
  119814. * @param uniformsNames defines the list of uniform names
  119815. * @returns an array of webGL uniform locations
  119816. */
  119817. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119818. /**
  119819. * Gets the lsit of active attributes for a given webGL program
  119820. * @param pipelineContext defines the pipeline context to use
  119821. * @param attributesNames defines the list of attribute names to get
  119822. * @returns an array of indices indicating the offset of each attribute
  119823. */
  119824. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119825. /**
  119826. * Binds an effect to the webGL context
  119827. * @param effect defines the effect to bind
  119828. */
  119829. bindSamplers(effect: Effect): void;
  119830. /**
  119831. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119832. * @param effect defines the effect to activate
  119833. */
  119834. enableEffect(effect: Effect): void;
  119835. /**
  119836. * Set various states to the webGL context
  119837. * @param culling defines backface culling state
  119838. * @param zOffset defines the value to apply to zOffset (0 by default)
  119839. * @param force defines if states must be applied even if cache is up to date
  119840. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119841. */
  119842. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119843. /**
  119844. * Set the value of an uniform to an array of int32
  119845. * @param uniform defines the webGL uniform location where to store the value
  119846. * @param array defines the array of int32 to store
  119847. */
  119848. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119849. /**
  119850. * Set the value of an uniform to an array of int32 (stored as vec2)
  119851. * @param uniform defines the webGL uniform location where to store the value
  119852. * @param array defines the array of int32 to store
  119853. */
  119854. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119855. /**
  119856. * Set the value of an uniform to an array of int32 (stored as vec3)
  119857. * @param uniform defines the webGL uniform location where to store the value
  119858. * @param array defines the array of int32 to store
  119859. */
  119860. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119861. /**
  119862. * Set the value of an uniform to an array of int32 (stored as vec4)
  119863. * @param uniform defines the webGL uniform location where to store the value
  119864. * @param array defines the array of int32 to store
  119865. */
  119866. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119867. /**
  119868. * Set the value of an uniform to an array of float32
  119869. * @param uniform defines the webGL uniform location where to store the value
  119870. * @param array defines the array of float32 to store
  119871. */
  119872. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119873. /**
  119874. * Set the value of an uniform to an array of float32 (stored as vec2)
  119875. * @param uniform defines the webGL uniform location where to store the value
  119876. * @param array defines the array of float32 to store
  119877. */
  119878. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119879. /**
  119880. * Set the value of an uniform to an array of float32 (stored as vec3)
  119881. * @param uniform defines the webGL uniform location where to store the value
  119882. * @param array defines the array of float32 to store
  119883. */
  119884. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119885. /**
  119886. * Set the value of an uniform to an array of float32 (stored as vec4)
  119887. * @param uniform defines the webGL uniform location where to store the value
  119888. * @param array defines the array of float32 to store
  119889. */
  119890. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119891. /**
  119892. * Set the value of an uniform to an array of number
  119893. * @param uniform defines the webGL uniform location where to store the value
  119894. * @param array defines the array of number to store
  119895. */
  119896. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119897. /**
  119898. * Set the value of an uniform to an array of number (stored as vec2)
  119899. * @param uniform defines the webGL uniform location where to store the value
  119900. * @param array defines the array of number to store
  119901. */
  119902. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119903. /**
  119904. * Set the value of an uniform to an array of number (stored as vec3)
  119905. * @param uniform defines the webGL uniform location where to store the value
  119906. * @param array defines the array of number to store
  119907. */
  119908. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119909. /**
  119910. * Set the value of an uniform to an array of number (stored as vec4)
  119911. * @param uniform defines the webGL uniform location where to store the value
  119912. * @param array defines the array of number to store
  119913. */
  119914. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119915. /**
  119916. * Set the value of an uniform to an array of float32 (stored as matrices)
  119917. * @param uniform defines the webGL uniform location where to store the value
  119918. * @param matrices defines the array of float32 to store
  119919. */
  119920. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119921. /**
  119922. * Set the value of an uniform to a matrix (3x3)
  119923. * @param uniform defines the webGL uniform location where to store the value
  119924. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119925. */
  119926. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119927. /**
  119928. * Set the value of an uniform to a matrix (2x2)
  119929. * @param uniform defines the webGL uniform location where to store the value
  119930. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119931. */
  119932. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119933. /**
  119934. * Set the value of an uniform to a number (float)
  119935. * @param uniform defines the webGL uniform location where to store the value
  119936. * @param value defines the float number to store
  119937. */
  119938. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119939. /**
  119940. * Set the value of an uniform to a vec2
  119941. * @param uniform defines the webGL uniform location where to store the value
  119942. * @param x defines the 1st component of the value
  119943. * @param y defines the 2nd component of the value
  119944. */
  119945. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119946. /**
  119947. * Set the value of an uniform to a vec3
  119948. * @param uniform defines the webGL uniform location where to store the value
  119949. * @param x defines the 1st component of the value
  119950. * @param y defines the 2nd component of the value
  119951. * @param z defines the 3rd component of the value
  119952. */
  119953. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119954. /**
  119955. * Set the value of an uniform to a boolean
  119956. * @param uniform defines the webGL uniform location where to store the value
  119957. * @param bool defines the boolean to store
  119958. */
  119959. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119960. /**
  119961. * Set the value of an uniform to a vec4
  119962. * @param uniform defines the webGL uniform location where to store the value
  119963. * @param x defines the 1st component of the value
  119964. * @param y defines the 2nd component of the value
  119965. * @param z defines the 3rd component of the value
  119966. * @param w defines the 4th component of the value
  119967. */
  119968. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119969. /**
  119970. * Sets the current alpha mode
  119971. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119972. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119973. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119974. */
  119975. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119976. /**
  119977. * Bind webGl buffers directly to the webGL context
  119978. * @param vertexBuffers defines the vertex buffer to bind
  119979. * @param indexBuffer defines the index buffer to bind
  119980. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119981. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119982. * @param effect defines the effect associated with the vertex buffer
  119983. */
  119984. bindBuffers(vertexBuffers: {
  119985. [key: string]: VertexBuffer;
  119986. }, indexBuffer: DataBuffer, effect: Effect): void;
  119987. /**
  119988. * Force the entire cache to be cleared
  119989. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119990. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119991. */
  119992. wipeCaches(bruteForce?: boolean): void;
  119993. /**
  119994. * Send a draw order
  119995. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119996. * @param indexStart defines the starting index
  119997. * @param indexCount defines the number of index to draw
  119998. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119999. */
  120000. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120001. /**
  120002. * Draw a list of indexed primitives
  120003. * @param fillMode defines the primitive to use
  120004. * @param indexStart defines the starting index
  120005. * @param indexCount defines the number of index to draw
  120006. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120007. */
  120008. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120009. /**
  120010. * Draw a list of unindexed primitives
  120011. * @param fillMode defines the primitive to use
  120012. * @param verticesStart defines the index of first vertex to draw
  120013. * @param verticesCount defines the count of vertices to draw
  120014. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120015. */
  120016. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120017. /** @hidden */
  120018. _createTexture(): WebGLTexture;
  120019. /** @hidden */
  120020. _releaseTexture(texture: InternalTexture): void;
  120021. /**
  120022. * Usually called from Texture.ts.
  120023. * Passed information to create a WebGLTexture
  120024. * @param urlArg defines a value which contains one of the following:
  120025. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120026. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120027. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120028. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120029. * @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)
  120030. * @param scene needed for loading to the correct scene
  120031. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120032. * @param onLoad optional callback to be called upon successful completion
  120033. * @param onError optional callback to be called upon failure
  120034. * @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
  120035. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120036. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120037. * @param forcedExtension defines the extension to use to pick the right loader
  120038. * @param mimeType defines an optional mime type
  120039. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120040. */
  120041. 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;
  120042. /**
  120043. * Creates a new render target texture
  120044. * @param size defines the size of the texture
  120045. * @param options defines the options used to create the texture
  120046. * @returns a new render target texture stored in an InternalTexture
  120047. */
  120048. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120049. /**
  120050. * Update the sampling mode of a given texture
  120051. * @param samplingMode defines the required sampling mode
  120052. * @param texture defines the texture to update
  120053. */
  120054. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120055. /**
  120056. * Binds the frame buffer to the specified texture.
  120057. * @param texture The texture to render to or null for the default canvas
  120058. * @param faceIndex The face of the texture to render to in case of cube texture
  120059. * @param requiredWidth The width of the target to render to
  120060. * @param requiredHeight The height of the target to render to
  120061. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120062. * @param lodLevel defines le lod level to bind to the frame buffer
  120063. */
  120064. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120065. /**
  120066. * Unbind the current render target texture from the webGL context
  120067. * @param texture defines the render target texture to unbind
  120068. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120069. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120070. */
  120071. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120072. /**
  120073. * Creates a dynamic vertex buffer
  120074. * @param vertices the data for the dynamic vertex buffer
  120075. * @returns the new WebGL dynamic buffer
  120076. */
  120077. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120078. /**
  120079. * Update the content of a dynamic texture
  120080. * @param texture defines the texture to update
  120081. * @param canvas defines the canvas containing the source
  120082. * @param invertY defines if data must be stored with Y axis inverted
  120083. * @param premulAlpha defines if alpha is stored as premultiplied
  120084. * @param format defines the format of the data
  120085. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120086. */
  120087. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120088. /**
  120089. * Gets a boolean indicating if all created effects are ready
  120090. * @returns true if all effects are ready
  120091. */
  120092. areAllEffectsReady(): boolean;
  120093. /**
  120094. * @hidden
  120095. * Get the current error code of the webGL context
  120096. * @returns the error code
  120097. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120098. */
  120099. getError(): number;
  120100. /** @hidden */
  120101. _getUnpackAlignement(): number;
  120102. /** @hidden */
  120103. _unpackFlipY(value: boolean): void;
  120104. /**
  120105. * Update a dynamic index buffer
  120106. * @param indexBuffer defines the target index buffer
  120107. * @param indices defines the data to update
  120108. * @param offset defines the offset in the target index buffer where update should start
  120109. */
  120110. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120111. /**
  120112. * Updates a dynamic vertex buffer.
  120113. * @param vertexBuffer the vertex buffer to update
  120114. * @param vertices the data used to update the vertex buffer
  120115. * @param byteOffset the byte offset of the data (optional)
  120116. * @param byteLength the byte length of the data (optional)
  120117. */
  120118. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120119. /** @hidden */
  120120. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120121. /** @hidden */
  120122. _bindTexture(channel: number, texture: InternalTexture): void;
  120123. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120124. /**
  120125. * 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
  120126. */
  120127. releaseEffects(): void;
  120128. displayLoadingUI(): void;
  120129. hideLoadingUI(): void;
  120130. /** @hidden */
  120131. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120132. /** @hidden */
  120133. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120134. /** @hidden */
  120135. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120136. /** @hidden */
  120137. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120138. }
  120139. }
  120140. declare module BABYLON {
  120141. /**
  120142. * @hidden
  120143. **/
  120144. export class _TimeToken {
  120145. _startTimeQuery: Nullable<WebGLQuery>;
  120146. _endTimeQuery: Nullable<WebGLQuery>;
  120147. _timeElapsedQuery: Nullable<WebGLQuery>;
  120148. _timeElapsedQueryEnded: boolean;
  120149. }
  120150. }
  120151. declare module BABYLON {
  120152. /** @hidden */
  120153. export class _OcclusionDataStorage {
  120154. /** @hidden */
  120155. occlusionInternalRetryCounter: number;
  120156. /** @hidden */
  120157. isOcclusionQueryInProgress: boolean;
  120158. /** @hidden */
  120159. isOccluded: boolean;
  120160. /** @hidden */
  120161. occlusionRetryCount: number;
  120162. /** @hidden */
  120163. occlusionType: number;
  120164. /** @hidden */
  120165. occlusionQueryAlgorithmType: number;
  120166. }
  120167. interface Engine {
  120168. /**
  120169. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120170. * @return the new query
  120171. */
  120172. createQuery(): WebGLQuery;
  120173. /**
  120174. * Delete and release a webGL query
  120175. * @param query defines the query to delete
  120176. * @return the current engine
  120177. */
  120178. deleteQuery(query: WebGLQuery): Engine;
  120179. /**
  120180. * Check if a given query has resolved and got its value
  120181. * @param query defines the query to check
  120182. * @returns true if the query got its value
  120183. */
  120184. isQueryResultAvailable(query: WebGLQuery): boolean;
  120185. /**
  120186. * Gets the value of a given query
  120187. * @param query defines the query to check
  120188. * @returns the value of the query
  120189. */
  120190. getQueryResult(query: WebGLQuery): number;
  120191. /**
  120192. * Initiates an occlusion query
  120193. * @param algorithmType defines the algorithm to use
  120194. * @param query defines the query to use
  120195. * @returns the current engine
  120196. * @see http://doc.babylonjs.com/features/occlusionquery
  120197. */
  120198. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120199. /**
  120200. * Ends an occlusion query
  120201. * @see http://doc.babylonjs.com/features/occlusionquery
  120202. * @param algorithmType defines the algorithm to use
  120203. * @returns the current engine
  120204. */
  120205. endOcclusionQuery(algorithmType: number): Engine;
  120206. /**
  120207. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120208. * Please note that only one query can be issued at a time
  120209. * @returns a time token used to track the time span
  120210. */
  120211. startTimeQuery(): Nullable<_TimeToken>;
  120212. /**
  120213. * Ends a time query
  120214. * @param token defines the token used to measure the time span
  120215. * @returns the time spent (in ns)
  120216. */
  120217. endTimeQuery(token: _TimeToken): int;
  120218. /** @hidden */
  120219. _currentNonTimestampToken: Nullable<_TimeToken>;
  120220. /** @hidden */
  120221. _createTimeQuery(): WebGLQuery;
  120222. /** @hidden */
  120223. _deleteTimeQuery(query: WebGLQuery): void;
  120224. /** @hidden */
  120225. _getGlAlgorithmType(algorithmType: number): number;
  120226. /** @hidden */
  120227. _getTimeQueryResult(query: WebGLQuery): any;
  120228. /** @hidden */
  120229. _getTimeQueryAvailability(query: WebGLQuery): any;
  120230. }
  120231. interface AbstractMesh {
  120232. /**
  120233. * Backing filed
  120234. * @hidden
  120235. */
  120236. __occlusionDataStorage: _OcclusionDataStorage;
  120237. /**
  120238. * Access property
  120239. * @hidden
  120240. */
  120241. _occlusionDataStorage: _OcclusionDataStorage;
  120242. /**
  120243. * 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.
  120244. * The default value is -1 which means don't break the query and wait till the result
  120245. * @see http://doc.babylonjs.com/features/occlusionquery
  120246. */
  120247. occlusionRetryCount: number;
  120248. /**
  120249. * 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:
  120250. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120251. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120252. * * 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.
  120253. * @see http://doc.babylonjs.com/features/occlusionquery
  120254. */
  120255. occlusionType: number;
  120256. /**
  120257. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120258. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120259. * * 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.
  120260. * @see http://doc.babylonjs.com/features/occlusionquery
  120261. */
  120262. occlusionQueryAlgorithmType: number;
  120263. /**
  120264. * 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
  120265. * @see http://doc.babylonjs.com/features/occlusionquery
  120266. */
  120267. isOccluded: boolean;
  120268. /**
  120269. * Flag to check the progress status of the query
  120270. * @see http://doc.babylonjs.com/features/occlusionquery
  120271. */
  120272. isOcclusionQueryInProgress: boolean;
  120273. }
  120274. }
  120275. declare module BABYLON {
  120276. /** @hidden */
  120277. export var _forceTransformFeedbackToBundle: boolean;
  120278. interface Engine {
  120279. /**
  120280. * Creates a webGL transform feedback object
  120281. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120282. * @returns the webGL transform feedback object
  120283. */
  120284. createTransformFeedback(): WebGLTransformFeedback;
  120285. /**
  120286. * Delete a webGL transform feedback object
  120287. * @param value defines the webGL transform feedback object to delete
  120288. */
  120289. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120290. /**
  120291. * Bind a webGL transform feedback object to the webgl context
  120292. * @param value defines the webGL transform feedback object to bind
  120293. */
  120294. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120295. /**
  120296. * Begins a transform feedback operation
  120297. * @param usePoints defines if points or triangles must be used
  120298. */
  120299. beginTransformFeedback(usePoints: boolean): void;
  120300. /**
  120301. * Ends a transform feedback operation
  120302. */
  120303. endTransformFeedback(): void;
  120304. /**
  120305. * Specify the varyings to use with transform feedback
  120306. * @param program defines the associated webGL program
  120307. * @param value defines the list of strings representing the varying names
  120308. */
  120309. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120310. /**
  120311. * Bind a webGL buffer for a transform feedback operation
  120312. * @param value defines the webGL buffer to bind
  120313. */
  120314. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120315. }
  120316. }
  120317. declare module BABYLON {
  120318. /**
  120319. * Creation options of the multi render target texture.
  120320. */
  120321. export interface IMultiRenderTargetOptions {
  120322. /**
  120323. * Define if the texture needs to create mip maps after render.
  120324. */
  120325. generateMipMaps?: boolean;
  120326. /**
  120327. * Define the types of all the draw buffers we want to create
  120328. */
  120329. types?: number[];
  120330. /**
  120331. * Define the sampling modes of all the draw buffers we want to create
  120332. */
  120333. samplingModes?: number[];
  120334. /**
  120335. * Define if a depth buffer is required
  120336. */
  120337. generateDepthBuffer?: boolean;
  120338. /**
  120339. * Define if a stencil buffer is required
  120340. */
  120341. generateStencilBuffer?: boolean;
  120342. /**
  120343. * Define if a depth texture is required instead of a depth buffer
  120344. */
  120345. generateDepthTexture?: boolean;
  120346. /**
  120347. * Define the number of desired draw buffers
  120348. */
  120349. textureCount?: number;
  120350. /**
  120351. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120352. */
  120353. doNotChangeAspectRatio?: boolean;
  120354. /**
  120355. * Define the default type of the buffers we are creating
  120356. */
  120357. defaultType?: number;
  120358. }
  120359. /**
  120360. * A multi render target, like a render target provides the ability to render to a texture.
  120361. * Unlike the render target, it can render to several draw buffers in one draw.
  120362. * This is specially interesting in deferred rendering or for any effects requiring more than
  120363. * just one color from a single pass.
  120364. */
  120365. export class MultiRenderTarget extends RenderTargetTexture {
  120366. private _internalTextures;
  120367. private _textures;
  120368. private _multiRenderTargetOptions;
  120369. /**
  120370. * Get if draw buffers are currently supported by the used hardware and browser.
  120371. */
  120372. get isSupported(): boolean;
  120373. /**
  120374. * Get the list of textures generated by the multi render target.
  120375. */
  120376. get textures(): Texture[];
  120377. /**
  120378. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120379. */
  120380. get depthTexture(): Texture;
  120381. /**
  120382. * Set the wrapping mode on U of all the textures we are rendering to.
  120383. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120384. */
  120385. set wrapU(wrap: number);
  120386. /**
  120387. * Set the wrapping mode on V of all the textures we are rendering to.
  120388. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120389. */
  120390. set wrapV(wrap: number);
  120391. /**
  120392. * Instantiate a new multi render target texture.
  120393. * A multi render target, like a render target provides the ability to render to a texture.
  120394. * Unlike the render target, it can render to several draw buffers in one draw.
  120395. * This is specially interesting in deferred rendering or for any effects requiring more than
  120396. * just one color from a single pass.
  120397. * @param name Define the name of the texture
  120398. * @param size Define the size of the buffers to render to
  120399. * @param count Define the number of target we are rendering into
  120400. * @param scene Define the scene the texture belongs to
  120401. * @param options Define the options used to create the multi render target
  120402. */
  120403. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120404. /** @hidden */
  120405. _rebuild(): void;
  120406. private _createInternalTextures;
  120407. private _createTextures;
  120408. /**
  120409. * Define the number of samples used if MSAA is enabled.
  120410. */
  120411. get samples(): number;
  120412. set samples(value: number);
  120413. /**
  120414. * Resize all the textures in the multi render target.
  120415. * Be carrefull as it will recreate all the data in the new texture.
  120416. * @param size Define the new size
  120417. */
  120418. resize(size: any): void;
  120419. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120420. /**
  120421. * Dispose the render targets and their associated resources
  120422. */
  120423. dispose(): void;
  120424. /**
  120425. * Release all the underlying texture used as draw buffers.
  120426. */
  120427. releaseInternalTextures(): void;
  120428. }
  120429. }
  120430. declare module BABYLON {
  120431. interface ThinEngine {
  120432. /**
  120433. * Unbind a list of render target textures from the webGL context
  120434. * This is used only when drawBuffer extension or webGL2 are active
  120435. * @param textures defines the render target textures to unbind
  120436. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120437. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120438. */
  120439. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120440. /**
  120441. * Create a multi render target texture
  120442. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120443. * @param size defines the size of the texture
  120444. * @param options defines the creation options
  120445. * @returns the cube texture as an InternalTexture
  120446. */
  120447. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120448. /**
  120449. * Update the sample count for a given multiple render target texture
  120450. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120451. * @param textures defines the textures to update
  120452. * @param samples defines the sample count to set
  120453. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120454. */
  120455. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120456. }
  120457. }
  120458. declare module BABYLON {
  120459. /**
  120460. * Class used to define an additional view for the engine
  120461. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120462. */
  120463. export class EngineView {
  120464. /** Defines the canvas where to render the view */
  120465. target: HTMLCanvasElement;
  120466. /** Defines an optional camera used to render the view (will use active camera else) */
  120467. camera?: Camera;
  120468. }
  120469. interface Engine {
  120470. /**
  120471. * Gets or sets the HTML element to use for attaching events
  120472. */
  120473. inputElement: Nullable<HTMLElement>;
  120474. /**
  120475. * Gets the current engine view
  120476. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120477. */
  120478. activeView: Nullable<EngineView>;
  120479. /** Gets or sets the list of views */
  120480. views: EngineView[];
  120481. /**
  120482. * Register a new child canvas
  120483. * @param canvas defines the canvas to register
  120484. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120485. * @returns the associated view
  120486. */
  120487. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120488. /**
  120489. * Remove a registered child canvas
  120490. * @param canvas defines the canvas to remove
  120491. * @returns the current engine
  120492. */
  120493. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120494. }
  120495. }
  120496. declare module BABYLON {
  120497. /**
  120498. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120499. */
  120500. export interface CubeMapInfo {
  120501. /**
  120502. * The pixel array for the front face.
  120503. * This is stored in format, left to right, up to down format.
  120504. */
  120505. front: Nullable<ArrayBufferView>;
  120506. /**
  120507. * The pixel array for the back face.
  120508. * This is stored in format, left to right, up to down format.
  120509. */
  120510. back: Nullable<ArrayBufferView>;
  120511. /**
  120512. * The pixel array for the left face.
  120513. * This is stored in format, left to right, up to down format.
  120514. */
  120515. left: Nullable<ArrayBufferView>;
  120516. /**
  120517. * The pixel array for the right face.
  120518. * This is stored in format, left to right, up to down format.
  120519. */
  120520. right: Nullable<ArrayBufferView>;
  120521. /**
  120522. * The pixel array for the up face.
  120523. * This is stored in format, left to right, up to down format.
  120524. */
  120525. up: Nullable<ArrayBufferView>;
  120526. /**
  120527. * The pixel array for the down face.
  120528. * This is stored in format, left to right, up to down format.
  120529. */
  120530. down: Nullable<ArrayBufferView>;
  120531. /**
  120532. * The size of the cubemap stored.
  120533. *
  120534. * Each faces will be size * size pixels.
  120535. */
  120536. size: number;
  120537. /**
  120538. * The format of the texture.
  120539. *
  120540. * RGBA, RGB.
  120541. */
  120542. format: number;
  120543. /**
  120544. * The type of the texture data.
  120545. *
  120546. * UNSIGNED_INT, FLOAT.
  120547. */
  120548. type: number;
  120549. /**
  120550. * Specifies whether the texture is in gamma space.
  120551. */
  120552. gammaSpace: boolean;
  120553. }
  120554. /**
  120555. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120556. */
  120557. export class PanoramaToCubeMapTools {
  120558. private static FACE_FRONT;
  120559. private static FACE_BACK;
  120560. private static FACE_RIGHT;
  120561. private static FACE_LEFT;
  120562. private static FACE_DOWN;
  120563. private static FACE_UP;
  120564. /**
  120565. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120566. *
  120567. * @param float32Array The source data.
  120568. * @param inputWidth The width of the input panorama.
  120569. * @param inputHeight The height of the input panorama.
  120570. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120571. * @return The cubemap data
  120572. */
  120573. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120574. private static CreateCubemapTexture;
  120575. private static CalcProjectionSpherical;
  120576. }
  120577. }
  120578. declare module BABYLON {
  120579. /**
  120580. * Helper class dealing with the extraction of spherical polynomial dataArray
  120581. * from a cube map.
  120582. */
  120583. export class CubeMapToSphericalPolynomialTools {
  120584. private static FileFaces;
  120585. /**
  120586. * Converts a texture to the according Spherical Polynomial data.
  120587. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120588. *
  120589. * @param texture The texture to extract the information from.
  120590. * @return The Spherical Polynomial data.
  120591. */
  120592. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120593. /**
  120594. * Converts a cubemap to the according Spherical Polynomial data.
  120595. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120596. *
  120597. * @param cubeInfo The Cube map to extract the information from.
  120598. * @return The Spherical Polynomial data.
  120599. */
  120600. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120601. }
  120602. }
  120603. declare module BABYLON {
  120604. interface BaseTexture {
  120605. /**
  120606. * Get the polynomial representation of the texture data.
  120607. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120608. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120609. */
  120610. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120611. }
  120612. }
  120613. declare module BABYLON {
  120614. /** @hidden */
  120615. export var rgbdEncodePixelShader: {
  120616. name: string;
  120617. shader: string;
  120618. };
  120619. }
  120620. declare module BABYLON {
  120621. /** @hidden */
  120622. export var rgbdDecodePixelShader: {
  120623. name: string;
  120624. shader: string;
  120625. };
  120626. }
  120627. declare module BABYLON {
  120628. /**
  120629. * Raw texture data and descriptor sufficient for WebGL texture upload
  120630. */
  120631. export interface EnvironmentTextureInfo {
  120632. /**
  120633. * Version of the environment map
  120634. */
  120635. version: number;
  120636. /**
  120637. * Width of image
  120638. */
  120639. width: number;
  120640. /**
  120641. * Irradiance information stored in the file.
  120642. */
  120643. irradiance: any;
  120644. /**
  120645. * Specular information stored in the file.
  120646. */
  120647. specular: any;
  120648. }
  120649. /**
  120650. * Defines One Image in the file. It requires only the position in the file
  120651. * as well as the length.
  120652. */
  120653. interface BufferImageData {
  120654. /**
  120655. * Length of the image data.
  120656. */
  120657. length: number;
  120658. /**
  120659. * Position of the data from the null terminator delimiting the end of the JSON.
  120660. */
  120661. position: number;
  120662. }
  120663. /**
  120664. * Defines the specular data enclosed in the file.
  120665. * This corresponds to the version 1 of the data.
  120666. */
  120667. export interface EnvironmentTextureSpecularInfoV1 {
  120668. /**
  120669. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120670. */
  120671. specularDataPosition?: number;
  120672. /**
  120673. * This contains all the images data needed to reconstruct the cubemap.
  120674. */
  120675. mipmaps: Array<BufferImageData>;
  120676. /**
  120677. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120678. */
  120679. lodGenerationScale: number;
  120680. }
  120681. /**
  120682. * Sets of helpers addressing the serialization and deserialization of environment texture
  120683. * stored in a BabylonJS env file.
  120684. * Those files are usually stored as .env files.
  120685. */
  120686. export class EnvironmentTextureTools {
  120687. /**
  120688. * Magic number identifying the env file.
  120689. */
  120690. private static _MagicBytes;
  120691. /**
  120692. * Gets the environment info from an env file.
  120693. * @param data The array buffer containing the .env bytes.
  120694. * @returns the environment file info (the json header) if successfully parsed.
  120695. */
  120696. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120697. /**
  120698. * Creates an environment texture from a loaded cube texture.
  120699. * @param texture defines the cube texture to convert in env file
  120700. * @return a promise containing the environment data if succesfull.
  120701. */
  120702. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120703. /**
  120704. * Creates a JSON representation of the spherical data.
  120705. * @param texture defines the texture containing the polynomials
  120706. * @return the JSON representation of the spherical info
  120707. */
  120708. private static _CreateEnvTextureIrradiance;
  120709. /**
  120710. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120711. * @param data the image data
  120712. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120713. * @return the views described by info providing access to the underlying buffer
  120714. */
  120715. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120716. /**
  120717. * Uploads the texture info contained in the env file to the GPU.
  120718. * @param texture defines the internal texture to upload to
  120719. * @param data defines the data to load
  120720. * @param info defines the texture info retrieved through the GetEnvInfo method
  120721. * @returns a promise
  120722. */
  120723. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120724. private static _OnImageReadyAsync;
  120725. /**
  120726. * Uploads the levels of image data to the GPU.
  120727. * @param texture defines the internal texture to upload to
  120728. * @param imageData defines the array buffer views of image data [mipmap][face]
  120729. * @returns a promise
  120730. */
  120731. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120732. /**
  120733. * Uploads spherical polynomials information to the texture.
  120734. * @param texture defines the texture we are trying to upload the information to
  120735. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120736. */
  120737. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120738. /** @hidden */
  120739. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120740. }
  120741. }
  120742. declare module BABYLON {
  120743. /**
  120744. * Contains position and normal vectors for a vertex
  120745. */
  120746. export class PositionNormalVertex {
  120747. /** the position of the vertex (defaut: 0,0,0) */
  120748. position: Vector3;
  120749. /** the normal of the vertex (defaut: 0,1,0) */
  120750. normal: Vector3;
  120751. /**
  120752. * Creates a PositionNormalVertex
  120753. * @param position the position of the vertex (defaut: 0,0,0)
  120754. * @param normal the normal of the vertex (defaut: 0,1,0)
  120755. */
  120756. constructor(
  120757. /** the position of the vertex (defaut: 0,0,0) */
  120758. position?: Vector3,
  120759. /** the normal of the vertex (defaut: 0,1,0) */
  120760. normal?: Vector3);
  120761. /**
  120762. * Clones the PositionNormalVertex
  120763. * @returns the cloned PositionNormalVertex
  120764. */
  120765. clone(): PositionNormalVertex;
  120766. }
  120767. /**
  120768. * Contains position, normal and uv vectors for a vertex
  120769. */
  120770. export class PositionNormalTextureVertex {
  120771. /** the position of the vertex (defaut: 0,0,0) */
  120772. position: Vector3;
  120773. /** the normal of the vertex (defaut: 0,1,0) */
  120774. normal: Vector3;
  120775. /** the uv of the vertex (default: 0,0) */
  120776. uv: Vector2;
  120777. /**
  120778. * Creates a PositionNormalTextureVertex
  120779. * @param position the position of the vertex (defaut: 0,0,0)
  120780. * @param normal the normal of the vertex (defaut: 0,1,0)
  120781. * @param uv the uv of the vertex (default: 0,0)
  120782. */
  120783. constructor(
  120784. /** the position of the vertex (defaut: 0,0,0) */
  120785. position?: Vector3,
  120786. /** the normal of the vertex (defaut: 0,1,0) */
  120787. normal?: Vector3,
  120788. /** the uv of the vertex (default: 0,0) */
  120789. uv?: Vector2);
  120790. /**
  120791. * Clones the PositionNormalTextureVertex
  120792. * @returns the cloned PositionNormalTextureVertex
  120793. */
  120794. clone(): PositionNormalTextureVertex;
  120795. }
  120796. }
  120797. declare module BABYLON {
  120798. /** @hidden */
  120799. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120800. private _genericAttributeLocation;
  120801. private _varyingLocationCount;
  120802. private _varyingLocationMap;
  120803. private _replacements;
  120804. private _textureCount;
  120805. private _uniforms;
  120806. lineProcessor(line: string): string;
  120807. attributeProcessor(attribute: string): string;
  120808. varyingProcessor(varying: string, isFragment: boolean): string;
  120809. uniformProcessor(uniform: string): string;
  120810. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120811. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120812. }
  120813. }
  120814. declare module BABYLON {
  120815. /**
  120816. * Container for accessors for natively-stored mesh data buffers.
  120817. */
  120818. class NativeDataBuffer extends DataBuffer {
  120819. /**
  120820. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120821. */
  120822. nativeIndexBuffer?: any;
  120823. /**
  120824. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120825. */
  120826. nativeVertexBuffer?: any;
  120827. }
  120828. /** @hidden */
  120829. class NativeTexture extends InternalTexture {
  120830. getInternalTexture(): InternalTexture;
  120831. getViewCount(): number;
  120832. }
  120833. /** @hidden */
  120834. export class NativeEngine extends Engine {
  120835. private readonly _native;
  120836. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120837. private readonly INVALID_HANDLE;
  120838. getHardwareScalingLevel(): number;
  120839. constructor();
  120840. /**
  120841. * Can be used to override the current requestAnimationFrame requester.
  120842. * @hidden
  120843. */
  120844. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120845. /**
  120846. * Override default engine behavior.
  120847. * @param color
  120848. * @param backBuffer
  120849. * @param depth
  120850. * @param stencil
  120851. */
  120852. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120853. /**
  120854. * Gets host document
  120855. * @returns the host document object
  120856. */
  120857. getHostDocument(): Nullable<Document>;
  120858. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120859. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120860. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120861. recordVertexArrayObject(vertexBuffers: {
  120862. [key: string]: VertexBuffer;
  120863. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120864. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120865. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120866. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120867. /**
  120868. * Draw a list of indexed primitives
  120869. * @param fillMode defines the primitive to use
  120870. * @param indexStart defines the starting index
  120871. * @param indexCount defines the number of index to draw
  120872. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120873. */
  120874. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120875. /**
  120876. * Draw a list of unindexed primitives
  120877. * @param fillMode defines the primitive to use
  120878. * @param verticesStart defines the index of first vertex to draw
  120879. * @param verticesCount defines the count of vertices to draw
  120880. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120881. */
  120882. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120883. createPipelineContext(): IPipelineContext;
  120884. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120885. /** @hidden */
  120886. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120887. /** @hidden */
  120888. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120889. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120890. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120891. protected _setProgram(program: WebGLProgram): void;
  120892. _releaseEffect(effect: Effect): void;
  120893. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120894. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120895. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120896. bindSamplers(effect: Effect): void;
  120897. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120898. getRenderWidth(useScreen?: boolean): number;
  120899. getRenderHeight(useScreen?: boolean): number;
  120900. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120901. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120902. /**
  120903. * Set the z offset to apply to current rendering
  120904. * @param value defines the offset to apply
  120905. */
  120906. setZOffset(value: number): void;
  120907. /**
  120908. * Gets the current value of the zOffset
  120909. * @returns the current zOffset state
  120910. */
  120911. getZOffset(): number;
  120912. /**
  120913. * Enable or disable depth buffering
  120914. * @param enable defines the state to set
  120915. */
  120916. setDepthBuffer(enable: boolean): void;
  120917. /**
  120918. * Gets a boolean indicating if depth writing is enabled
  120919. * @returns the current depth writing state
  120920. */
  120921. getDepthWrite(): boolean;
  120922. /**
  120923. * Enable or disable depth writing
  120924. * @param enable defines the state to set
  120925. */
  120926. setDepthWrite(enable: boolean): void;
  120927. /**
  120928. * Enable or disable color writing
  120929. * @param enable defines the state to set
  120930. */
  120931. setColorWrite(enable: boolean): void;
  120932. /**
  120933. * Gets a boolean indicating if color writing is enabled
  120934. * @returns the current color writing state
  120935. */
  120936. getColorWrite(): boolean;
  120937. /**
  120938. * Sets alpha constants used by some alpha blending modes
  120939. * @param r defines the red component
  120940. * @param g defines the green component
  120941. * @param b defines the blue component
  120942. * @param a defines the alpha component
  120943. */
  120944. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120945. /**
  120946. * Sets the current alpha mode
  120947. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120948. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120949. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120950. */
  120951. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120952. /**
  120953. * Gets the current alpha mode
  120954. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120955. * @returns the current alpha mode
  120956. */
  120957. getAlphaMode(): number;
  120958. setInt(uniform: WebGLUniformLocation, int: number): void;
  120959. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120960. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120961. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120962. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120963. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120964. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120965. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120966. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120967. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120968. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120969. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120970. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120971. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120972. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120973. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120974. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120975. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120976. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120977. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120978. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120979. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120980. wipeCaches(bruteForce?: boolean): void;
  120981. _createTexture(): WebGLTexture;
  120982. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120983. /**
  120984. * Usually called from Texture.ts.
  120985. * Passed information to create a WebGLTexture
  120986. * @param urlArg defines a value which contains one of the following:
  120987. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120988. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120989. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120990. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120991. * @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)
  120992. * @param scene needed for loading to the correct scene
  120993. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120994. * @param onLoad optional callback to be called upon successful completion
  120995. * @param onError optional callback to be called upon failure
  120996. * @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
  120997. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120998. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120999. * @param forcedExtension defines the extension to use to pick the right loader
  121000. * @param mimeType defines an optional mime type
  121001. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121002. */
  121003. 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;
  121004. /**
  121005. * Creates a cube texture
  121006. * @param rootUrl defines the url where the files to load is located
  121007. * @param scene defines the current scene
  121008. * @param files defines the list of files to load (1 per face)
  121009. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  121010. * @param onLoad defines an optional callback raised when the texture is loaded
  121011. * @param onError defines an optional callback raised if there is an issue to load the texture
  121012. * @param format defines the format of the data
  121013. * @param forcedExtension defines the extension to use to pick the right loader
  121014. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  121015. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121016. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121017. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  121018. * @returns the cube texture as an InternalTexture
  121019. */
  121020. 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;
  121021. private _getSamplingFilter;
  121022. private static _GetNativeTextureFormat;
  121023. createRenderTargetTexture(size: number | {
  121024. width: number;
  121025. height: number;
  121026. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121027. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121028. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121029. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121030. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121031. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121032. /**
  121033. * Updates a dynamic vertex buffer.
  121034. * @param vertexBuffer the vertex buffer to update
  121035. * @param data the data used to update the vertex buffer
  121036. * @param byteOffset the byte offset of the data (optional)
  121037. * @param byteLength the byte length of the data (optional)
  121038. */
  121039. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121040. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121041. private _updateAnisotropicLevel;
  121042. private _getAddressMode;
  121043. /** @hidden */
  121044. _bindTexture(channel: number, texture: InternalTexture): void;
  121045. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121046. releaseEffects(): void;
  121047. /** @hidden */
  121048. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121049. /** @hidden */
  121050. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121051. /** @hidden */
  121052. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121053. /** @hidden */
  121054. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121055. }
  121056. }
  121057. declare module BABYLON {
  121058. /**
  121059. * Gather the list of clipboard event types as constants.
  121060. */
  121061. export class ClipboardEventTypes {
  121062. /**
  121063. * The clipboard event is fired when a copy command is active (pressed).
  121064. */
  121065. static readonly COPY: number;
  121066. /**
  121067. * The clipboard event is fired when a cut command is active (pressed).
  121068. */
  121069. static readonly CUT: number;
  121070. /**
  121071. * The clipboard event is fired when a paste command is active (pressed).
  121072. */
  121073. static readonly PASTE: number;
  121074. }
  121075. /**
  121076. * This class is used to store clipboard related info for the onClipboardObservable event.
  121077. */
  121078. export class ClipboardInfo {
  121079. /**
  121080. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121081. */
  121082. type: number;
  121083. /**
  121084. * Defines the related dom event
  121085. */
  121086. event: ClipboardEvent;
  121087. /**
  121088. *Creates an instance of ClipboardInfo.
  121089. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121090. * @param event Defines the related dom event
  121091. */
  121092. constructor(
  121093. /**
  121094. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121095. */
  121096. type: number,
  121097. /**
  121098. * Defines the related dom event
  121099. */
  121100. event: ClipboardEvent);
  121101. /**
  121102. * Get the clipboard event's type from the keycode.
  121103. * @param keyCode Defines the keyCode for the current keyboard event.
  121104. * @return {number}
  121105. */
  121106. static GetTypeFromCharacter(keyCode: number): number;
  121107. }
  121108. }
  121109. declare module BABYLON {
  121110. /**
  121111. * Google Daydream controller
  121112. */
  121113. export class DaydreamController extends WebVRController {
  121114. /**
  121115. * Base Url for the controller model.
  121116. */
  121117. static MODEL_BASE_URL: string;
  121118. /**
  121119. * File name for the controller model.
  121120. */
  121121. static MODEL_FILENAME: string;
  121122. /**
  121123. * Gamepad Id prefix used to identify Daydream Controller.
  121124. */
  121125. static readonly GAMEPAD_ID_PREFIX: string;
  121126. /**
  121127. * Creates a new DaydreamController from a gamepad
  121128. * @param vrGamepad the gamepad that the controller should be created from
  121129. */
  121130. constructor(vrGamepad: any);
  121131. /**
  121132. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121133. * @param scene scene in which to add meshes
  121134. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121135. */
  121136. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121137. /**
  121138. * Called once for each button that changed state since the last frame
  121139. * @param buttonIdx Which button index changed
  121140. * @param state New state of the button
  121141. * @param changes Which properties on the state changed since last frame
  121142. */
  121143. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121144. }
  121145. }
  121146. declare module BABYLON {
  121147. /**
  121148. * Gear VR Controller
  121149. */
  121150. export class GearVRController extends WebVRController {
  121151. /**
  121152. * Base Url for the controller model.
  121153. */
  121154. static MODEL_BASE_URL: string;
  121155. /**
  121156. * File name for the controller model.
  121157. */
  121158. static MODEL_FILENAME: string;
  121159. /**
  121160. * Gamepad Id prefix used to identify this controller.
  121161. */
  121162. static readonly GAMEPAD_ID_PREFIX: string;
  121163. private readonly _buttonIndexToObservableNameMap;
  121164. /**
  121165. * Creates a new GearVRController from a gamepad
  121166. * @param vrGamepad the gamepad that the controller should be created from
  121167. */
  121168. constructor(vrGamepad: any);
  121169. /**
  121170. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121171. * @param scene scene in which to add meshes
  121172. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121173. */
  121174. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121175. /**
  121176. * Called once for each button that changed state since the last frame
  121177. * @param buttonIdx Which button index changed
  121178. * @param state New state of the button
  121179. * @param changes Which properties on the state changed since last frame
  121180. */
  121181. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121182. }
  121183. }
  121184. declare module BABYLON {
  121185. /**
  121186. * Generic Controller
  121187. */
  121188. export class GenericController extends WebVRController {
  121189. /**
  121190. * Base Url for the controller model.
  121191. */
  121192. static readonly MODEL_BASE_URL: string;
  121193. /**
  121194. * File name for the controller model.
  121195. */
  121196. static readonly MODEL_FILENAME: string;
  121197. /**
  121198. * Creates a new GenericController from a gamepad
  121199. * @param vrGamepad the gamepad that the controller should be created from
  121200. */
  121201. constructor(vrGamepad: any);
  121202. /**
  121203. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121204. * @param scene scene in which to add meshes
  121205. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121206. */
  121207. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121208. /**
  121209. * Called once for each button that changed state since the last frame
  121210. * @param buttonIdx Which button index changed
  121211. * @param state New state of the button
  121212. * @param changes Which properties on the state changed since last frame
  121213. */
  121214. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121215. }
  121216. }
  121217. declare module BABYLON {
  121218. /**
  121219. * Oculus Touch Controller
  121220. */
  121221. export class OculusTouchController extends WebVRController {
  121222. /**
  121223. * Base Url for the controller model.
  121224. */
  121225. static MODEL_BASE_URL: string;
  121226. /**
  121227. * File name for the left controller model.
  121228. */
  121229. static MODEL_LEFT_FILENAME: string;
  121230. /**
  121231. * File name for the right controller model.
  121232. */
  121233. static MODEL_RIGHT_FILENAME: string;
  121234. /**
  121235. * Base Url for the Quest controller model.
  121236. */
  121237. static QUEST_MODEL_BASE_URL: string;
  121238. /**
  121239. * @hidden
  121240. * If the controllers are running on a device that needs the updated Quest controller models
  121241. */
  121242. static _IsQuest: boolean;
  121243. /**
  121244. * Fired when the secondary trigger on this controller is modified
  121245. */
  121246. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121247. /**
  121248. * Fired when the thumb rest on this controller is modified
  121249. */
  121250. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121251. /**
  121252. * Creates a new OculusTouchController from a gamepad
  121253. * @param vrGamepad the gamepad that the controller should be created from
  121254. */
  121255. constructor(vrGamepad: any);
  121256. /**
  121257. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121258. * @param scene scene in which to add meshes
  121259. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121260. */
  121261. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121262. /**
  121263. * Fired when the A button on this controller is modified
  121264. */
  121265. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121266. /**
  121267. * Fired when the B button on this controller is modified
  121268. */
  121269. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121270. /**
  121271. * Fired when the X button on this controller is modified
  121272. */
  121273. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121274. /**
  121275. * Fired when the Y button on this controller is modified
  121276. */
  121277. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121278. /**
  121279. * Called once for each button that changed state since the last frame
  121280. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121281. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121282. * 2) secondary trigger (same)
  121283. * 3) A (right) X (left), touch, pressed = value
  121284. * 4) B / Y
  121285. * 5) thumb rest
  121286. * @param buttonIdx Which button index changed
  121287. * @param state New state of the button
  121288. * @param changes Which properties on the state changed since last frame
  121289. */
  121290. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121291. }
  121292. }
  121293. declare module BABYLON {
  121294. /**
  121295. * Vive Controller
  121296. */
  121297. export class ViveController extends WebVRController {
  121298. /**
  121299. * Base Url for the controller model.
  121300. */
  121301. static MODEL_BASE_URL: string;
  121302. /**
  121303. * File name for the controller model.
  121304. */
  121305. static MODEL_FILENAME: string;
  121306. /**
  121307. * Creates a new ViveController from a gamepad
  121308. * @param vrGamepad the gamepad that the controller should be created from
  121309. */
  121310. constructor(vrGamepad: any);
  121311. /**
  121312. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121313. * @param scene scene in which to add meshes
  121314. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121315. */
  121316. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121317. /**
  121318. * Fired when the left button on this controller is modified
  121319. */
  121320. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121321. /**
  121322. * Fired when the right button on this controller is modified
  121323. */
  121324. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121325. /**
  121326. * Fired when the menu button on this controller is modified
  121327. */
  121328. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121329. /**
  121330. * Called once for each button that changed state since the last frame
  121331. * Vive mapping:
  121332. * 0: touchpad
  121333. * 1: trigger
  121334. * 2: left AND right buttons
  121335. * 3: menu button
  121336. * @param buttonIdx Which button index changed
  121337. * @param state New state of the button
  121338. * @param changes Which properties on the state changed since last frame
  121339. */
  121340. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121341. }
  121342. }
  121343. declare module BABYLON {
  121344. /**
  121345. * Defines the WindowsMotionController object that the state of the windows motion controller
  121346. */
  121347. export class WindowsMotionController extends WebVRController {
  121348. /**
  121349. * The base url used to load the left and right controller models
  121350. */
  121351. static MODEL_BASE_URL: string;
  121352. /**
  121353. * The name of the left controller model file
  121354. */
  121355. static MODEL_LEFT_FILENAME: string;
  121356. /**
  121357. * The name of the right controller model file
  121358. */
  121359. static MODEL_RIGHT_FILENAME: string;
  121360. /**
  121361. * The controller name prefix for this controller type
  121362. */
  121363. static readonly GAMEPAD_ID_PREFIX: string;
  121364. /**
  121365. * The controller id pattern for this controller type
  121366. */
  121367. private static readonly GAMEPAD_ID_PATTERN;
  121368. private _loadedMeshInfo;
  121369. protected readonly _mapping: {
  121370. buttons: string[];
  121371. buttonMeshNames: {
  121372. 'trigger': string;
  121373. 'menu': string;
  121374. 'grip': string;
  121375. 'thumbstick': string;
  121376. 'trackpad': string;
  121377. };
  121378. buttonObservableNames: {
  121379. 'trigger': string;
  121380. 'menu': string;
  121381. 'grip': string;
  121382. 'thumbstick': string;
  121383. 'trackpad': string;
  121384. };
  121385. axisMeshNames: string[];
  121386. pointingPoseMeshName: string;
  121387. };
  121388. /**
  121389. * Fired when the trackpad on this controller is clicked
  121390. */
  121391. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121392. /**
  121393. * Fired when the trackpad on this controller is modified
  121394. */
  121395. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121396. /**
  121397. * The current x and y values of this controller's trackpad
  121398. */
  121399. trackpad: StickValues;
  121400. /**
  121401. * Creates a new WindowsMotionController from a gamepad
  121402. * @param vrGamepad the gamepad that the controller should be created from
  121403. */
  121404. constructor(vrGamepad: any);
  121405. /**
  121406. * Fired when the trigger on this controller is modified
  121407. */
  121408. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121409. /**
  121410. * Fired when the menu button on this controller is modified
  121411. */
  121412. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121413. /**
  121414. * Fired when the grip button on this controller is modified
  121415. */
  121416. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121417. /**
  121418. * Fired when the thumbstick button on this controller is modified
  121419. */
  121420. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121421. /**
  121422. * Fired when the touchpad button on this controller is modified
  121423. */
  121424. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121425. /**
  121426. * Fired when the touchpad values on this controller are modified
  121427. */
  121428. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121429. protected _updateTrackpad(): void;
  121430. /**
  121431. * Called once per frame by the engine.
  121432. */
  121433. update(): void;
  121434. /**
  121435. * Called once for each button that changed state since the last frame
  121436. * @param buttonIdx Which button index changed
  121437. * @param state New state of the button
  121438. * @param changes Which properties on the state changed since last frame
  121439. */
  121440. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121441. /**
  121442. * Moves the buttons on the controller mesh based on their current state
  121443. * @param buttonName the name of the button to move
  121444. * @param buttonValue the value of the button which determines the buttons new position
  121445. */
  121446. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121447. /**
  121448. * Moves the axis on the controller mesh based on its current state
  121449. * @param axis the index of the axis
  121450. * @param axisValue the value of the axis which determines the meshes new position
  121451. * @hidden
  121452. */
  121453. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121454. /**
  121455. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121456. * @param scene scene in which to add meshes
  121457. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121458. */
  121459. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121460. /**
  121461. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121462. * can be transformed by button presses and axes values, based on this._mapping.
  121463. *
  121464. * @param scene scene in which the meshes exist
  121465. * @param meshes list of meshes that make up the controller model to process
  121466. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121467. */
  121468. private processModel;
  121469. private createMeshInfo;
  121470. /**
  121471. * Gets the ray of the controller in the direction the controller is pointing
  121472. * @param length the length the resulting ray should be
  121473. * @returns a ray in the direction the controller is pointing
  121474. */
  121475. getForwardRay(length?: number): Ray;
  121476. /**
  121477. * Disposes of the controller
  121478. */
  121479. dispose(): void;
  121480. }
  121481. /**
  121482. * This class represents a new windows motion controller in XR.
  121483. */
  121484. export class XRWindowsMotionController extends WindowsMotionController {
  121485. /**
  121486. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121487. */
  121488. protected readonly _mapping: {
  121489. buttons: string[];
  121490. buttonMeshNames: {
  121491. 'trigger': string;
  121492. 'menu': string;
  121493. 'grip': string;
  121494. 'thumbstick': string;
  121495. 'trackpad': string;
  121496. };
  121497. buttonObservableNames: {
  121498. 'trigger': string;
  121499. 'menu': string;
  121500. 'grip': string;
  121501. 'thumbstick': string;
  121502. 'trackpad': string;
  121503. };
  121504. axisMeshNames: string[];
  121505. pointingPoseMeshName: string;
  121506. };
  121507. /**
  121508. * Construct a new XR-Based windows motion controller
  121509. *
  121510. * @param gamepadInfo the gamepad object from the browser
  121511. */
  121512. constructor(gamepadInfo: any);
  121513. /**
  121514. * holds the thumbstick values (X,Y)
  121515. */
  121516. thumbstickValues: StickValues;
  121517. /**
  121518. * Fired when the thumbstick on this controller is clicked
  121519. */
  121520. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121521. /**
  121522. * Fired when the thumbstick on this controller is modified
  121523. */
  121524. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121525. /**
  121526. * Fired when the touchpad button on this controller is modified
  121527. */
  121528. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121529. /**
  121530. * Fired when the touchpad values on this controller are modified
  121531. */
  121532. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121533. /**
  121534. * Fired when the thumbstick button on this controller is modified
  121535. * here to prevent breaking changes
  121536. */
  121537. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121538. /**
  121539. * updating the thumbstick(!) and not the trackpad.
  121540. * This is named this way due to the difference between WebVR and XR and to avoid
  121541. * changing the parent class.
  121542. */
  121543. protected _updateTrackpad(): void;
  121544. /**
  121545. * Disposes the class with joy
  121546. */
  121547. dispose(): void;
  121548. }
  121549. }
  121550. declare module BABYLON {
  121551. /**
  121552. * Class containing static functions to help procedurally build meshes
  121553. */
  121554. export class PolyhedronBuilder {
  121555. /**
  121556. * Creates a polyhedron mesh
  121557. * * 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
  121558. * * The parameter `size` (positive float, default 1) sets the polygon size
  121559. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121560. * * 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`
  121561. * * 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
  121562. * * 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)`)
  121563. * * 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
  121564. * * 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
  121565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121568. * @param name defines the name of the mesh
  121569. * @param options defines the options used to create the mesh
  121570. * @param scene defines the hosting scene
  121571. * @returns the polyhedron mesh
  121572. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121573. */
  121574. static CreatePolyhedron(name: string, options: {
  121575. type?: number;
  121576. size?: number;
  121577. sizeX?: number;
  121578. sizeY?: number;
  121579. sizeZ?: number;
  121580. custom?: any;
  121581. faceUV?: Vector4[];
  121582. faceColors?: Color4[];
  121583. flat?: boolean;
  121584. updatable?: boolean;
  121585. sideOrientation?: number;
  121586. frontUVs?: Vector4;
  121587. backUVs?: Vector4;
  121588. }, scene?: Nullable<Scene>): Mesh;
  121589. }
  121590. }
  121591. declare module BABYLON {
  121592. /**
  121593. * Gizmo that enables scaling a mesh along 3 axis
  121594. */
  121595. export class ScaleGizmo extends Gizmo {
  121596. /**
  121597. * Internal gizmo used for interactions on the x axis
  121598. */
  121599. xGizmo: AxisScaleGizmo;
  121600. /**
  121601. * Internal gizmo used for interactions on the y axis
  121602. */
  121603. yGizmo: AxisScaleGizmo;
  121604. /**
  121605. * Internal gizmo used for interactions on the z axis
  121606. */
  121607. zGizmo: AxisScaleGizmo;
  121608. /**
  121609. * Internal gizmo used to scale all axis equally
  121610. */
  121611. uniformScaleGizmo: AxisScaleGizmo;
  121612. private _meshAttached;
  121613. private _updateGizmoRotationToMatchAttachedMesh;
  121614. private _snapDistance;
  121615. private _scaleRatio;
  121616. private _uniformScalingMesh;
  121617. private _octahedron;
  121618. private _sensitivity;
  121619. /** Fires an event when any of it's sub gizmos are dragged */
  121620. onDragStartObservable: Observable<unknown>;
  121621. /** Fires an event when any of it's sub gizmos are released from dragging */
  121622. onDragEndObservable: Observable<unknown>;
  121623. get attachedMesh(): Nullable<AbstractMesh>;
  121624. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121625. /**
  121626. * Creates a ScaleGizmo
  121627. * @param gizmoLayer The utility layer the gizmo will be added to
  121628. */
  121629. constructor(gizmoLayer?: UtilityLayerRenderer);
  121630. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121631. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121632. /**
  121633. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121634. */
  121635. set snapDistance(value: number);
  121636. get snapDistance(): number;
  121637. /**
  121638. * Ratio for the scale of the gizmo (Default: 1)
  121639. */
  121640. set scaleRatio(value: number);
  121641. get scaleRatio(): number;
  121642. /**
  121643. * Sensitivity factor for dragging (Default: 1)
  121644. */
  121645. set sensitivity(value: number);
  121646. get sensitivity(): number;
  121647. /**
  121648. * Disposes of the gizmo
  121649. */
  121650. dispose(): void;
  121651. }
  121652. }
  121653. declare module BABYLON {
  121654. /**
  121655. * Single axis scale gizmo
  121656. */
  121657. export class AxisScaleGizmo extends Gizmo {
  121658. /**
  121659. * Drag behavior responsible for the gizmos dragging interactions
  121660. */
  121661. dragBehavior: PointerDragBehavior;
  121662. private _pointerObserver;
  121663. /**
  121664. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121665. */
  121666. snapDistance: number;
  121667. /**
  121668. * Event that fires each time the gizmo snaps to a new location.
  121669. * * snapDistance is the the change in distance
  121670. */
  121671. onSnapObservable: Observable<{
  121672. snapDistance: number;
  121673. }>;
  121674. /**
  121675. * If the scaling operation should be done on all axis (default: false)
  121676. */
  121677. uniformScaling: boolean;
  121678. /**
  121679. * Custom sensitivity value for the drag strength
  121680. */
  121681. sensitivity: number;
  121682. private _isEnabled;
  121683. private _parent;
  121684. private _arrow;
  121685. private _coloredMaterial;
  121686. private _hoverMaterial;
  121687. /**
  121688. * Creates an AxisScaleGizmo
  121689. * @param gizmoLayer The utility layer the gizmo will be added to
  121690. * @param dragAxis The axis which the gizmo will be able to scale on
  121691. * @param color The color of the gizmo
  121692. */
  121693. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121694. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121695. /**
  121696. * If the gizmo is enabled
  121697. */
  121698. set isEnabled(value: boolean);
  121699. get isEnabled(): boolean;
  121700. /**
  121701. * Disposes of the gizmo
  121702. */
  121703. dispose(): void;
  121704. /**
  121705. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121706. * @param mesh The mesh to replace the default mesh of the gizmo
  121707. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121708. */
  121709. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121710. }
  121711. }
  121712. declare module BABYLON {
  121713. /**
  121714. * Bounding box gizmo
  121715. */
  121716. export class BoundingBoxGizmo extends Gizmo {
  121717. private _lineBoundingBox;
  121718. private _rotateSpheresParent;
  121719. private _scaleBoxesParent;
  121720. private _boundingDimensions;
  121721. private _renderObserver;
  121722. private _pointerObserver;
  121723. private _scaleDragSpeed;
  121724. private _tmpQuaternion;
  121725. private _tmpVector;
  121726. private _tmpRotationMatrix;
  121727. /**
  121728. * 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)
  121729. */
  121730. ignoreChildren: boolean;
  121731. /**
  121732. * 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)
  121733. */
  121734. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121735. /**
  121736. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121737. */
  121738. rotationSphereSize: number;
  121739. /**
  121740. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121741. */
  121742. scaleBoxSize: number;
  121743. /**
  121744. * 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)
  121745. */
  121746. fixedDragMeshScreenSize: boolean;
  121747. /**
  121748. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121749. */
  121750. fixedDragMeshScreenSizeDistanceFactor: number;
  121751. /**
  121752. * Fired when a rotation sphere or scale box is dragged
  121753. */
  121754. onDragStartObservable: Observable<{}>;
  121755. /**
  121756. * Fired when a scale box is dragged
  121757. */
  121758. onScaleBoxDragObservable: Observable<{}>;
  121759. /**
  121760. * Fired when a scale box drag is ended
  121761. */
  121762. onScaleBoxDragEndObservable: Observable<{}>;
  121763. /**
  121764. * Fired when a rotation sphere is dragged
  121765. */
  121766. onRotationSphereDragObservable: Observable<{}>;
  121767. /**
  121768. * Fired when a rotation sphere drag is ended
  121769. */
  121770. onRotationSphereDragEndObservable: Observable<{}>;
  121771. /**
  121772. * 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)
  121773. */
  121774. scalePivot: Nullable<Vector3>;
  121775. /**
  121776. * Mesh used as a pivot to rotate the attached mesh
  121777. */
  121778. private _anchorMesh;
  121779. private _existingMeshScale;
  121780. private _dragMesh;
  121781. private pointerDragBehavior;
  121782. private coloredMaterial;
  121783. private hoverColoredMaterial;
  121784. /**
  121785. * Sets the color of the bounding box gizmo
  121786. * @param color the color to set
  121787. */
  121788. setColor(color: Color3): void;
  121789. /**
  121790. * Creates an BoundingBoxGizmo
  121791. * @param gizmoLayer The utility layer the gizmo will be added to
  121792. * @param color The color of the gizmo
  121793. */
  121794. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121795. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121796. private _selectNode;
  121797. /**
  121798. * Updates the bounding box information for the Gizmo
  121799. */
  121800. updateBoundingBox(): void;
  121801. private _updateRotationSpheres;
  121802. private _updateScaleBoxes;
  121803. /**
  121804. * Enables rotation on the specified axis and disables rotation on the others
  121805. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121806. */
  121807. setEnabledRotationAxis(axis: string): void;
  121808. /**
  121809. * Enables/disables scaling
  121810. * @param enable if scaling should be enabled
  121811. */
  121812. setEnabledScaling(enable: boolean): void;
  121813. private _updateDummy;
  121814. /**
  121815. * Enables a pointer drag behavior on the bounding box of the gizmo
  121816. */
  121817. enableDragBehavior(): void;
  121818. /**
  121819. * Disposes of the gizmo
  121820. */
  121821. dispose(): void;
  121822. /**
  121823. * 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)
  121824. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121825. * @returns the bounding box mesh with the passed in mesh as a child
  121826. */
  121827. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121828. /**
  121829. * CustomMeshes are not supported by this gizmo
  121830. * @param mesh The mesh to replace the default mesh of the gizmo
  121831. */
  121832. setCustomMesh(mesh: Mesh): void;
  121833. }
  121834. }
  121835. declare module BABYLON {
  121836. /**
  121837. * Single plane rotation gizmo
  121838. */
  121839. export class PlaneRotationGizmo extends Gizmo {
  121840. /**
  121841. * Drag behavior responsible for the gizmos dragging interactions
  121842. */
  121843. dragBehavior: PointerDragBehavior;
  121844. private _pointerObserver;
  121845. /**
  121846. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121847. */
  121848. snapDistance: number;
  121849. /**
  121850. * Event that fires each time the gizmo snaps to a new location.
  121851. * * snapDistance is the the change in distance
  121852. */
  121853. onSnapObservable: Observable<{
  121854. snapDistance: number;
  121855. }>;
  121856. private _isEnabled;
  121857. private _parent;
  121858. /**
  121859. * Creates a PlaneRotationGizmo
  121860. * @param gizmoLayer The utility layer the gizmo will be added to
  121861. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121862. * @param color The color of the gizmo
  121863. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121864. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121865. */
  121866. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121867. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121868. /**
  121869. * If the gizmo is enabled
  121870. */
  121871. set isEnabled(value: boolean);
  121872. get isEnabled(): boolean;
  121873. /**
  121874. * Disposes of the gizmo
  121875. */
  121876. dispose(): void;
  121877. }
  121878. }
  121879. declare module BABYLON {
  121880. /**
  121881. * Gizmo that enables rotating a mesh along 3 axis
  121882. */
  121883. export class RotationGizmo extends Gizmo {
  121884. /**
  121885. * Internal gizmo used for interactions on the x axis
  121886. */
  121887. xGizmo: PlaneRotationGizmo;
  121888. /**
  121889. * Internal gizmo used for interactions on the y axis
  121890. */
  121891. yGizmo: PlaneRotationGizmo;
  121892. /**
  121893. * Internal gizmo used for interactions on the z axis
  121894. */
  121895. zGizmo: PlaneRotationGizmo;
  121896. /** Fires an event when any of it's sub gizmos are dragged */
  121897. onDragStartObservable: Observable<unknown>;
  121898. /** Fires an event when any of it's sub gizmos are released from dragging */
  121899. onDragEndObservable: Observable<unknown>;
  121900. private _meshAttached;
  121901. get attachedMesh(): Nullable<AbstractMesh>;
  121902. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121903. /**
  121904. * Creates a RotationGizmo
  121905. * @param gizmoLayer The utility layer the gizmo will be added to
  121906. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121907. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121908. */
  121909. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121910. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121911. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121912. /**
  121913. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121914. */
  121915. set snapDistance(value: number);
  121916. get snapDistance(): number;
  121917. /**
  121918. * Ratio for the scale of the gizmo (Default: 1)
  121919. */
  121920. set scaleRatio(value: number);
  121921. get scaleRatio(): number;
  121922. /**
  121923. * Disposes of the gizmo
  121924. */
  121925. dispose(): void;
  121926. /**
  121927. * CustomMeshes are not supported by this gizmo
  121928. * @param mesh The mesh to replace the default mesh of the gizmo
  121929. */
  121930. setCustomMesh(mesh: Mesh): void;
  121931. }
  121932. }
  121933. declare module BABYLON {
  121934. /**
  121935. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121936. */
  121937. export class GizmoManager implements IDisposable {
  121938. private scene;
  121939. /**
  121940. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121941. */
  121942. gizmos: {
  121943. positionGizmo: Nullable<PositionGizmo>;
  121944. rotationGizmo: Nullable<RotationGizmo>;
  121945. scaleGizmo: Nullable<ScaleGizmo>;
  121946. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121947. };
  121948. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121949. clearGizmoOnEmptyPointerEvent: boolean;
  121950. /** Fires an event when the manager is attached to a mesh */
  121951. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121952. private _gizmosEnabled;
  121953. private _pointerObserver;
  121954. private _attachedMesh;
  121955. private _boundingBoxColor;
  121956. private _defaultUtilityLayer;
  121957. private _defaultKeepDepthUtilityLayer;
  121958. /**
  121959. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121960. */
  121961. boundingBoxDragBehavior: SixDofDragBehavior;
  121962. /**
  121963. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121964. */
  121965. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121966. /**
  121967. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121968. */
  121969. usePointerToAttachGizmos: boolean;
  121970. /**
  121971. * Utility layer that the bounding box gizmo belongs to
  121972. */
  121973. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121974. /**
  121975. * Utility layer that all gizmos besides bounding box belong to
  121976. */
  121977. get utilityLayer(): UtilityLayerRenderer;
  121978. /**
  121979. * Instatiates a gizmo manager
  121980. * @param scene the scene to overlay the gizmos on top of
  121981. */
  121982. constructor(scene: Scene);
  121983. /**
  121984. * Attaches a set of gizmos to the specified mesh
  121985. * @param mesh The mesh the gizmo's should be attached to
  121986. */
  121987. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121988. /**
  121989. * If the position gizmo is enabled
  121990. */
  121991. set positionGizmoEnabled(value: boolean);
  121992. get positionGizmoEnabled(): boolean;
  121993. /**
  121994. * If the rotation gizmo is enabled
  121995. */
  121996. set rotationGizmoEnabled(value: boolean);
  121997. get rotationGizmoEnabled(): boolean;
  121998. /**
  121999. * If the scale gizmo is enabled
  122000. */
  122001. set scaleGizmoEnabled(value: boolean);
  122002. get scaleGizmoEnabled(): boolean;
  122003. /**
  122004. * If the boundingBox gizmo is enabled
  122005. */
  122006. set boundingBoxGizmoEnabled(value: boolean);
  122007. get boundingBoxGizmoEnabled(): boolean;
  122008. /**
  122009. * Disposes of the gizmo manager
  122010. */
  122011. dispose(): void;
  122012. }
  122013. }
  122014. declare module BABYLON {
  122015. /**
  122016. * A directional light is defined by a direction (what a surprise!).
  122017. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  122018. * 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.
  122019. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122020. */
  122021. export class DirectionalLight extends ShadowLight {
  122022. private _shadowFrustumSize;
  122023. /**
  122024. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122025. */
  122026. get shadowFrustumSize(): number;
  122027. /**
  122028. * Specifies a fix frustum size for the shadow generation.
  122029. */
  122030. set shadowFrustumSize(value: number);
  122031. private _shadowOrthoScale;
  122032. /**
  122033. * Gets the shadow projection scale against the optimal computed one.
  122034. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122035. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122036. */
  122037. get shadowOrthoScale(): number;
  122038. /**
  122039. * Sets the shadow projection scale against the optimal computed one.
  122040. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122041. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122042. */
  122043. set shadowOrthoScale(value: number);
  122044. /**
  122045. * Automatically compute the projection matrix to best fit (including all the casters)
  122046. * on each frame.
  122047. */
  122048. autoUpdateExtends: boolean;
  122049. /**
  122050. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122051. * on each frame. autoUpdateExtends must be set to true for this to work
  122052. */
  122053. autoCalcShadowZBounds: boolean;
  122054. private _orthoLeft;
  122055. private _orthoRight;
  122056. private _orthoTop;
  122057. private _orthoBottom;
  122058. /**
  122059. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122060. * The directional light is emitted from everywhere in the given direction.
  122061. * It can cast shadows.
  122062. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122063. * @param name The friendly name of the light
  122064. * @param direction The direction of the light
  122065. * @param scene The scene the light belongs to
  122066. */
  122067. constructor(name: string, direction: Vector3, scene: Scene);
  122068. /**
  122069. * Returns the string "DirectionalLight".
  122070. * @return The class name
  122071. */
  122072. getClassName(): string;
  122073. /**
  122074. * Returns the integer 1.
  122075. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122076. */
  122077. getTypeID(): number;
  122078. /**
  122079. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122080. * Returns the DirectionalLight Shadow projection matrix.
  122081. */
  122082. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122083. /**
  122084. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122085. * Returns the DirectionalLight Shadow projection matrix.
  122086. */
  122087. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122088. /**
  122089. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122090. * Returns the DirectionalLight Shadow projection matrix.
  122091. */
  122092. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122093. protected _buildUniformLayout(): void;
  122094. /**
  122095. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122096. * @param effect The effect to update
  122097. * @param lightIndex The index of the light in the effect to update
  122098. * @returns The directional light
  122099. */
  122100. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122101. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122102. /**
  122103. * Gets the minZ used for shadow according to both the scene and the light.
  122104. *
  122105. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122106. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122107. * @param activeCamera The camera we are returning the min for
  122108. * @returns the depth min z
  122109. */
  122110. getDepthMinZ(activeCamera: Camera): number;
  122111. /**
  122112. * Gets the maxZ used for shadow according to both the scene and the light.
  122113. *
  122114. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122115. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122116. * @param activeCamera The camera we are returning the max for
  122117. * @returns the depth max z
  122118. */
  122119. getDepthMaxZ(activeCamera: Camera): number;
  122120. /**
  122121. * Prepares the list of defines specific to the light type.
  122122. * @param defines the list of defines
  122123. * @param lightIndex defines the index of the light for the effect
  122124. */
  122125. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122126. }
  122127. }
  122128. declare module BABYLON {
  122129. /**
  122130. * Class containing static functions to help procedurally build meshes
  122131. */
  122132. export class HemisphereBuilder {
  122133. /**
  122134. * Creates a hemisphere mesh
  122135. * @param name defines the name of the mesh
  122136. * @param options defines the options used to create the mesh
  122137. * @param scene defines the hosting scene
  122138. * @returns the hemisphere mesh
  122139. */
  122140. static CreateHemisphere(name: string, options: {
  122141. segments?: number;
  122142. diameter?: number;
  122143. sideOrientation?: number;
  122144. }, scene: any): Mesh;
  122145. }
  122146. }
  122147. declare module BABYLON {
  122148. /**
  122149. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122150. * These values define a cone of light starting from the position, emitting toward the direction.
  122151. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122152. * and the exponent defines the speed of the decay of the light with distance (reach).
  122153. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122154. */
  122155. export class SpotLight extends ShadowLight {
  122156. private _angle;
  122157. private _innerAngle;
  122158. private _cosHalfAngle;
  122159. private _lightAngleScale;
  122160. private _lightAngleOffset;
  122161. /**
  122162. * Gets the cone angle of the spot light in Radians.
  122163. */
  122164. get angle(): number;
  122165. /**
  122166. * Sets the cone angle of the spot light in Radians.
  122167. */
  122168. set angle(value: number);
  122169. /**
  122170. * Only used in gltf falloff mode, this defines the angle where
  122171. * the directional falloff will start before cutting at angle which could be seen
  122172. * as outer angle.
  122173. */
  122174. get innerAngle(): number;
  122175. /**
  122176. * Only used in gltf falloff mode, this defines the angle where
  122177. * the directional falloff will start before cutting at angle which could be seen
  122178. * as outer angle.
  122179. */
  122180. set innerAngle(value: number);
  122181. private _shadowAngleScale;
  122182. /**
  122183. * Allows scaling the angle of the light for shadow generation only.
  122184. */
  122185. get shadowAngleScale(): number;
  122186. /**
  122187. * Allows scaling the angle of the light for shadow generation only.
  122188. */
  122189. set shadowAngleScale(value: number);
  122190. /**
  122191. * The light decay speed with the distance from the emission spot.
  122192. */
  122193. exponent: number;
  122194. private _projectionTextureMatrix;
  122195. /**
  122196. * Allows reading the projecton texture
  122197. */
  122198. get projectionTextureMatrix(): Matrix;
  122199. protected _projectionTextureLightNear: number;
  122200. /**
  122201. * Gets the near clip of the Spotlight for texture projection.
  122202. */
  122203. get projectionTextureLightNear(): number;
  122204. /**
  122205. * Sets the near clip of the Spotlight for texture projection.
  122206. */
  122207. set projectionTextureLightNear(value: number);
  122208. protected _projectionTextureLightFar: number;
  122209. /**
  122210. * Gets the far clip of the Spotlight for texture projection.
  122211. */
  122212. get projectionTextureLightFar(): number;
  122213. /**
  122214. * Sets the far clip of the Spotlight for texture projection.
  122215. */
  122216. set projectionTextureLightFar(value: number);
  122217. protected _projectionTextureUpDirection: Vector3;
  122218. /**
  122219. * Gets the Up vector of the Spotlight for texture projection.
  122220. */
  122221. get projectionTextureUpDirection(): Vector3;
  122222. /**
  122223. * Sets the Up vector of the Spotlight for texture projection.
  122224. */
  122225. set projectionTextureUpDirection(value: Vector3);
  122226. private _projectionTexture;
  122227. /**
  122228. * Gets the projection texture of the light.
  122229. */
  122230. get projectionTexture(): Nullable<BaseTexture>;
  122231. /**
  122232. * Sets the projection texture of the light.
  122233. */
  122234. set projectionTexture(value: Nullable<BaseTexture>);
  122235. private _projectionTextureViewLightDirty;
  122236. private _projectionTextureProjectionLightDirty;
  122237. private _projectionTextureDirty;
  122238. private _projectionTextureViewTargetVector;
  122239. private _projectionTextureViewLightMatrix;
  122240. private _projectionTextureProjectionLightMatrix;
  122241. private _projectionTextureScalingMatrix;
  122242. /**
  122243. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122244. * It can cast shadows.
  122245. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122246. * @param name The light friendly name
  122247. * @param position The position of the spot light in the scene
  122248. * @param direction The direction of the light in the scene
  122249. * @param angle The cone angle of the light in Radians
  122250. * @param exponent The light decay speed with the distance from the emission spot
  122251. * @param scene The scene the lights belongs to
  122252. */
  122253. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122254. /**
  122255. * Returns the string "SpotLight".
  122256. * @returns the class name
  122257. */
  122258. getClassName(): string;
  122259. /**
  122260. * Returns the integer 2.
  122261. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122262. */
  122263. getTypeID(): number;
  122264. /**
  122265. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122266. */
  122267. protected _setDirection(value: Vector3): void;
  122268. /**
  122269. * Overrides the position setter to recompute the projection texture view light Matrix.
  122270. */
  122271. protected _setPosition(value: Vector3): void;
  122272. /**
  122273. * 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.
  122274. * Returns the SpotLight.
  122275. */
  122276. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122277. protected _computeProjectionTextureViewLightMatrix(): void;
  122278. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122279. /**
  122280. * Main function for light texture projection matrix computing.
  122281. */
  122282. protected _computeProjectionTextureMatrix(): void;
  122283. protected _buildUniformLayout(): void;
  122284. private _computeAngleValues;
  122285. /**
  122286. * Sets the passed Effect "effect" with the Light textures.
  122287. * @param effect The effect to update
  122288. * @param lightIndex The index of the light in the effect to update
  122289. * @returns The light
  122290. */
  122291. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122292. /**
  122293. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122294. * @param effect The effect to update
  122295. * @param lightIndex The index of the light in the effect to update
  122296. * @returns The spot light
  122297. */
  122298. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122299. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122300. /**
  122301. * Disposes the light and the associated resources.
  122302. */
  122303. dispose(): void;
  122304. /**
  122305. * Prepares the list of defines specific to the light type.
  122306. * @param defines the list of defines
  122307. * @param lightIndex defines the index of the light for the effect
  122308. */
  122309. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122310. }
  122311. }
  122312. declare module BABYLON {
  122313. /**
  122314. * Gizmo that enables viewing a light
  122315. */
  122316. export class LightGizmo extends Gizmo {
  122317. private _lightMesh;
  122318. private _material;
  122319. private _cachedPosition;
  122320. private _cachedForward;
  122321. private _attachedMeshParent;
  122322. /**
  122323. * Creates a LightGizmo
  122324. * @param gizmoLayer The utility layer the gizmo will be added to
  122325. */
  122326. constructor(gizmoLayer?: UtilityLayerRenderer);
  122327. private _light;
  122328. /**
  122329. * The light that the gizmo is attached to
  122330. */
  122331. set light(light: Nullable<Light>);
  122332. get light(): Nullable<Light>;
  122333. /**
  122334. * Gets the material used to render the light gizmo
  122335. */
  122336. get material(): StandardMaterial;
  122337. /**
  122338. * @hidden
  122339. * Updates the gizmo to match the attached mesh's position/rotation
  122340. */
  122341. protected _update(): void;
  122342. private static _Scale;
  122343. /**
  122344. * Creates the lines for a light mesh
  122345. */
  122346. private static _CreateLightLines;
  122347. /**
  122348. * Disposes of the light gizmo
  122349. */
  122350. dispose(): void;
  122351. private static _CreateHemisphericLightMesh;
  122352. private static _CreatePointLightMesh;
  122353. private static _CreateSpotLightMesh;
  122354. private static _CreateDirectionalLightMesh;
  122355. }
  122356. }
  122357. declare module BABYLON {
  122358. /** @hidden */
  122359. export var backgroundFragmentDeclaration: {
  122360. name: string;
  122361. shader: string;
  122362. };
  122363. }
  122364. declare module BABYLON {
  122365. /** @hidden */
  122366. export var backgroundUboDeclaration: {
  122367. name: string;
  122368. shader: string;
  122369. };
  122370. }
  122371. declare module BABYLON {
  122372. /** @hidden */
  122373. export var backgroundPixelShader: {
  122374. name: string;
  122375. shader: string;
  122376. };
  122377. }
  122378. declare module BABYLON {
  122379. /** @hidden */
  122380. export var backgroundVertexDeclaration: {
  122381. name: string;
  122382. shader: string;
  122383. };
  122384. }
  122385. declare module BABYLON {
  122386. /** @hidden */
  122387. export var backgroundVertexShader: {
  122388. name: string;
  122389. shader: string;
  122390. };
  122391. }
  122392. declare module BABYLON {
  122393. /**
  122394. * Background material used to create an efficient environement around your scene.
  122395. */
  122396. export class BackgroundMaterial extends PushMaterial {
  122397. /**
  122398. * Standard reflectance value at parallel view angle.
  122399. */
  122400. static StandardReflectance0: number;
  122401. /**
  122402. * Standard reflectance value at grazing angle.
  122403. */
  122404. static StandardReflectance90: number;
  122405. protected _primaryColor: Color3;
  122406. /**
  122407. * Key light Color (multiply against the environement texture)
  122408. */
  122409. primaryColor: Color3;
  122410. protected __perceptualColor: Nullable<Color3>;
  122411. /**
  122412. * Experimental Internal Use Only.
  122413. *
  122414. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122415. * This acts as a helper to set the primary color to a more "human friendly" value.
  122416. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122417. * output color as close as possible from the chosen value.
  122418. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122419. * part of lighting setup.)
  122420. */
  122421. get _perceptualColor(): Nullable<Color3>;
  122422. set _perceptualColor(value: Nullable<Color3>);
  122423. protected _primaryColorShadowLevel: float;
  122424. /**
  122425. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122426. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122427. */
  122428. get primaryColorShadowLevel(): float;
  122429. set primaryColorShadowLevel(value: float);
  122430. protected _primaryColorHighlightLevel: float;
  122431. /**
  122432. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122433. * The primary color is used at the level chosen to define what the white area would look.
  122434. */
  122435. get primaryColorHighlightLevel(): float;
  122436. set primaryColorHighlightLevel(value: float);
  122437. protected _reflectionTexture: Nullable<BaseTexture>;
  122438. /**
  122439. * Reflection Texture used in the material.
  122440. * Should be author in a specific way for the best result (refer to the documentation).
  122441. */
  122442. reflectionTexture: Nullable<BaseTexture>;
  122443. protected _reflectionBlur: float;
  122444. /**
  122445. * Reflection Texture level of blur.
  122446. *
  122447. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122448. * texture twice.
  122449. */
  122450. reflectionBlur: float;
  122451. protected _diffuseTexture: Nullable<BaseTexture>;
  122452. /**
  122453. * Diffuse Texture used in the material.
  122454. * Should be author in a specific way for the best result (refer to the documentation).
  122455. */
  122456. diffuseTexture: Nullable<BaseTexture>;
  122457. protected _shadowLights: Nullable<IShadowLight[]>;
  122458. /**
  122459. * Specify the list of lights casting shadow on the material.
  122460. * All scene shadow lights will be included if null.
  122461. */
  122462. shadowLights: Nullable<IShadowLight[]>;
  122463. protected _shadowLevel: float;
  122464. /**
  122465. * Helps adjusting the shadow to a softer level if required.
  122466. * 0 means black shadows and 1 means no shadows.
  122467. */
  122468. shadowLevel: float;
  122469. protected _sceneCenter: Vector3;
  122470. /**
  122471. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122472. * It is usually zero but might be interesting to modify according to your setup.
  122473. */
  122474. sceneCenter: Vector3;
  122475. protected _opacityFresnel: boolean;
  122476. /**
  122477. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122478. * This helps ensuring a nice transition when the camera goes under the ground.
  122479. */
  122480. opacityFresnel: boolean;
  122481. protected _reflectionFresnel: boolean;
  122482. /**
  122483. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122484. * This helps adding a mirror texture on the ground.
  122485. */
  122486. reflectionFresnel: boolean;
  122487. protected _reflectionFalloffDistance: number;
  122488. /**
  122489. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122490. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122491. */
  122492. reflectionFalloffDistance: number;
  122493. protected _reflectionAmount: number;
  122494. /**
  122495. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122496. */
  122497. reflectionAmount: number;
  122498. protected _reflectionReflectance0: number;
  122499. /**
  122500. * This specifies the weight of the reflection at grazing angle.
  122501. */
  122502. reflectionReflectance0: number;
  122503. protected _reflectionReflectance90: number;
  122504. /**
  122505. * This specifies the weight of the reflection at a perpendicular point of view.
  122506. */
  122507. reflectionReflectance90: number;
  122508. /**
  122509. * Sets the reflection reflectance fresnel values according to the default standard
  122510. * empirically know to work well :-)
  122511. */
  122512. set reflectionStandardFresnelWeight(value: number);
  122513. protected _useRGBColor: boolean;
  122514. /**
  122515. * Helps to directly use the maps channels instead of their level.
  122516. */
  122517. useRGBColor: boolean;
  122518. protected _enableNoise: boolean;
  122519. /**
  122520. * This helps reducing the banding effect that could occur on the background.
  122521. */
  122522. enableNoise: boolean;
  122523. /**
  122524. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122525. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122526. * Recommended to be keep at 1.0 except for special cases.
  122527. */
  122528. get fovMultiplier(): number;
  122529. set fovMultiplier(value: number);
  122530. private _fovMultiplier;
  122531. /**
  122532. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122533. */
  122534. useEquirectangularFOV: boolean;
  122535. private _maxSimultaneousLights;
  122536. /**
  122537. * Number of Simultaneous lights allowed on the material.
  122538. */
  122539. maxSimultaneousLights: int;
  122540. /**
  122541. * Default configuration related to image processing available in the Background Material.
  122542. */
  122543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122544. /**
  122545. * Keep track of the image processing observer to allow dispose and replace.
  122546. */
  122547. private _imageProcessingObserver;
  122548. /**
  122549. * Attaches a new image processing configuration to the PBR Material.
  122550. * @param configuration (if null the scene configuration will be use)
  122551. */
  122552. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122553. /**
  122554. * Gets the image processing configuration used either in this material.
  122555. */
  122556. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122557. /**
  122558. * Sets the Default image processing configuration used either in the this material.
  122559. *
  122560. * If sets to null, the scene one is in use.
  122561. */
  122562. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122563. /**
  122564. * Gets wether the color curves effect is enabled.
  122565. */
  122566. get cameraColorCurvesEnabled(): boolean;
  122567. /**
  122568. * Sets wether the color curves effect is enabled.
  122569. */
  122570. set cameraColorCurvesEnabled(value: boolean);
  122571. /**
  122572. * Gets wether the color grading effect is enabled.
  122573. */
  122574. get cameraColorGradingEnabled(): boolean;
  122575. /**
  122576. * Gets wether the color grading effect is enabled.
  122577. */
  122578. set cameraColorGradingEnabled(value: boolean);
  122579. /**
  122580. * Gets wether tonemapping is enabled or not.
  122581. */
  122582. get cameraToneMappingEnabled(): boolean;
  122583. /**
  122584. * Sets wether tonemapping is enabled or not
  122585. */
  122586. set cameraToneMappingEnabled(value: boolean);
  122587. /**
  122588. * The camera exposure used on this material.
  122589. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122590. * This corresponds to a photographic exposure.
  122591. */
  122592. get cameraExposure(): float;
  122593. /**
  122594. * The camera exposure used on this material.
  122595. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122596. * This corresponds to a photographic exposure.
  122597. */
  122598. set cameraExposure(value: float);
  122599. /**
  122600. * Gets The camera contrast used on this material.
  122601. */
  122602. get cameraContrast(): float;
  122603. /**
  122604. * Sets The camera contrast used on this material.
  122605. */
  122606. set cameraContrast(value: float);
  122607. /**
  122608. * Gets the Color Grading 2D Lookup Texture.
  122609. */
  122610. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122611. /**
  122612. * Sets the Color Grading 2D Lookup Texture.
  122613. */
  122614. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122615. /**
  122616. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122617. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122618. * 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;
  122619. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122620. */
  122621. get cameraColorCurves(): Nullable<ColorCurves>;
  122622. /**
  122623. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122624. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122625. * 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;
  122626. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122627. */
  122628. set cameraColorCurves(value: Nullable<ColorCurves>);
  122629. /**
  122630. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122631. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122632. */
  122633. switchToBGR: boolean;
  122634. private _renderTargets;
  122635. private _reflectionControls;
  122636. private _white;
  122637. private _primaryShadowColor;
  122638. private _primaryHighlightColor;
  122639. /**
  122640. * Instantiates a Background Material in the given scene
  122641. * @param name The friendly name of the material
  122642. * @param scene The scene to add the material to
  122643. */
  122644. constructor(name: string, scene: Scene);
  122645. /**
  122646. * Gets a boolean indicating that current material needs to register RTT
  122647. */
  122648. get hasRenderTargetTextures(): boolean;
  122649. /**
  122650. * The entire material has been created in order to prevent overdraw.
  122651. * @returns false
  122652. */
  122653. needAlphaTesting(): boolean;
  122654. /**
  122655. * The entire material has been created in order to prevent overdraw.
  122656. * @returns true if blending is enable
  122657. */
  122658. needAlphaBlending(): boolean;
  122659. /**
  122660. * Checks wether the material is ready to be rendered for a given mesh.
  122661. * @param mesh The mesh to render
  122662. * @param subMesh The submesh to check against
  122663. * @param useInstances Specify wether or not the material is used with instances
  122664. * @returns true if all the dependencies are ready (Textures, Effects...)
  122665. */
  122666. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122667. /**
  122668. * Compute the primary color according to the chosen perceptual color.
  122669. */
  122670. private _computePrimaryColorFromPerceptualColor;
  122671. /**
  122672. * Compute the highlights and shadow colors according to their chosen levels.
  122673. */
  122674. private _computePrimaryColors;
  122675. /**
  122676. * Build the uniform buffer used in the material.
  122677. */
  122678. buildUniformLayout(): void;
  122679. /**
  122680. * Unbind the material.
  122681. */
  122682. unbind(): void;
  122683. /**
  122684. * Bind only the world matrix to the material.
  122685. * @param world The world matrix to bind.
  122686. */
  122687. bindOnlyWorldMatrix(world: Matrix): void;
  122688. /**
  122689. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122690. * @param world The world matrix to bind.
  122691. * @param subMesh The submesh to bind for.
  122692. */
  122693. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122694. /**
  122695. * Checks to see if a texture is used in the material.
  122696. * @param texture - Base texture to use.
  122697. * @returns - Boolean specifying if a texture is used in the material.
  122698. */
  122699. hasTexture(texture: BaseTexture): boolean;
  122700. /**
  122701. * Dispose the material.
  122702. * @param forceDisposeEffect Force disposal of the associated effect.
  122703. * @param forceDisposeTextures Force disposal of the associated textures.
  122704. */
  122705. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122706. /**
  122707. * Clones the material.
  122708. * @param name The cloned name.
  122709. * @returns The cloned material.
  122710. */
  122711. clone(name: string): BackgroundMaterial;
  122712. /**
  122713. * Serializes the current material to its JSON representation.
  122714. * @returns The JSON representation.
  122715. */
  122716. serialize(): any;
  122717. /**
  122718. * Gets the class name of the material
  122719. * @returns "BackgroundMaterial"
  122720. */
  122721. getClassName(): string;
  122722. /**
  122723. * Parse a JSON input to create back a background material.
  122724. * @param source The JSON data to parse
  122725. * @param scene The scene to create the parsed material in
  122726. * @param rootUrl The root url of the assets the material depends upon
  122727. * @returns the instantiated BackgroundMaterial.
  122728. */
  122729. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122730. }
  122731. }
  122732. declare module BABYLON {
  122733. /**
  122734. * Represents the different options available during the creation of
  122735. * a Environment helper.
  122736. *
  122737. * This can control the default ground, skybox and image processing setup of your scene.
  122738. */
  122739. export interface IEnvironmentHelperOptions {
  122740. /**
  122741. * Specifies whether or not to create a ground.
  122742. * True by default.
  122743. */
  122744. createGround: boolean;
  122745. /**
  122746. * Specifies the ground size.
  122747. * 15 by default.
  122748. */
  122749. groundSize: number;
  122750. /**
  122751. * The texture used on the ground for the main color.
  122752. * Comes from the BabylonJS CDN by default.
  122753. *
  122754. * Remarks: Can be either a texture or a url.
  122755. */
  122756. groundTexture: string | BaseTexture;
  122757. /**
  122758. * The color mixed in the ground texture by default.
  122759. * BabylonJS clearColor by default.
  122760. */
  122761. groundColor: Color3;
  122762. /**
  122763. * Specifies the ground opacity.
  122764. * 1 by default.
  122765. */
  122766. groundOpacity: number;
  122767. /**
  122768. * Enables the ground to receive shadows.
  122769. * True by default.
  122770. */
  122771. enableGroundShadow: boolean;
  122772. /**
  122773. * Helps preventing the shadow to be fully black on the ground.
  122774. * 0.5 by default.
  122775. */
  122776. groundShadowLevel: number;
  122777. /**
  122778. * Creates a mirror texture attach to the ground.
  122779. * false by default.
  122780. */
  122781. enableGroundMirror: boolean;
  122782. /**
  122783. * Specifies the ground mirror size ratio.
  122784. * 0.3 by default as the default kernel is 64.
  122785. */
  122786. groundMirrorSizeRatio: number;
  122787. /**
  122788. * Specifies the ground mirror blur kernel size.
  122789. * 64 by default.
  122790. */
  122791. groundMirrorBlurKernel: number;
  122792. /**
  122793. * Specifies the ground mirror visibility amount.
  122794. * 1 by default
  122795. */
  122796. groundMirrorAmount: number;
  122797. /**
  122798. * Specifies the ground mirror reflectance weight.
  122799. * This uses the standard weight of the background material to setup the fresnel effect
  122800. * of the mirror.
  122801. * 1 by default.
  122802. */
  122803. groundMirrorFresnelWeight: number;
  122804. /**
  122805. * Specifies the ground mirror Falloff distance.
  122806. * This can helps reducing the size of the reflection.
  122807. * 0 by Default.
  122808. */
  122809. groundMirrorFallOffDistance: number;
  122810. /**
  122811. * Specifies the ground mirror texture type.
  122812. * Unsigned Int by Default.
  122813. */
  122814. groundMirrorTextureType: number;
  122815. /**
  122816. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122817. * the shown objects.
  122818. */
  122819. groundYBias: number;
  122820. /**
  122821. * Specifies whether or not to create a skybox.
  122822. * True by default.
  122823. */
  122824. createSkybox: boolean;
  122825. /**
  122826. * Specifies the skybox size.
  122827. * 20 by default.
  122828. */
  122829. skyboxSize: number;
  122830. /**
  122831. * The texture used on the skybox for the main color.
  122832. * Comes from the BabylonJS CDN by default.
  122833. *
  122834. * Remarks: Can be either a texture or a url.
  122835. */
  122836. skyboxTexture: string | BaseTexture;
  122837. /**
  122838. * The color mixed in the skybox texture by default.
  122839. * BabylonJS clearColor by default.
  122840. */
  122841. skyboxColor: Color3;
  122842. /**
  122843. * The background rotation around the Y axis of the scene.
  122844. * This helps aligning the key lights of your scene with the background.
  122845. * 0 by default.
  122846. */
  122847. backgroundYRotation: number;
  122848. /**
  122849. * Compute automatically the size of the elements to best fit with the scene.
  122850. */
  122851. sizeAuto: boolean;
  122852. /**
  122853. * Default position of the rootMesh if autoSize is not true.
  122854. */
  122855. rootPosition: Vector3;
  122856. /**
  122857. * Sets up the image processing in the scene.
  122858. * true by default.
  122859. */
  122860. setupImageProcessing: boolean;
  122861. /**
  122862. * The texture used as your environment texture in the scene.
  122863. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122864. *
  122865. * Remarks: Can be either a texture or a url.
  122866. */
  122867. environmentTexture: string | BaseTexture;
  122868. /**
  122869. * The value of the exposure to apply to the scene.
  122870. * 0.6 by default if setupImageProcessing is true.
  122871. */
  122872. cameraExposure: number;
  122873. /**
  122874. * The value of the contrast to apply to the scene.
  122875. * 1.6 by default if setupImageProcessing is true.
  122876. */
  122877. cameraContrast: number;
  122878. /**
  122879. * Specifies whether or not tonemapping should be enabled in the scene.
  122880. * true by default if setupImageProcessing is true.
  122881. */
  122882. toneMappingEnabled: boolean;
  122883. }
  122884. /**
  122885. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122886. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122887. * It also helps with the default setup of your imageProcessing configuration.
  122888. */
  122889. export class EnvironmentHelper {
  122890. /**
  122891. * Default ground texture URL.
  122892. */
  122893. private static _groundTextureCDNUrl;
  122894. /**
  122895. * Default skybox texture URL.
  122896. */
  122897. private static _skyboxTextureCDNUrl;
  122898. /**
  122899. * Default environment texture URL.
  122900. */
  122901. private static _environmentTextureCDNUrl;
  122902. /**
  122903. * Creates the default options for the helper.
  122904. */
  122905. private static _getDefaultOptions;
  122906. private _rootMesh;
  122907. /**
  122908. * Gets the root mesh created by the helper.
  122909. */
  122910. get rootMesh(): Mesh;
  122911. private _skybox;
  122912. /**
  122913. * Gets the skybox created by the helper.
  122914. */
  122915. get skybox(): Nullable<Mesh>;
  122916. private _skyboxTexture;
  122917. /**
  122918. * Gets the skybox texture created by the helper.
  122919. */
  122920. get skyboxTexture(): Nullable<BaseTexture>;
  122921. private _skyboxMaterial;
  122922. /**
  122923. * Gets the skybox material created by the helper.
  122924. */
  122925. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122926. private _ground;
  122927. /**
  122928. * Gets the ground mesh created by the helper.
  122929. */
  122930. get ground(): Nullable<Mesh>;
  122931. private _groundTexture;
  122932. /**
  122933. * Gets the ground texture created by the helper.
  122934. */
  122935. get groundTexture(): Nullable<BaseTexture>;
  122936. private _groundMirror;
  122937. /**
  122938. * Gets the ground mirror created by the helper.
  122939. */
  122940. get groundMirror(): Nullable<MirrorTexture>;
  122941. /**
  122942. * Gets the ground mirror render list to helps pushing the meshes
  122943. * you wish in the ground reflection.
  122944. */
  122945. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122946. private _groundMaterial;
  122947. /**
  122948. * Gets the ground material created by the helper.
  122949. */
  122950. get groundMaterial(): Nullable<BackgroundMaterial>;
  122951. /**
  122952. * Stores the creation options.
  122953. */
  122954. private readonly _scene;
  122955. private _options;
  122956. /**
  122957. * This observable will be notified with any error during the creation of the environment,
  122958. * mainly texture creation errors.
  122959. */
  122960. onErrorObservable: Observable<{
  122961. message?: string;
  122962. exception?: any;
  122963. }>;
  122964. /**
  122965. * constructor
  122966. * @param options Defines the options we want to customize the helper
  122967. * @param scene The scene to add the material to
  122968. */
  122969. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122970. /**
  122971. * Updates the background according to the new options
  122972. * @param options
  122973. */
  122974. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122975. /**
  122976. * Sets the primary color of all the available elements.
  122977. * @param color the main color to affect to the ground and the background
  122978. */
  122979. setMainColor(color: Color3): void;
  122980. /**
  122981. * Setup the image processing according to the specified options.
  122982. */
  122983. private _setupImageProcessing;
  122984. /**
  122985. * Setup the environment texture according to the specified options.
  122986. */
  122987. private _setupEnvironmentTexture;
  122988. /**
  122989. * Setup the background according to the specified options.
  122990. */
  122991. private _setupBackground;
  122992. /**
  122993. * Get the scene sizes according to the setup.
  122994. */
  122995. private _getSceneSize;
  122996. /**
  122997. * Setup the ground according to the specified options.
  122998. */
  122999. private _setupGround;
  123000. /**
  123001. * Setup the ground material according to the specified options.
  123002. */
  123003. private _setupGroundMaterial;
  123004. /**
  123005. * Setup the ground diffuse texture according to the specified options.
  123006. */
  123007. private _setupGroundDiffuseTexture;
  123008. /**
  123009. * Setup the ground mirror texture according to the specified options.
  123010. */
  123011. private _setupGroundMirrorTexture;
  123012. /**
  123013. * Setup the ground to receive the mirror texture.
  123014. */
  123015. private _setupMirrorInGroundMaterial;
  123016. /**
  123017. * Setup the skybox according to the specified options.
  123018. */
  123019. private _setupSkybox;
  123020. /**
  123021. * Setup the skybox material according to the specified options.
  123022. */
  123023. private _setupSkyboxMaterial;
  123024. /**
  123025. * Setup the skybox reflection texture according to the specified options.
  123026. */
  123027. private _setupSkyboxReflectionTexture;
  123028. private _errorHandler;
  123029. /**
  123030. * Dispose all the elements created by the Helper.
  123031. */
  123032. dispose(): void;
  123033. }
  123034. }
  123035. declare module BABYLON {
  123036. /**
  123037. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123038. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123039. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123040. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123041. */
  123042. export class PhotoDome extends TransformNode {
  123043. /**
  123044. * Define the image as a Monoscopic panoramic 360 image.
  123045. */
  123046. static readonly MODE_MONOSCOPIC: number;
  123047. /**
  123048. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123049. */
  123050. static readonly MODE_TOPBOTTOM: number;
  123051. /**
  123052. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123053. */
  123054. static readonly MODE_SIDEBYSIDE: number;
  123055. private _useDirectMapping;
  123056. /**
  123057. * The texture being displayed on the sphere
  123058. */
  123059. protected _photoTexture: Texture;
  123060. /**
  123061. * Gets or sets the texture being displayed on the sphere
  123062. */
  123063. get photoTexture(): Texture;
  123064. set photoTexture(value: Texture);
  123065. /**
  123066. * Observable raised when an error occured while loading the 360 image
  123067. */
  123068. onLoadErrorObservable: Observable<string>;
  123069. /**
  123070. * The skybox material
  123071. */
  123072. protected _material: BackgroundMaterial;
  123073. /**
  123074. * The surface used for the skybox
  123075. */
  123076. protected _mesh: Mesh;
  123077. /**
  123078. * Gets the mesh used for the skybox.
  123079. */
  123080. get mesh(): Mesh;
  123081. /**
  123082. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123083. * Also see the options.resolution property.
  123084. */
  123085. get fovMultiplier(): number;
  123086. set fovMultiplier(value: number);
  123087. private _imageMode;
  123088. /**
  123089. * Gets or set the current video mode for the video. It can be:
  123090. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123091. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123092. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123093. */
  123094. get imageMode(): number;
  123095. set imageMode(value: number);
  123096. /**
  123097. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123098. * @param name Element's name, child elements will append suffixes for their own names.
  123099. * @param urlsOfPhoto defines the url of the photo to display
  123100. * @param options defines an object containing optional or exposed sub element properties
  123101. * @param onError defines a callback called when an error occured while loading the texture
  123102. */
  123103. constructor(name: string, urlOfPhoto: string, options: {
  123104. resolution?: number;
  123105. size?: number;
  123106. useDirectMapping?: boolean;
  123107. faceForward?: boolean;
  123108. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123109. private _onBeforeCameraRenderObserver;
  123110. private _changeImageMode;
  123111. /**
  123112. * Releases resources associated with this node.
  123113. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123114. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123115. */
  123116. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123117. }
  123118. }
  123119. declare module BABYLON {
  123120. /**
  123121. * Class used to host RGBD texture specific utilities
  123122. */
  123123. export class RGBDTextureTools {
  123124. /**
  123125. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123126. * @param texture the texture to expand.
  123127. */
  123128. static ExpandRGBDTexture(texture: Texture): void;
  123129. }
  123130. }
  123131. declare module BABYLON {
  123132. /**
  123133. * Class used to host texture specific utilities
  123134. */
  123135. export class BRDFTextureTools {
  123136. /**
  123137. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123138. * @param scene defines the hosting scene
  123139. * @returns the environment BRDF texture
  123140. */
  123141. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123142. private static _environmentBRDFBase64Texture;
  123143. }
  123144. }
  123145. declare module BABYLON {
  123146. /**
  123147. * @hidden
  123148. */
  123149. export interface IMaterialClearCoatDefines {
  123150. CLEARCOAT: boolean;
  123151. CLEARCOAT_DEFAULTIOR: boolean;
  123152. CLEARCOAT_TEXTURE: boolean;
  123153. CLEARCOAT_TEXTUREDIRECTUV: number;
  123154. CLEARCOAT_BUMP: boolean;
  123155. CLEARCOAT_BUMPDIRECTUV: number;
  123156. CLEARCOAT_TINT: boolean;
  123157. CLEARCOAT_TINT_TEXTURE: boolean;
  123158. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123159. /** @hidden */
  123160. _areTexturesDirty: boolean;
  123161. }
  123162. /**
  123163. * Define the code related to the clear coat parameters of the pbr material.
  123164. */
  123165. export class PBRClearCoatConfiguration {
  123166. /**
  123167. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123168. * The default fits with a polyurethane material.
  123169. */
  123170. private static readonly _DefaultIndexOfRefraction;
  123171. private _isEnabled;
  123172. /**
  123173. * Defines if the clear coat is enabled in the material.
  123174. */
  123175. isEnabled: boolean;
  123176. /**
  123177. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123178. */
  123179. intensity: number;
  123180. /**
  123181. * Defines the clear coat layer roughness.
  123182. */
  123183. roughness: number;
  123184. private _indexOfRefraction;
  123185. /**
  123186. * Defines the index of refraction of the clear coat.
  123187. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123188. * The default fits with a polyurethane material.
  123189. * Changing the default value is more performance intensive.
  123190. */
  123191. indexOfRefraction: number;
  123192. private _texture;
  123193. /**
  123194. * Stores the clear coat values in a texture.
  123195. */
  123196. texture: Nullable<BaseTexture>;
  123197. private _bumpTexture;
  123198. /**
  123199. * Define the clear coat specific bump texture.
  123200. */
  123201. bumpTexture: Nullable<BaseTexture>;
  123202. private _isTintEnabled;
  123203. /**
  123204. * Defines if the clear coat tint is enabled in the material.
  123205. */
  123206. isTintEnabled: boolean;
  123207. /**
  123208. * Defines the clear coat tint of the material.
  123209. * This is only use if tint is enabled
  123210. */
  123211. tintColor: Color3;
  123212. /**
  123213. * Defines the distance at which the tint color should be found in the
  123214. * clear coat media.
  123215. * This is only use if tint is enabled
  123216. */
  123217. tintColorAtDistance: number;
  123218. /**
  123219. * Defines the clear coat layer thickness.
  123220. * This is only use if tint is enabled
  123221. */
  123222. tintThickness: number;
  123223. private _tintTexture;
  123224. /**
  123225. * Stores the clear tint values in a texture.
  123226. * rgb is tint
  123227. * a is a thickness factor
  123228. */
  123229. tintTexture: Nullable<BaseTexture>;
  123230. /** @hidden */
  123231. private _internalMarkAllSubMeshesAsTexturesDirty;
  123232. /** @hidden */
  123233. _markAllSubMeshesAsTexturesDirty(): void;
  123234. /**
  123235. * Instantiate a new istance of clear coat configuration.
  123236. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123237. */
  123238. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123239. /**
  123240. * Gets wehter the submesh is ready to be used or not.
  123241. * @param defines the list of "defines" to update.
  123242. * @param scene defines the scene the material belongs to.
  123243. * @param engine defines the engine the material belongs to.
  123244. * @param disableBumpMap defines wether the material disables bump or not.
  123245. * @returns - boolean indicating that the submesh is ready or not.
  123246. */
  123247. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123248. /**
  123249. * Checks to see if a texture is used in the material.
  123250. * @param defines the list of "defines" to update.
  123251. * @param scene defines the scene to the material belongs to.
  123252. */
  123253. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123254. /**
  123255. * Binds the material data.
  123256. * @param uniformBuffer defines the Uniform buffer to fill in.
  123257. * @param scene defines the scene the material belongs to.
  123258. * @param engine defines the engine the material belongs to.
  123259. * @param disableBumpMap defines wether the material disables bump or not.
  123260. * @param isFrozen defines wether the material is frozen or not.
  123261. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123262. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123263. */
  123264. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123265. /**
  123266. * Checks to see if a texture is used in the material.
  123267. * @param texture - Base texture to use.
  123268. * @returns - Boolean specifying if a texture is used in the material.
  123269. */
  123270. hasTexture(texture: BaseTexture): boolean;
  123271. /**
  123272. * Returns an array of the actively used textures.
  123273. * @param activeTextures Array of BaseTextures
  123274. */
  123275. getActiveTextures(activeTextures: BaseTexture[]): void;
  123276. /**
  123277. * Returns the animatable textures.
  123278. * @param animatables Array of animatable textures.
  123279. */
  123280. getAnimatables(animatables: IAnimatable[]): void;
  123281. /**
  123282. * Disposes the resources of the material.
  123283. * @param forceDisposeTextures - Forces the disposal of all textures.
  123284. */
  123285. dispose(forceDisposeTextures?: boolean): void;
  123286. /**
  123287. * Get the current class name of the texture useful for serialization or dynamic coding.
  123288. * @returns "PBRClearCoatConfiguration"
  123289. */
  123290. getClassName(): string;
  123291. /**
  123292. * Add fallbacks to the effect fallbacks list.
  123293. * @param defines defines the Base texture to use.
  123294. * @param fallbacks defines the current fallback list.
  123295. * @param currentRank defines the current fallback rank.
  123296. * @returns the new fallback rank.
  123297. */
  123298. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123299. /**
  123300. * Add the required uniforms to the current list.
  123301. * @param uniforms defines the current uniform list.
  123302. */
  123303. static AddUniforms(uniforms: string[]): void;
  123304. /**
  123305. * Add the required samplers to the current list.
  123306. * @param samplers defines the current sampler list.
  123307. */
  123308. static AddSamplers(samplers: string[]): void;
  123309. /**
  123310. * Add the required uniforms to the current buffer.
  123311. * @param uniformBuffer defines the current uniform buffer.
  123312. */
  123313. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123314. /**
  123315. * Makes a duplicate of the current configuration into another one.
  123316. * @param clearCoatConfiguration define the config where to copy the info
  123317. */
  123318. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123319. /**
  123320. * Serializes this clear coat configuration.
  123321. * @returns - An object with the serialized config.
  123322. */
  123323. serialize(): any;
  123324. /**
  123325. * Parses a anisotropy Configuration from a serialized object.
  123326. * @param source - Serialized object.
  123327. * @param scene Defines the scene we are parsing for
  123328. * @param rootUrl Defines the rootUrl to load from
  123329. */
  123330. parse(source: any, scene: Scene, rootUrl: string): void;
  123331. }
  123332. }
  123333. declare module BABYLON {
  123334. /**
  123335. * @hidden
  123336. */
  123337. export interface IMaterialAnisotropicDefines {
  123338. ANISOTROPIC: boolean;
  123339. ANISOTROPIC_TEXTURE: boolean;
  123340. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123341. MAINUV1: boolean;
  123342. _areTexturesDirty: boolean;
  123343. _needUVs: boolean;
  123344. }
  123345. /**
  123346. * Define the code related to the anisotropic parameters of the pbr material.
  123347. */
  123348. export class PBRAnisotropicConfiguration {
  123349. private _isEnabled;
  123350. /**
  123351. * Defines if the anisotropy is enabled in the material.
  123352. */
  123353. isEnabled: boolean;
  123354. /**
  123355. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123356. */
  123357. intensity: number;
  123358. /**
  123359. * Defines if the effect is along the tangents, bitangents or in between.
  123360. * By default, the effect is "strectching" the highlights along the tangents.
  123361. */
  123362. direction: Vector2;
  123363. private _texture;
  123364. /**
  123365. * Stores the anisotropy values in a texture.
  123366. * rg is direction (like normal from -1 to 1)
  123367. * b is a intensity
  123368. */
  123369. texture: Nullable<BaseTexture>;
  123370. /** @hidden */
  123371. private _internalMarkAllSubMeshesAsTexturesDirty;
  123372. /** @hidden */
  123373. _markAllSubMeshesAsTexturesDirty(): void;
  123374. /**
  123375. * Instantiate a new istance of anisotropy configuration.
  123376. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123377. */
  123378. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123379. /**
  123380. * Specifies that the submesh is ready to be used.
  123381. * @param defines the list of "defines" to update.
  123382. * @param scene defines the scene the material belongs to.
  123383. * @returns - boolean indicating that the submesh is ready or not.
  123384. */
  123385. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123386. /**
  123387. * Checks to see if a texture is used in the material.
  123388. * @param defines the list of "defines" to update.
  123389. * @param mesh the mesh we are preparing the defines for.
  123390. * @param scene defines the scene the material belongs to.
  123391. */
  123392. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123393. /**
  123394. * Binds the material data.
  123395. * @param uniformBuffer defines the Uniform buffer to fill in.
  123396. * @param scene defines the scene the material belongs to.
  123397. * @param isFrozen defines wether the material is frozen or not.
  123398. */
  123399. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123400. /**
  123401. * Checks to see if a texture is used in the material.
  123402. * @param texture - Base texture to use.
  123403. * @returns - Boolean specifying if a texture is used in the material.
  123404. */
  123405. hasTexture(texture: BaseTexture): boolean;
  123406. /**
  123407. * Returns an array of the actively used textures.
  123408. * @param activeTextures Array of BaseTextures
  123409. */
  123410. getActiveTextures(activeTextures: BaseTexture[]): void;
  123411. /**
  123412. * Returns the animatable textures.
  123413. * @param animatables Array of animatable textures.
  123414. */
  123415. getAnimatables(animatables: IAnimatable[]): void;
  123416. /**
  123417. * Disposes the resources of the material.
  123418. * @param forceDisposeTextures - Forces the disposal of all textures.
  123419. */
  123420. dispose(forceDisposeTextures?: boolean): void;
  123421. /**
  123422. * Get the current class name of the texture useful for serialization or dynamic coding.
  123423. * @returns "PBRAnisotropicConfiguration"
  123424. */
  123425. getClassName(): string;
  123426. /**
  123427. * Add fallbacks to the effect fallbacks list.
  123428. * @param defines defines the Base texture to use.
  123429. * @param fallbacks defines the current fallback list.
  123430. * @param currentRank defines the current fallback rank.
  123431. * @returns the new fallback rank.
  123432. */
  123433. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123434. /**
  123435. * Add the required uniforms to the current list.
  123436. * @param uniforms defines the current uniform list.
  123437. */
  123438. static AddUniforms(uniforms: string[]): void;
  123439. /**
  123440. * Add the required uniforms to the current buffer.
  123441. * @param uniformBuffer defines the current uniform buffer.
  123442. */
  123443. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123444. /**
  123445. * Add the required samplers to the current list.
  123446. * @param samplers defines the current sampler list.
  123447. */
  123448. static AddSamplers(samplers: string[]): void;
  123449. /**
  123450. * Makes a duplicate of the current configuration into another one.
  123451. * @param anisotropicConfiguration define the config where to copy the info
  123452. */
  123453. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123454. /**
  123455. * Serializes this anisotropy configuration.
  123456. * @returns - An object with the serialized config.
  123457. */
  123458. serialize(): any;
  123459. /**
  123460. * Parses a anisotropy Configuration from a serialized object.
  123461. * @param source - Serialized object.
  123462. * @param scene Defines the scene we are parsing for
  123463. * @param rootUrl Defines the rootUrl to load from
  123464. */
  123465. parse(source: any, scene: Scene, rootUrl: string): void;
  123466. }
  123467. }
  123468. declare module BABYLON {
  123469. /**
  123470. * @hidden
  123471. */
  123472. export interface IMaterialBRDFDefines {
  123473. BRDF_V_HEIGHT_CORRELATED: boolean;
  123474. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123475. SPHERICAL_HARMONICS: boolean;
  123476. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123477. /** @hidden */
  123478. _areMiscDirty: boolean;
  123479. }
  123480. /**
  123481. * Define the code related to the BRDF parameters of the pbr material.
  123482. */
  123483. export class PBRBRDFConfiguration {
  123484. /**
  123485. * Default value used for the energy conservation.
  123486. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123487. */
  123488. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123489. /**
  123490. * Default value used for the Smith Visibility Height Correlated mode.
  123491. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123492. */
  123493. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123494. /**
  123495. * Default value used for the IBL diffuse part.
  123496. * This can help switching back to the polynomials mode globally which is a tiny bit
  123497. * less GPU intensive at the drawback of a lower quality.
  123498. */
  123499. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123500. /**
  123501. * Default value used for activating energy conservation for the specular workflow.
  123502. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123503. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123504. */
  123505. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123506. private _useEnergyConservation;
  123507. /**
  123508. * Defines if the material uses energy conservation.
  123509. */
  123510. useEnergyConservation: boolean;
  123511. private _useSmithVisibilityHeightCorrelated;
  123512. /**
  123513. * LEGACY Mode set to false
  123514. * Defines if the material uses height smith correlated visibility term.
  123515. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123516. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123517. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123518. * Not relying on height correlated will also disable energy conservation.
  123519. */
  123520. useSmithVisibilityHeightCorrelated: boolean;
  123521. private _useSphericalHarmonics;
  123522. /**
  123523. * LEGACY Mode set to false
  123524. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123525. * diffuse part of the IBL.
  123526. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123527. * to the ground truth.
  123528. */
  123529. useSphericalHarmonics: boolean;
  123530. private _useSpecularGlossinessInputEnergyConservation;
  123531. /**
  123532. * Defines if the material uses energy conservation, when the specular workflow is active.
  123533. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123534. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123535. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123536. */
  123537. useSpecularGlossinessInputEnergyConservation: boolean;
  123538. /** @hidden */
  123539. private _internalMarkAllSubMeshesAsMiscDirty;
  123540. /** @hidden */
  123541. _markAllSubMeshesAsMiscDirty(): void;
  123542. /**
  123543. * Instantiate a new istance of clear coat configuration.
  123544. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123545. */
  123546. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123547. /**
  123548. * Checks to see if a texture is used in the material.
  123549. * @param defines the list of "defines" to update.
  123550. */
  123551. prepareDefines(defines: IMaterialBRDFDefines): void;
  123552. /**
  123553. * Get the current class name of the texture useful for serialization or dynamic coding.
  123554. * @returns "PBRClearCoatConfiguration"
  123555. */
  123556. getClassName(): string;
  123557. /**
  123558. * Makes a duplicate of the current configuration into another one.
  123559. * @param brdfConfiguration define the config where to copy the info
  123560. */
  123561. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123562. /**
  123563. * Serializes this BRDF configuration.
  123564. * @returns - An object with the serialized config.
  123565. */
  123566. serialize(): any;
  123567. /**
  123568. * Parses a anisotropy Configuration from a serialized object.
  123569. * @param source - Serialized object.
  123570. * @param scene Defines the scene we are parsing for
  123571. * @param rootUrl Defines the rootUrl to load from
  123572. */
  123573. parse(source: any, scene: Scene, rootUrl: string): void;
  123574. }
  123575. }
  123576. declare module BABYLON {
  123577. /**
  123578. * @hidden
  123579. */
  123580. export interface IMaterialSheenDefines {
  123581. SHEEN: boolean;
  123582. SHEEN_TEXTURE: boolean;
  123583. SHEEN_TEXTUREDIRECTUV: number;
  123584. SHEEN_LINKWITHALBEDO: boolean;
  123585. /** @hidden */
  123586. _areTexturesDirty: boolean;
  123587. }
  123588. /**
  123589. * Define the code related to the Sheen parameters of the pbr material.
  123590. */
  123591. export class PBRSheenConfiguration {
  123592. private _isEnabled;
  123593. /**
  123594. * Defines if the material uses sheen.
  123595. */
  123596. isEnabled: boolean;
  123597. private _linkSheenWithAlbedo;
  123598. /**
  123599. * Defines if the sheen is linked to the sheen color.
  123600. */
  123601. linkSheenWithAlbedo: boolean;
  123602. /**
  123603. * Defines the sheen intensity.
  123604. */
  123605. intensity: number;
  123606. /**
  123607. * Defines the sheen color.
  123608. */
  123609. color: Color3;
  123610. private _texture;
  123611. /**
  123612. * Stores the sheen tint values in a texture.
  123613. * rgb is tint
  123614. * a is a intensity
  123615. */
  123616. texture: Nullable<BaseTexture>;
  123617. /** @hidden */
  123618. private _internalMarkAllSubMeshesAsTexturesDirty;
  123619. /** @hidden */
  123620. _markAllSubMeshesAsTexturesDirty(): void;
  123621. /**
  123622. * Instantiate a new istance of clear coat configuration.
  123623. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123624. */
  123625. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123626. /**
  123627. * Specifies that the submesh is ready to be used.
  123628. * @param defines the list of "defines" to update.
  123629. * @param scene defines the scene the material belongs to.
  123630. * @returns - boolean indicating that the submesh is ready or not.
  123631. */
  123632. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123633. /**
  123634. * Checks to see if a texture is used in the material.
  123635. * @param defines the list of "defines" to update.
  123636. * @param scene defines the scene the material belongs to.
  123637. */
  123638. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123639. /**
  123640. * Binds the material data.
  123641. * @param uniformBuffer defines the Uniform buffer to fill in.
  123642. * @param scene defines the scene the material belongs to.
  123643. * @param isFrozen defines wether the material is frozen or not.
  123644. */
  123645. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123646. /**
  123647. * Checks to see if a texture is used in the material.
  123648. * @param texture - Base texture to use.
  123649. * @returns - Boolean specifying if a texture is used in the material.
  123650. */
  123651. hasTexture(texture: BaseTexture): boolean;
  123652. /**
  123653. * Returns an array of the actively used textures.
  123654. * @param activeTextures Array of BaseTextures
  123655. */
  123656. getActiveTextures(activeTextures: BaseTexture[]): void;
  123657. /**
  123658. * Returns the animatable textures.
  123659. * @param animatables Array of animatable textures.
  123660. */
  123661. getAnimatables(animatables: IAnimatable[]): void;
  123662. /**
  123663. * Disposes the resources of the material.
  123664. * @param forceDisposeTextures - Forces the disposal of all textures.
  123665. */
  123666. dispose(forceDisposeTextures?: boolean): void;
  123667. /**
  123668. * Get the current class name of the texture useful for serialization or dynamic coding.
  123669. * @returns "PBRSheenConfiguration"
  123670. */
  123671. getClassName(): string;
  123672. /**
  123673. * Add fallbacks to the effect fallbacks list.
  123674. * @param defines defines the Base texture to use.
  123675. * @param fallbacks defines the current fallback list.
  123676. * @param currentRank defines the current fallback rank.
  123677. * @returns the new fallback rank.
  123678. */
  123679. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123680. /**
  123681. * Add the required uniforms to the current list.
  123682. * @param uniforms defines the current uniform list.
  123683. */
  123684. static AddUniforms(uniforms: string[]): void;
  123685. /**
  123686. * Add the required uniforms to the current buffer.
  123687. * @param uniformBuffer defines the current uniform buffer.
  123688. */
  123689. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123690. /**
  123691. * Add the required samplers to the current list.
  123692. * @param samplers defines the current sampler list.
  123693. */
  123694. static AddSamplers(samplers: string[]): void;
  123695. /**
  123696. * Makes a duplicate of the current configuration into another one.
  123697. * @param sheenConfiguration define the config where to copy the info
  123698. */
  123699. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123700. /**
  123701. * Serializes this BRDF configuration.
  123702. * @returns - An object with the serialized config.
  123703. */
  123704. serialize(): any;
  123705. /**
  123706. * Parses a anisotropy Configuration from a serialized object.
  123707. * @param source - Serialized object.
  123708. * @param scene Defines the scene we are parsing for
  123709. * @param rootUrl Defines the rootUrl to load from
  123710. */
  123711. parse(source: any, scene: Scene, rootUrl: string): void;
  123712. }
  123713. }
  123714. declare module BABYLON {
  123715. /**
  123716. * @hidden
  123717. */
  123718. export interface IMaterialSubSurfaceDefines {
  123719. SUBSURFACE: boolean;
  123720. SS_REFRACTION: boolean;
  123721. SS_TRANSLUCENCY: boolean;
  123722. SS_SCATERRING: boolean;
  123723. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123724. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123725. SS_REFRACTIONMAP_3D: boolean;
  123726. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123727. SS_LODINREFRACTIONALPHA: boolean;
  123728. SS_GAMMAREFRACTION: boolean;
  123729. SS_RGBDREFRACTION: boolean;
  123730. SS_LINEARSPECULARREFRACTION: boolean;
  123731. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123732. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123733. /** @hidden */
  123734. _areTexturesDirty: boolean;
  123735. }
  123736. /**
  123737. * Define the code related to the sub surface parameters of the pbr material.
  123738. */
  123739. export class PBRSubSurfaceConfiguration {
  123740. private _isRefractionEnabled;
  123741. /**
  123742. * Defines if the refraction is enabled in the material.
  123743. */
  123744. isRefractionEnabled: boolean;
  123745. private _isTranslucencyEnabled;
  123746. /**
  123747. * Defines if the translucency is enabled in the material.
  123748. */
  123749. isTranslucencyEnabled: boolean;
  123750. private _isScatteringEnabled;
  123751. /**
  123752. * Defines the refraction intensity of the material.
  123753. * The refraction when enabled replaces the Diffuse part of the material.
  123754. * The intensity helps transitionning between diffuse and refraction.
  123755. */
  123756. refractionIntensity: number;
  123757. /**
  123758. * Defines the translucency intensity of the material.
  123759. * When translucency has been enabled, this defines how much of the "translucency"
  123760. * is addded to the diffuse part of the material.
  123761. */
  123762. translucencyIntensity: number;
  123763. /**
  123764. * Defines the scattering intensity of the material.
  123765. * When scattering has been enabled, this defines how much of the "scattered light"
  123766. * is addded to the diffuse part of the material.
  123767. */
  123768. scatteringIntensity: number;
  123769. private _thicknessTexture;
  123770. /**
  123771. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123772. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123773. * 0 would mean minimumThickness
  123774. * 1 would mean maximumThickness
  123775. * The other channels might be use as a mask to vary the different effects intensity.
  123776. */
  123777. thicknessTexture: Nullable<BaseTexture>;
  123778. private _refractionTexture;
  123779. /**
  123780. * Defines the texture to use for refraction.
  123781. */
  123782. refractionTexture: Nullable<BaseTexture>;
  123783. private _indexOfRefraction;
  123784. /**
  123785. * Defines the index of refraction used in the material.
  123786. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123787. */
  123788. indexOfRefraction: number;
  123789. private _invertRefractionY;
  123790. /**
  123791. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123792. */
  123793. invertRefractionY: boolean;
  123794. private _linkRefractionWithTransparency;
  123795. /**
  123796. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123797. * Materials half opaque for instance using refraction could benefit from this control.
  123798. */
  123799. linkRefractionWithTransparency: boolean;
  123800. /**
  123801. * Defines the minimum thickness stored in the thickness map.
  123802. * If no thickness map is defined, this value will be used to simulate thickness.
  123803. */
  123804. minimumThickness: number;
  123805. /**
  123806. * Defines the maximum thickness stored in the thickness map.
  123807. */
  123808. maximumThickness: number;
  123809. /**
  123810. * Defines the volume tint of the material.
  123811. * This is used for both translucency and scattering.
  123812. */
  123813. tintColor: Color3;
  123814. /**
  123815. * Defines the distance at which the tint color should be found in the media.
  123816. * This is used for refraction only.
  123817. */
  123818. tintColorAtDistance: number;
  123819. /**
  123820. * Defines how far each channel transmit through the media.
  123821. * It is defined as a color to simplify it selection.
  123822. */
  123823. diffusionDistance: Color3;
  123824. private _useMaskFromThicknessTexture;
  123825. /**
  123826. * Stores the intensity of the different subsurface effects in the thickness texture.
  123827. * * the green channel is the translucency intensity.
  123828. * * the blue channel is the scattering intensity.
  123829. * * the alpha channel is the refraction intensity.
  123830. */
  123831. useMaskFromThicknessTexture: boolean;
  123832. /** @hidden */
  123833. private _internalMarkAllSubMeshesAsTexturesDirty;
  123834. /** @hidden */
  123835. _markAllSubMeshesAsTexturesDirty(): void;
  123836. /**
  123837. * Instantiate a new istance of sub surface configuration.
  123838. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123839. */
  123840. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123841. /**
  123842. * Gets wehter the submesh is ready to be used or not.
  123843. * @param defines the list of "defines" to update.
  123844. * @param scene defines the scene the material belongs to.
  123845. * @returns - boolean indicating that the submesh is ready or not.
  123846. */
  123847. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123848. /**
  123849. * Checks to see if a texture is used in the material.
  123850. * @param defines the list of "defines" to update.
  123851. * @param scene defines the scene to the material belongs to.
  123852. */
  123853. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123854. /**
  123855. * Binds the material data.
  123856. * @param uniformBuffer defines the Uniform buffer to fill in.
  123857. * @param scene defines the scene the material belongs to.
  123858. * @param engine defines the engine the material belongs to.
  123859. * @param isFrozen defines wether the material is frozen or not.
  123860. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123861. */
  123862. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123863. /**
  123864. * Unbinds the material from the mesh.
  123865. * @param activeEffect defines the effect that should be unbound from.
  123866. * @returns true if unbound, otherwise false
  123867. */
  123868. unbind(activeEffect: Effect): boolean;
  123869. /**
  123870. * Returns the texture used for refraction or null if none is used.
  123871. * @param scene defines the scene the material belongs to.
  123872. * @returns - Refraction texture if present. If no refraction texture and refraction
  123873. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123874. */
  123875. private _getRefractionTexture;
  123876. /**
  123877. * Returns true if alpha blending should be disabled.
  123878. */
  123879. get disableAlphaBlending(): boolean;
  123880. /**
  123881. * Fills the list of render target textures.
  123882. * @param renderTargets the list of render targets to update
  123883. */
  123884. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123885. /**
  123886. * Checks to see if a texture is used in the material.
  123887. * @param texture - Base texture to use.
  123888. * @returns - Boolean specifying if a texture is used in the material.
  123889. */
  123890. hasTexture(texture: BaseTexture): boolean;
  123891. /**
  123892. * Gets a boolean indicating that current material needs to register RTT
  123893. * @returns true if this uses a render target otherwise false.
  123894. */
  123895. hasRenderTargetTextures(): boolean;
  123896. /**
  123897. * Returns an array of the actively used textures.
  123898. * @param activeTextures Array of BaseTextures
  123899. */
  123900. getActiveTextures(activeTextures: BaseTexture[]): void;
  123901. /**
  123902. * Returns the animatable textures.
  123903. * @param animatables Array of animatable textures.
  123904. */
  123905. getAnimatables(animatables: IAnimatable[]): void;
  123906. /**
  123907. * Disposes the resources of the material.
  123908. * @param forceDisposeTextures - Forces the disposal of all textures.
  123909. */
  123910. dispose(forceDisposeTextures?: boolean): void;
  123911. /**
  123912. * Get the current class name of the texture useful for serialization or dynamic coding.
  123913. * @returns "PBRSubSurfaceConfiguration"
  123914. */
  123915. getClassName(): string;
  123916. /**
  123917. * Add fallbacks to the effect fallbacks list.
  123918. * @param defines defines the Base texture to use.
  123919. * @param fallbacks defines the current fallback list.
  123920. * @param currentRank defines the current fallback rank.
  123921. * @returns the new fallback rank.
  123922. */
  123923. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123924. /**
  123925. * Add the required uniforms to the current list.
  123926. * @param uniforms defines the current uniform list.
  123927. */
  123928. static AddUniforms(uniforms: string[]): void;
  123929. /**
  123930. * Add the required samplers to the current list.
  123931. * @param samplers defines the current sampler list.
  123932. */
  123933. static AddSamplers(samplers: string[]): void;
  123934. /**
  123935. * Add the required uniforms to the current buffer.
  123936. * @param uniformBuffer defines the current uniform buffer.
  123937. */
  123938. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123939. /**
  123940. * Makes a duplicate of the current configuration into another one.
  123941. * @param configuration define the config where to copy the info
  123942. */
  123943. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123944. /**
  123945. * Serializes this Sub Surface configuration.
  123946. * @returns - An object with the serialized config.
  123947. */
  123948. serialize(): any;
  123949. /**
  123950. * Parses a anisotropy Configuration from a serialized object.
  123951. * @param source - Serialized object.
  123952. * @param scene Defines the scene we are parsing for
  123953. * @param rootUrl Defines the rootUrl to load from
  123954. */
  123955. parse(source: any, scene: Scene, rootUrl: string): void;
  123956. }
  123957. }
  123958. declare module BABYLON {
  123959. /** @hidden */
  123960. export var pbrFragmentDeclaration: {
  123961. name: string;
  123962. shader: string;
  123963. };
  123964. }
  123965. declare module BABYLON {
  123966. /** @hidden */
  123967. export var pbrUboDeclaration: {
  123968. name: string;
  123969. shader: string;
  123970. };
  123971. }
  123972. declare module BABYLON {
  123973. /** @hidden */
  123974. export var pbrFragmentExtraDeclaration: {
  123975. name: string;
  123976. shader: string;
  123977. };
  123978. }
  123979. declare module BABYLON {
  123980. /** @hidden */
  123981. export var pbrFragmentSamplersDeclaration: {
  123982. name: string;
  123983. shader: string;
  123984. };
  123985. }
  123986. declare module BABYLON {
  123987. /** @hidden */
  123988. export var pbrHelperFunctions: {
  123989. name: string;
  123990. shader: string;
  123991. };
  123992. }
  123993. declare module BABYLON {
  123994. /** @hidden */
  123995. export var harmonicsFunctions: {
  123996. name: string;
  123997. shader: string;
  123998. };
  123999. }
  124000. declare module BABYLON {
  124001. /** @hidden */
  124002. export var pbrDirectLightingSetupFunctions: {
  124003. name: string;
  124004. shader: string;
  124005. };
  124006. }
  124007. declare module BABYLON {
  124008. /** @hidden */
  124009. export var pbrDirectLightingFalloffFunctions: {
  124010. name: string;
  124011. shader: string;
  124012. };
  124013. }
  124014. declare module BABYLON {
  124015. /** @hidden */
  124016. export var pbrBRDFFunctions: {
  124017. name: string;
  124018. shader: string;
  124019. };
  124020. }
  124021. declare module BABYLON {
  124022. /** @hidden */
  124023. export var pbrDirectLightingFunctions: {
  124024. name: string;
  124025. shader: string;
  124026. };
  124027. }
  124028. declare module BABYLON {
  124029. /** @hidden */
  124030. export var pbrIBLFunctions: {
  124031. name: string;
  124032. shader: string;
  124033. };
  124034. }
  124035. declare module BABYLON {
  124036. /** @hidden */
  124037. export var pbrDebug: {
  124038. name: string;
  124039. shader: string;
  124040. };
  124041. }
  124042. declare module BABYLON {
  124043. /** @hidden */
  124044. export var pbrPixelShader: {
  124045. name: string;
  124046. shader: string;
  124047. };
  124048. }
  124049. declare module BABYLON {
  124050. /** @hidden */
  124051. export var pbrVertexDeclaration: {
  124052. name: string;
  124053. shader: string;
  124054. };
  124055. }
  124056. declare module BABYLON {
  124057. /** @hidden */
  124058. export var pbrVertexShader: {
  124059. name: string;
  124060. shader: string;
  124061. };
  124062. }
  124063. declare module BABYLON {
  124064. /**
  124065. * Manages the defines for the PBR Material.
  124066. * @hidden
  124067. */
  124068. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124069. PBR: boolean;
  124070. MAINUV1: boolean;
  124071. MAINUV2: boolean;
  124072. UV1: boolean;
  124073. UV2: boolean;
  124074. ALBEDO: boolean;
  124075. GAMMAALBEDO: boolean;
  124076. ALBEDODIRECTUV: number;
  124077. VERTEXCOLOR: boolean;
  124078. AMBIENT: boolean;
  124079. AMBIENTDIRECTUV: number;
  124080. AMBIENTINGRAYSCALE: boolean;
  124081. OPACITY: boolean;
  124082. VERTEXALPHA: boolean;
  124083. OPACITYDIRECTUV: number;
  124084. OPACITYRGB: boolean;
  124085. ALPHATEST: boolean;
  124086. DEPTHPREPASS: boolean;
  124087. ALPHABLEND: boolean;
  124088. ALPHAFROMALBEDO: boolean;
  124089. ALPHATESTVALUE: string;
  124090. SPECULAROVERALPHA: boolean;
  124091. RADIANCEOVERALPHA: boolean;
  124092. ALPHAFRESNEL: boolean;
  124093. LINEARALPHAFRESNEL: boolean;
  124094. PREMULTIPLYALPHA: boolean;
  124095. EMISSIVE: boolean;
  124096. EMISSIVEDIRECTUV: number;
  124097. REFLECTIVITY: boolean;
  124098. REFLECTIVITYDIRECTUV: number;
  124099. SPECULARTERM: boolean;
  124100. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124101. MICROSURFACEAUTOMATIC: boolean;
  124102. LODBASEDMICROSFURACE: boolean;
  124103. MICROSURFACEMAP: boolean;
  124104. MICROSURFACEMAPDIRECTUV: number;
  124105. METALLICWORKFLOW: boolean;
  124106. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124107. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124108. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124109. AOSTOREINMETALMAPRED: boolean;
  124110. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124111. ENVIRONMENTBRDF: boolean;
  124112. ENVIRONMENTBRDF_RGBD: boolean;
  124113. NORMAL: boolean;
  124114. TANGENT: boolean;
  124115. BUMP: boolean;
  124116. BUMPDIRECTUV: number;
  124117. OBJECTSPACE_NORMALMAP: boolean;
  124118. PARALLAX: boolean;
  124119. PARALLAXOCCLUSION: boolean;
  124120. NORMALXYSCALE: boolean;
  124121. LIGHTMAP: boolean;
  124122. LIGHTMAPDIRECTUV: number;
  124123. USELIGHTMAPASSHADOWMAP: boolean;
  124124. GAMMALIGHTMAP: boolean;
  124125. RGBDLIGHTMAP: boolean;
  124126. REFLECTION: boolean;
  124127. REFLECTIONMAP_3D: boolean;
  124128. REFLECTIONMAP_SPHERICAL: boolean;
  124129. REFLECTIONMAP_PLANAR: boolean;
  124130. REFLECTIONMAP_CUBIC: boolean;
  124131. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124132. REFLECTIONMAP_PROJECTION: boolean;
  124133. REFLECTIONMAP_SKYBOX: boolean;
  124134. REFLECTIONMAP_EXPLICIT: boolean;
  124135. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124136. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124137. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124138. INVERTCUBICMAP: boolean;
  124139. USESPHERICALFROMREFLECTIONMAP: boolean;
  124140. USEIRRADIANCEMAP: boolean;
  124141. SPHERICAL_HARMONICS: boolean;
  124142. USESPHERICALINVERTEX: boolean;
  124143. REFLECTIONMAP_OPPOSITEZ: boolean;
  124144. LODINREFLECTIONALPHA: boolean;
  124145. GAMMAREFLECTION: boolean;
  124146. RGBDREFLECTION: boolean;
  124147. LINEARSPECULARREFLECTION: boolean;
  124148. RADIANCEOCCLUSION: boolean;
  124149. HORIZONOCCLUSION: boolean;
  124150. INSTANCES: boolean;
  124151. NUM_BONE_INFLUENCERS: number;
  124152. BonesPerMesh: number;
  124153. BONETEXTURE: boolean;
  124154. NONUNIFORMSCALING: boolean;
  124155. MORPHTARGETS: boolean;
  124156. MORPHTARGETS_NORMAL: boolean;
  124157. MORPHTARGETS_TANGENT: boolean;
  124158. MORPHTARGETS_UV: boolean;
  124159. NUM_MORPH_INFLUENCERS: number;
  124160. IMAGEPROCESSING: boolean;
  124161. VIGNETTE: boolean;
  124162. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124163. VIGNETTEBLENDMODEOPAQUE: boolean;
  124164. TONEMAPPING: boolean;
  124165. TONEMAPPING_ACES: boolean;
  124166. CONTRAST: boolean;
  124167. COLORCURVES: boolean;
  124168. COLORGRADING: boolean;
  124169. COLORGRADING3D: boolean;
  124170. SAMPLER3DGREENDEPTH: boolean;
  124171. SAMPLER3DBGRMAP: boolean;
  124172. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124173. EXPOSURE: boolean;
  124174. MULTIVIEW: boolean;
  124175. USEPHYSICALLIGHTFALLOFF: boolean;
  124176. USEGLTFLIGHTFALLOFF: boolean;
  124177. TWOSIDEDLIGHTING: boolean;
  124178. SHADOWFLOAT: boolean;
  124179. CLIPPLANE: boolean;
  124180. CLIPPLANE2: boolean;
  124181. CLIPPLANE3: boolean;
  124182. CLIPPLANE4: boolean;
  124183. CLIPPLANE5: boolean;
  124184. CLIPPLANE6: boolean;
  124185. POINTSIZE: boolean;
  124186. FOG: boolean;
  124187. LOGARITHMICDEPTH: boolean;
  124188. FORCENORMALFORWARD: boolean;
  124189. SPECULARAA: boolean;
  124190. CLEARCOAT: boolean;
  124191. CLEARCOAT_DEFAULTIOR: boolean;
  124192. CLEARCOAT_TEXTURE: boolean;
  124193. CLEARCOAT_TEXTUREDIRECTUV: number;
  124194. CLEARCOAT_BUMP: boolean;
  124195. CLEARCOAT_BUMPDIRECTUV: number;
  124196. CLEARCOAT_TINT: boolean;
  124197. CLEARCOAT_TINT_TEXTURE: boolean;
  124198. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124199. ANISOTROPIC: boolean;
  124200. ANISOTROPIC_TEXTURE: boolean;
  124201. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124202. BRDF_V_HEIGHT_CORRELATED: boolean;
  124203. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124204. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124205. SHEEN: boolean;
  124206. SHEEN_TEXTURE: boolean;
  124207. SHEEN_TEXTUREDIRECTUV: number;
  124208. SHEEN_LINKWITHALBEDO: boolean;
  124209. SUBSURFACE: boolean;
  124210. SS_REFRACTION: boolean;
  124211. SS_TRANSLUCENCY: boolean;
  124212. SS_SCATERRING: boolean;
  124213. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124214. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124215. SS_REFRACTIONMAP_3D: boolean;
  124216. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124217. SS_LODINREFRACTIONALPHA: boolean;
  124218. SS_GAMMAREFRACTION: boolean;
  124219. SS_RGBDREFRACTION: boolean;
  124220. SS_LINEARSPECULARREFRACTION: boolean;
  124221. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124222. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124223. UNLIT: boolean;
  124224. DEBUGMODE: number;
  124225. /**
  124226. * Initializes the PBR Material defines.
  124227. */
  124228. constructor();
  124229. /**
  124230. * Resets the PBR Material defines.
  124231. */
  124232. reset(): void;
  124233. }
  124234. /**
  124235. * The Physically based material base class of BJS.
  124236. *
  124237. * This offers the main features of a standard PBR material.
  124238. * For more information, please refer to the documentation :
  124239. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124240. */
  124241. export abstract class PBRBaseMaterial extends PushMaterial {
  124242. /**
  124243. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124244. */
  124245. static readonly PBRMATERIAL_OPAQUE: number;
  124246. /**
  124247. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124248. */
  124249. static readonly PBRMATERIAL_ALPHATEST: number;
  124250. /**
  124251. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124252. */
  124253. static readonly PBRMATERIAL_ALPHABLEND: number;
  124254. /**
  124255. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124256. * They are also discarded below the alpha cutoff threshold to improve performances.
  124257. */
  124258. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124259. /**
  124260. * Defines the default value of how much AO map is occluding the analytical lights
  124261. * (point spot...).
  124262. */
  124263. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124264. /**
  124265. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124266. */
  124267. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124268. /**
  124269. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124270. * to enhance interoperability with other engines.
  124271. */
  124272. static readonly LIGHTFALLOFF_GLTF: number;
  124273. /**
  124274. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124275. * to enhance interoperability with other materials.
  124276. */
  124277. static readonly LIGHTFALLOFF_STANDARD: number;
  124278. /**
  124279. * Intensity of the direct lights e.g. the four lights available in your scene.
  124280. * This impacts both the direct diffuse and specular highlights.
  124281. */
  124282. protected _directIntensity: number;
  124283. /**
  124284. * Intensity of the emissive part of the material.
  124285. * This helps controlling the emissive effect without modifying the emissive color.
  124286. */
  124287. protected _emissiveIntensity: number;
  124288. /**
  124289. * Intensity of the environment e.g. how much the environment will light the object
  124290. * either through harmonics for rough material or through the refelction for shiny ones.
  124291. */
  124292. protected _environmentIntensity: number;
  124293. /**
  124294. * This is a special control allowing the reduction of the specular highlights coming from the
  124295. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124296. */
  124297. protected _specularIntensity: number;
  124298. /**
  124299. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124300. */
  124301. private _lightingInfos;
  124302. /**
  124303. * Debug Control allowing disabling the bump map on this material.
  124304. */
  124305. protected _disableBumpMap: boolean;
  124306. /**
  124307. * AKA Diffuse Texture in standard nomenclature.
  124308. */
  124309. protected _albedoTexture: Nullable<BaseTexture>;
  124310. /**
  124311. * AKA Occlusion Texture in other nomenclature.
  124312. */
  124313. protected _ambientTexture: Nullable<BaseTexture>;
  124314. /**
  124315. * AKA Occlusion Texture Intensity in other nomenclature.
  124316. */
  124317. protected _ambientTextureStrength: number;
  124318. /**
  124319. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124320. * 1 means it completely occludes it
  124321. * 0 mean it has no impact
  124322. */
  124323. protected _ambientTextureImpactOnAnalyticalLights: number;
  124324. /**
  124325. * Stores the alpha values in a texture.
  124326. */
  124327. protected _opacityTexture: Nullable<BaseTexture>;
  124328. /**
  124329. * Stores the reflection values in a texture.
  124330. */
  124331. protected _reflectionTexture: Nullable<BaseTexture>;
  124332. /**
  124333. * Stores the emissive values in a texture.
  124334. */
  124335. protected _emissiveTexture: Nullable<BaseTexture>;
  124336. /**
  124337. * AKA Specular texture in other nomenclature.
  124338. */
  124339. protected _reflectivityTexture: Nullable<BaseTexture>;
  124340. /**
  124341. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124342. */
  124343. protected _metallicTexture: Nullable<BaseTexture>;
  124344. /**
  124345. * Specifies the metallic scalar of the metallic/roughness workflow.
  124346. * Can also be used to scale the metalness values of the metallic texture.
  124347. */
  124348. protected _metallic: Nullable<number>;
  124349. /**
  124350. * Specifies the roughness scalar of the metallic/roughness workflow.
  124351. * Can also be used to scale the roughness values of the metallic texture.
  124352. */
  124353. protected _roughness: Nullable<number>;
  124354. /**
  124355. * Specifies the an F0 factor to help configuring the material F0.
  124356. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124357. * to 0.5 the previously hard coded value stays the same.
  124358. * Can also be used to scale the F0 values of the metallic texture.
  124359. */
  124360. protected _metallicF0Factor: number;
  124361. /**
  124362. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124363. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124364. * your expectation as it multiplies with the texture data.
  124365. */
  124366. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124367. /**
  124368. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124369. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124370. */
  124371. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124372. /**
  124373. * Stores surface normal data used to displace a mesh in a texture.
  124374. */
  124375. protected _bumpTexture: Nullable<BaseTexture>;
  124376. /**
  124377. * Stores the pre-calculated light information of a mesh in a texture.
  124378. */
  124379. protected _lightmapTexture: Nullable<BaseTexture>;
  124380. /**
  124381. * The color of a material in ambient lighting.
  124382. */
  124383. protected _ambientColor: Color3;
  124384. /**
  124385. * AKA Diffuse Color in other nomenclature.
  124386. */
  124387. protected _albedoColor: Color3;
  124388. /**
  124389. * AKA Specular Color in other nomenclature.
  124390. */
  124391. protected _reflectivityColor: Color3;
  124392. /**
  124393. * The color applied when light is reflected from a material.
  124394. */
  124395. protected _reflectionColor: Color3;
  124396. /**
  124397. * The color applied when light is emitted from a material.
  124398. */
  124399. protected _emissiveColor: Color3;
  124400. /**
  124401. * AKA Glossiness in other nomenclature.
  124402. */
  124403. protected _microSurface: number;
  124404. /**
  124405. * Specifies that the material will use the light map as a show map.
  124406. */
  124407. protected _useLightmapAsShadowmap: boolean;
  124408. /**
  124409. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124410. * makes the reflect vector face the model (under horizon).
  124411. */
  124412. protected _useHorizonOcclusion: boolean;
  124413. /**
  124414. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124415. * too much the area relying on ambient texture to define their ambient occlusion.
  124416. */
  124417. protected _useRadianceOcclusion: boolean;
  124418. /**
  124419. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124420. */
  124421. protected _useAlphaFromAlbedoTexture: boolean;
  124422. /**
  124423. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124424. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124425. */
  124426. protected _useSpecularOverAlpha: boolean;
  124427. /**
  124428. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124429. */
  124430. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124431. /**
  124432. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124433. */
  124434. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124435. /**
  124436. * Specifies if the metallic texture contains the roughness information in its green channel.
  124437. */
  124438. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124439. /**
  124440. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124441. */
  124442. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124443. /**
  124444. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124445. */
  124446. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124447. /**
  124448. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124449. */
  124450. protected _useAmbientInGrayScale: boolean;
  124451. /**
  124452. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124453. * The material will try to infer what glossiness each pixel should be.
  124454. */
  124455. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124456. /**
  124457. * Defines the falloff type used in this material.
  124458. * It by default is Physical.
  124459. */
  124460. protected _lightFalloff: number;
  124461. /**
  124462. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124463. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124464. */
  124465. protected _useRadianceOverAlpha: boolean;
  124466. /**
  124467. * Allows using an object space normal map (instead of tangent space).
  124468. */
  124469. protected _useObjectSpaceNormalMap: boolean;
  124470. /**
  124471. * Allows using the bump map in parallax mode.
  124472. */
  124473. protected _useParallax: boolean;
  124474. /**
  124475. * Allows using the bump map in parallax occlusion mode.
  124476. */
  124477. protected _useParallaxOcclusion: boolean;
  124478. /**
  124479. * Controls the scale bias of the parallax mode.
  124480. */
  124481. protected _parallaxScaleBias: number;
  124482. /**
  124483. * If sets to true, disables all the lights affecting the material.
  124484. */
  124485. protected _disableLighting: boolean;
  124486. /**
  124487. * Number of Simultaneous lights allowed on the material.
  124488. */
  124489. protected _maxSimultaneousLights: number;
  124490. /**
  124491. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124492. */
  124493. protected _invertNormalMapX: boolean;
  124494. /**
  124495. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124496. */
  124497. protected _invertNormalMapY: boolean;
  124498. /**
  124499. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124500. */
  124501. protected _twoSidedLighting: boolean;
  124502. /**
  124503. * Defines the alpha limits in alpha test mode.
  124504. */
  124505. protected _alphaCutOff: number;
  124506. /**
  124507. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124508. */
  124509. protected _forceAlphaTest: boolean;
  124510. /**
  124511. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124512. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124513. */
  124514. protected _useAlphaFresnel: boolean;
  124515. /**
  124516. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124517. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124518. */
  124519. protected _useLinearAlphaFresnel: boolean;
  124520. /**
  124521. * The transparency mode of the material.
  124522. */
  124523. protected _transparencyMode: Nullable<number>;
  124524. /**
  124525. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124526. * from cos thetav and roughness:
  124527. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124528. */
  124529. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124530. /**
  124531. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124532. */
  124533. protected _forceIrradianceInFragment: boolean;
  124534. /**
  124535. * Force normal to face away from face.
  124536. */
  124537. protected _forceNormalForward: boolean;
  124538. /**
  124539. * Enables specular anti aliasing in the PBR shader.
  124540. * It will both interacts on the Geometry for analytical and IBL lighting.
  124541. * It also prefilter the roughness map based on the bump values.
  124542. */
  124543. protected _enableSpecularAntiAliasing: boolean;
  124544. /**
  124545. * Default configuration related to image processing available in the PBR Material.
  124546. */
  124547. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124548. /**
  124549. * Keep track of the image processing observer to allow dispose and replace.
  124550. */
  124551. private _imageProcessingObserver;
  124552. /**
  124553. * Attaches a new image processing configuration to the PBR Material.
  124554. * @param configuration
  124555. */
  124556. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124557. /**
  124558. * Stores the available render targets.
  124559. */
  124560. private _renderTargets;
  124561. /**
  124562. * Sets the global ambient color for the material used in lighting calculations.
  124563. */
  124564. private _globalAmbientColor;
  124565. /**
  124566. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124567. */
  124568. private _useLogarithmicDepth;
  124569. /**
  124570. * If set to true, no lighting calculations will be applied.
  124571. */
  124572. private _unlit;
  124573. private _debugMode;
  124574. /**
  124575. * @hidden
  124576. * This is reserved for the inspector.
  124577. * Defines the material debug mode.
  124578. * It helps seeing only some components of the material while troubleshooting.
  124579. */
  124580. debugMode: number;
  124581. /**
  124582. * @hidden
  124583. * This is reserved for the inspector.
  124584. * Specify from where on screen the debug mode should start.
  124585. * The value goes from -1 (full screen) to 1 (not visible)
  124586. * It helps with side by side comparison against the final render
  124587. * This defaults to -1
  124588. */
  124589. private debugLimit;
  124590. /**
  124591. * @hidden
  124592. * This is reserved for the inspector.
  124593. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124594. * You can use the factor to better multiply the final value.
  124595. */
  124596. private debugFactor;
  124597. /**
  124598. * Defines the clear coat layer parameters for the material.
  124599. */
  124600. readonly clearCoat: PBRClearCoatConfiguration;
  124601. /**
  124602. * Defines the anisotropic parameters for the material.
  124603. */
  124604. readonly anisotropy: PBRAnisotropicConfiguration;
  124605. /**
  124606. * Defines the BRDF parameters for the material.
  124607. */
  124608. readonly brdf: PBRBRDFConfiguration;
  124609. /**
  124610. * Defines the Sheen parameters for the material.
  124611. */
  124612. readonly sheen: PBRSheenConfiguration;
  124613. /**
  124614. * Defines the SubSurface parameters for the material.
  124615. */
  124616. readonly subSurface: PBRSubSurfaceConfiguration;
  124617. /**
  124618. * Custom callback helping to override the default shader used in the material.
  124619. */
  124620. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124621. protected _rebuildInParallel: boolean;
  124622. /**
  124623. * Instantiates a new PBRMaterial instance.
  124624. *
  124625. * @param name The material name
  124626. * @param scene The scene the material will be use in.
  124627. */
  124628. constructor(name: string, scene: Scene);
  124629. /**
  124630. * Gets a boolean indicating that current material needs to register RTT
  124631. */
  124632. get hasRenderTargetTextures(): boolean;
  124633. /**
  124634. * Gets the name of the material class.
  124635. */
  124636. getClassName(): string;
  124637. /**
  124638. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124639. */
  124640. get useLogarithmicDepth(): boolean;
  124641. /**
  124642. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124643. */
  124644. set useLogarithmicDepth(value: boolean);
  124645. /**
  124646. * Gets the current transparency mode.
  124647. */
  124648. get transparencyMode(): Nullable<number>;
  124649. /**
  124650. * Sets the transparency mode of the material.
  124651. *
  124652. * | Value | Type | Description |
  124653. * | ----- | ----------------------------------- | ----------- |
  124654. * | 0 | OPAQUE | |
  124655. * | 1 | ALPHATEST | |
  124656. * | 2 | ALPHABLEND | |
  124657. * | 3 | ALPHATESTANDBLEND | |
  124658. *
  124659. */
  124660. set transparencyMode(value: Nullable<number>);
  124661. /**
  124662. * Returns true if alpha blending should be disabled.
  124663. */
  124664. private get _disableAlphaBlending();
  124665. /**
  124666. * Specifies whether or not this material should be rendered in alpha blend mode.
  124667. */
  124668. needAlphaBlending(): boolean;
  124669. /**
  124670. * Specifies if the mesh will require alpha blending.
  124671. * @param mesh - BJS mesh.
  124672. */
  124673. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124674. /**
  124675. * Specifies whether or not this material should be rendered in alpha test mode.
  124676. */
  124677. needAlphaTesting(): boolean;
  124678. /**
  124679. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124680. */
  124681. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124682. /**
  124683. * Gets the texture used for the alpha test.
  124684. */
  124685. getAlphaTestTexture(): Nullable<BaseTexture>;
  124686. /**
  124687. * Specifies that the submesh is ready to be used.
  124688. * @param mesh - BJS mesh.
  124689. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124690. * @param useInstances - Specifies that instances should be used.
  124691. * @returns - boolean indicating that the submesh is ready or not.
  124692. */
  124693. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124694. /**
  124695. * Specifies if the material uses metallic roughness workflow.
  124696. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124697. */
  124698. isMetallicWorkflow(): boolean;
  124699. private _prepareEffect;
  124700. private _prepareDefines;
  124701. /**
  124702. * Force shader compilation
  124703. */
  124704. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124705. /**
  124706. * Initializes the uniform buffer layout for the shader.
  124707. */
  124708. buildUniformLayout(): void;
  124709. /**
  124710. * Unbinds the material from the mesh
  124711. */
  124712. unbind(): void;
  124713. /**
  124714. * Binds the submesh data.
  124715. * @param world - The world matrix.
  124716. * @param mesh - The BJS mesh.
  124717. * @param subMesh - A submesh of the BJS mesh.
  124718. */
  124719. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124720. /**
  124721. * Returns the animatable textures.
  124722. * @returns - Array of animatable textures.
  124723. */
  124724. getAnimatables(): IAnimatable[];
  124725. /**
  124726. * Returns the texture used for reflections.
  124727. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124728. */
  124729. private _getReflectionTexture;
  124730. /**
  124731. * Returns an array of the actively used textures.
  124732. * @returns - Array of BaseTextures
  124733. */
  124734. getActiveTextures(): BaseTexture[];
  124735. /**
  124736. * Checks to see if a texture is used in the material.
  124737. * @param texture - Base texture to use.
  124738. * @returns - Boolean specifying if a texture is used in the material.
  124739. */
  124740. hasTexture(texture: BaseTexture): boolean;
  124741. /**
  124742. * Disposes the resources of the material.
  124743. * @param forceDisposeEffect - Forces the disposal of effects.
  124744. * @param forceDisposeTextures - Forces the disposal of all textures.
  124745. */
  124746. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124747. }
  124748. }
  124749. declare module BABYLON {
  124750. /**
  124751. * The Physically based material of BJS.
  124752. *
  124753. * This offers the main features of a standard PBR material.
  124754. * For more information, please refer to the documentation :
  124755. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124756. */
  124757. export class PBRMaterial extends PBRBaseMaterial {
  124758. /**
  124759. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124760. */
  124761. static readonly PBRMATERIAL_OPAQUE: number;
  124762. /**
  124763. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124764. */
  124765. static readonly PBRMATERIAL_ALPHATEST: number;
  124766. /**
  124767. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124768. */
  124769. static readonly PBRMATERIAL_ALPHABLEND: number;
  124770. /**
  124771. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124772. * They are also discarded below the alpha cutoff threshold to improve performances.
  124773. */
  124774. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124775. /**
  124776. * Defines the default value of how much AO map is occluding the analytical lights
  124777. * (point spot...).
  124778. */
  124779. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124780. /**
  124781. * Intensity of the direct lights e.g. the four lights available in your scene.
  124782. * This impacts both the direct diffuse and specular highlights.
  124783. */
  124784. directIntensity: number;
  124785. /**
  124786. * Intensity of the emissive part of the material.
  124787. * This helps controlling the emissive effect without modifying the emissive color.
  124788. */
  124789. emissiveIntensity: number;
  124790. /**
  124791. * Intensity of the environment e.g. how much the environment will light the object
  124792. * either through harmonics for rough material or through the refelction for shiny ones.
  124793. */
  124794. environmentIntensity: number;
  124795. /**
  124796. * This is a special control allowing the reduction of the specular highlights coming from the
  124797. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124798. */
  124799. specularIntensity: number;
  124800. /**
  124801. * Debug Control allowing disabling the bump map on this material.
  124802. */
  124803. disableBumpMap: boolean;
  124804. /**
  124805. * AKA Diffuse Texture in standard nomenclature.
  124806. */
  124807. albedoTexture: BaseTexture;
  124808. /**
  124809. * AKA Occlusion Texture in other nomenclature.
  124810. */
  124811. ambientTexture: BaseTexture;
  124812. /**
  124813. * AKA Occlusion Texture Intensity in other nomenclature.
  124814. */
  124815. ambientTextureStrength: number;
  124816. /**
  124817. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124818. * 1 means it completely occludes it
  124819. * 0 mean it has no impact
  124820. */
  124821. ambientTextureImpactOnAnalyticalLights: number;
  124822. /**
  124823. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124824. */
  124825. opacityTexture: BaseTexture;
  124826. /**
  124827. * Stores the reflection values in a texture.
  124828. */
  124829. reflectionTexture: Nullable<BaseTexture>;
  124830. /**
  124831. * Stores the emissive values in a texture.
  124832. */
  124833. emissiveTexture: BaseTexture;
  124834. /**
  124835. * AKA Specular texture in other nomenclature.
  124836. */
  124837. reflectivityTexture: BaseTexture;
  124838. /**
  124839. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124840. */
  124841. metallicTexture: BaseTexture;
  124842. /**
  124843. * Specifies the metallic scalar of the metallic/roughness workflow.
  124844. * Can also be used to scale the metalness values of the metallic texture.
  124845. */
  124846. metallic: Nullable<number>;
  124847. /**
  124848. * Specifies the roughness scalar of the metallic/roughness workflow.
  124849. * Can also be used to scale the roughness values of the metallic texture.
  124850. */
  124851. roughness: Nullable<number>;
  124852. /**
  124853. * Specifies the an F0 factor to help configuring the material F0.
  124854. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124855. * to 0.5 the previously hard coded value stays the same.
  124856. * Can also be used to scale the F0 values of the metallic texture.
  124857. */
  124858. metallicF0Factor: number;
  124859. /**
  124860. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124861. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124862. * your expectation as it multiplies with the texture data.
  124863. */
  124864. useMetallicF0FactorFromMetallicTexture: boolean;
  124865. /**
  124866. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124867. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124868. */
  124869. microSurfaceTexture: BaseTexture;
  124870. /**
  124871. * Stores surface normal data used to displace a mesh in a texture.
  124872. */
  124873. bumpTexture: BaseTexture;
  124874. /**
  124875. * Stores the pre-calculated light information of a mesh in a texture.
  124876. */
  124877. lightmapTexture: BaseTexture;
  124878. /**
  124879. * Stores the refracted light information in a texture.
  124880. */
  124881. get refractionTexture(): Nullable<BaseTexture>;
  124882. set refractionTexture(value: Nullable<BaseTexture>);
  124883. /**
  124884. * The color of a material in ambient lighting.
  124885. */
  124886. ambientColor: Color3;
  124887. /**
  124888. * AKA Diffuse Color in other nomenclature.
  124889. */
  124890. albedoColor: Color3;
  124891. /**
  124892. * AKA Specular Color in other nomenclature.
  124893. */
  124894. reflectivityColor: Color3;
  124895. /**
  124896. * The color reflected from the material.
  124897. */
  124898. reflectionColor: Color3;
  124899. /**
  124900. * The color emitted from the material.
  124901. */
  124902. emissiveColor: Color3;
  124903. /**
  124904. * AKA Glossiness in other nomenclature.
  124905. */
  124906. microSurface: number;
  124907. /**
  124908. * source material index of refraction (IOR)' / 'destination material IOR.
  124909. */
  124910. get indexOfRefraction(): number;
  124911. set indexOfRefraction(value: number);
  124912. /**
  124913. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124914. */
  124915. get invertRefractionY(): boolean;
  124916. set invertRefractionY(value: boolean);
  124917. /**
  124918. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124919. * Materials half opaque for instance using refraction could benefit from this control.
  124920. */
  124921. get linkRefractionWithTransparency(): boolean;
  124922. set linkRefractionWithTransparency(value: boolean);
  124923. /**
  124924. * If true, the light map contains occlusion information instead of lighting info.
  124925. */
  124926. useLightmapAsShadowmap: boolean;
  124927. /**
  124928. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124929. */
  124930. useAlphaFromAlbedoTexture: boolean;
  124931. /**
  124932. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124933. */
  124934. forceAlphaTest: boolean;
  124935. /**
  124936. * Defines the alpha limits in alpha test mode.
  124937. */
  124938. alphaCutOff: number;
  124939. /**
  124940. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124941. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124942. */
  124943. useSpecularOverAlpha: boolean;
  124944. /**
  124945. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124946. */
  124947. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124948. /**
  124949. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124950. */
  124951. useRoughnessFromMetallicTextureAlpha: boolean;
  124952. /**
  124953. * Specifies if the metallic texture contains the roughness information in its green channel.
  124954. */
  124955. useRoughnessFromMetallicTextureGreen: boolean;
  124956. /**
  124957. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124958. */
  124959. useMetallnessFromMetallicTextureBlue: boolean;
  124960. /**
  124961. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124962. */
  124963. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124964. /**
  124965. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124966. */
  124967. useAmbientInGrayScale: boolean;
  124968. /**
  124969. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124970. * The material will try to infer what glossiness each pixel should be.
  124971. */
  124972. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124973. /**
  124974. * BJS is using an harcoded light falloff based on a manually sets up range.
  124975. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124976. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124977. */
  124978. get usePhysicalLightFalloff(): boolean;
  124979. /**
  124980. * BJS is using an harcoded light falloff based on a manually sets up range.
  124981. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124982. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124983. */
  124984. set usePhysicalLightFalloff(value: boolean);
  124985. /**
  124986. * In order to support the falloff compatibility with gltf, a special mode has been added
  124987. * to reproduce the gltf light falloff.
  124988. */
  124989. get useGLTFLightFalloff(): boolean;
  124990. /**
  124991. * In order to support the falloff compatibility with gltf, a special mode has been added
  124992. * to reproduce the gltf light falloff.
  124993. */
  124994. set useGLTFLightFalloff(value: boolean);
  124995. /**
  124996. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124997. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124998. */
  124999. useRadianceOverAlpha: boolean;
  125000. /**
  125001. * Allows using an object space normal map (instead of tangent space).
  125002. */
  125003. useObjectSpaceNormalMap: boolean;
  125004. /**
  125005. * Allows using the bump map in parallax mode.
  125006. */
  125007. useParallax: boolean;
  125008. /**
  125009. * Allows using the bump map in parallax occlusion mode.
  125010. */
  125011. useParallaxOcclusion: boolean;
  125012. /**
  125013. * Controls the scale bias of the parallax mode.
  125014. */
  125015. parallaxScaleBias: number;
  125016. /**
  125017. * If sets to true, disables all the lights affecting the material.
  125018. */
  125019. disableLighting: boolean;
  125020. /**
  125021. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125022. */
  125023. forceIrradianceInFragment: boolean;
  125024. /**
  125025. * Number of Simultaneous lights allowed on the material.
  125026. */
  125027. maxSimultaneousLights: number;
  125028. /**
  125029. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125030. */
  125031. invertNormalMapX: boolean;
  125032. /**
  125033. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125034. */
  125035. invertNormalMapY: boolean;
  125036. /**
  125037. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125038. */
  125039. twoSidedLighting: boolean;
  125040. /**
  125041. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125042. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125043. */
  125044. useAlphaFresnel: boolean;
  125045. /**
  125046. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125047. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125048. */
  125049. useLinearAlphaFresnel: boolean;
  125050. /**
  125051. * Let user defines the brdf lookup texture used for IBL.
  125052. * A default 8bit version is embedded but you could point at :
  125053. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125054. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125055. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125056. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125057. */
  125058. environmentBRDFTexture: Nullable<BaseTexture>;
  125059. /**
  125060. * Force normal to face away from face.
  125061. */
  125062. forceNormalForward: boolean;
  125063. /**
  125064. * Enables specular anti aliasing in the PBR shader.
  125065. * It will both interacts on the Geometry for analytical and IBL lighting.
  125066. * It also prefilter the roughness map based on the bump values.
  125067. */
  125068. enableSpecularAntiAliasing: boolean;
  125069. /**
  125070. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125071. * makes the reflect vector face the model (under horizon).
  125072. */
  125073. useHorizonOcclusion: boolean;
  125074. /**
  125075. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125076. * too much the area relying on ambient texture to define their ambient occlusion.
  125077. */
  125078. useRadianceOcclusion: boolean;
  125079. /**
  125080. * If set to true, no lighting calculations will be applied.
  125081. */
  125082. unlit: boolean;
  125083. /**
  125084. * Gets the image processing configuration used either in this material.
  125085. */
  125086. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125087. /**
  125088. * Sets the Default image processing configuration used either in the this material.
  125089. *
  125090. * If sets to null, the scene one is in use.
  125091. */
  125092. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125093. /**
  125094. * Gets wether the color curves effect is enabled.
  125095. */
  125096. get cameraColorCurvesEnabled(): boolean;
  125097. /**
  125098. * Sets wether the color curves effect is enabled.
  125099. */
  125100. set cameraColorCurvesEnabled(value: boolean);
  125101. /**
  125102. * Gets wether the color grading effect is enabled.
  125103. */
  125104. get cameraColorGradingEnabled(): boolean;
  125105. /**
  125106. * Gets wether the color grading effect is enabled.
  125107. */
  125108. set cameraColorGradingEnabled(value: boolean);
  125109. /**
  125110. * Gets wether tonemapping is enabled or not.
  125111. */
  125112. get cameraToneMappingEnabled(): boolean;
  125113. /**
  125114. * Sets wether tonemapping is enabled or not
  125115. */
  125116. set cameraToneMappingEnabled(value: boolean);
  125117. /**
  125118. * The camera exposure used on this material.
  125119. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125120. * This corresponds to a photographic exposure.
  125121. */
  125122. get cameraExposure(): number;
  125123. /**
  125124. * The camera exposure used on this material.
  125125. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125126. * This corresponds to a photographic exposure.
  125127. */
  125128. set cameraExposure(value: number);
  125129. /**
  125130. * Gets The camera contrast used on this material.
  125131. */
  125132. get cameraContrast(): number;
  125133. /**
  125134. * Sets The camera contrast used on this material.
  125135. */
  125136. set cameraContrast(value: number);
  125137. /**
  125138. * Gets the Color Grading 2D Lookup Texture.
  125139. */
  125140. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125141. /**
  125142. * Sets the Color Grading 2D Lookup Texture.
  125143. */
  125144. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125145. /**
  125146. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125147. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125148. * 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;
  125149. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125150. */
  125151. get cameraColorCurves(): Nullable<ColorCurves>;
  125152. /**
  125153. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125154. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125155. * 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;
  125156. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125157. */
  125158. set cameraColorCurves(value: Nullable<ColorCurves>);
  125159. /**
  125160. * Instantiates a new PBRMaterial instance.
  125161. *
  125162. * @param name The material name
  125163. * @param scene The scene the material will be use in.
  125164. */
  125165. constructor(name: string, scene: Scene);
  125166. /**
  125167. * Returns the name of this material class.
  125168. */
  125169. getClassName(): string;
  125170. /**
  125171. * Makes a duplicate of the current material.
  125172. * @param name - name to use for the new material.
  125173. */
  125174. clone(name: string): PBRMaterial;
  125175. /**
  125176. * Serializes this PBR Material.
  125177. * @returns - An object with the serialized material.
  125178. */
  125179. serialize(): any;
  125180. /**
  125181. * Parses a PBR Material from a serialized object.
  125182. * @param source - Serialized object.
  125183. * @param scene - BJS scene instance.
  125184. * @param rootUrl - url for the scene object
  125185. * @returns - PBRMaterial
  125186. */
  125187. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125188. }
  125189. }
  125190. declare module BABYLON {
  125191. /**
  125192. * Direct draw surface info
  125193. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125194. */
  125195. export interface DDSInfo {
  125196. /**
  125197. * Width of the texture
  125198. */
  125199. width: number;
  125200. /**
  125201. * Width of the texture
  125202. */
  125203. height: number;
  125204. /**
  125205. * Number of Mipmaps for the texture
  125206. * @see https://en.wikipedia.org/wiki/Mipmap
  125207. */
  125208. mipmapCount: number;
  125209. /**
  125210. * If the textures format is a known fourCC format
  125211. * @see https://www.fourcc.org/
  125212. */
  125213. isFourCC: boolean;
  125214. /**
  125215. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125216. */
  125217. isRGB: boolean;
  125218. /**
  125219. * If the texture is a lumincance format
  125220. */
  125221. isLuminance: boolean;
  125222. /**
  125223. * If this is a cube texture
  125224. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125225. */
  125226. isCube: boolean;
  125227. /**
  125228. * If the texture is a compressed format eg. FOURCC_DXT1
  125229. */
  125230. isCompressed: boolean;
  125231. /**
  125232. * The dxgiFormat of the texture
  125233. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125234. */
  125235. dxgiFormat: number;
  125236. /**
  125237. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125238. */
  125239. textureType: number;
  125240. /**
  125241. * Sphericle polynomial created for the dds texture
  125242. */
  125243. sphericalPolynomial?: SphericalPolynomial;
  125244. }
  125245. /**
  125246. * Class used to provide DDS decompression tools
  125247. */
  125248. export class DDSTools {
  125249. /**
  125250. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125251. */
  125252. static StoreLODInAlphaChannel: boolean;
  125253. /**
  125254. * Gets DDS information from an array buffer
  125255. * @param data defines the array buffer view to read data from
  125256. * @returns the DDS information
  125257. */
  125258. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125259. private static _FloatView;
  125260. private static _Int32View;
  125261. private static _ToHalfFloat;
  125262. private static _FromHalfFloat;
  125263. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125264. private static _GetHalfFloatRGBAArrayBuffer;
  125265. private static _GetFloatRGBAArrayBuffer;
  125266. private static _GetFloatAsUIntRGBAArrayBuffer;
  125267. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125268. private static _GetRGBAArrayBuffer;
  125269. private static _ExtractLongWordOrder;
  125270. private static _GetRGBArrayBuffer;
  125271. private static _GetLuminanceArrayBuffer;
  125272. /**
  125273. * Uploads DDS Levels to a Babylon Texture
  125274. * @hidden
  125275. */
  125276. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125277. }
  125278. interface ThinEngine {
  125279. /**
  125280. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125281. * @param rootUrl defines the url where the file to load is located
  125282. * @param scene defines the current scene
  125283. * @param lodScale defines scale to apply to the mip map selection
  125284. * @param lodOffset defines offset to apply to the mip map selection
  125285. * @param onLoad defines an optional callback raised when the texture is loaded
  125286. * @param onError defines an optional callback raised if there is an issue to load the texture
  125287. * @param format defines the format of the data
  125288. * @param forcedExtension defines the extension to use to pick the right loader
  125289. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125290. * @returns the cube texture as an InternalTexture
  125291. */
  125292. 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;
  125293. }
  125294. }
  125295. declare module BABYLON {
  125296. /**
  125297. * Implementation of the DDS Texture Loader.
  125298. * @hidden
  125299. */
  125300. export class _DDSTextureLoader implements IInternalTextureLoader {
  125301. /**
  125302. * Defines wether the loader supports cascade loading the different faces.
  125303. */
  125304. readonly supportCascades: boolean;
  125305. /**
  125306. * This returns if the loader support the current file information.
  125307. * @param extension defines the file extension of the file being loaded
  125308. * @returns true if the loader can load the specified file
  125309. */
  125310. canLoad(extension: string): boolean;
  125311. /**
  125312. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125313. * @param data contains the texture data
  125314. * @param texture defines the BabylonJS internal texture
  125315. * @param createPolynomials will be true if polynomials have been requested
  125316. * @param onLoad defines the callback to trigger once the texture is ready
  125317. * @param onError defines the callback to trigger in case of error
  125318. */
  125319. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125320. /**
  125321. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125322. * @param data contains the texture data
  125323. * @param texture defines the BabylonJS internal texture
  125324. * @param callback defines the method to call once ready to upload
  125325. */
  125326. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125327. }
  125328. }
  125329. declare module BABYLON {
  125330. /**
  125331. * Implementation of the ENV Texture Loader.
  125332. * @hidden
  125333. */
  125334. export class _ENVTextureLoader implements IInternalTextureLoader {
  125335. /**
  125336. * Defines wether the loader supports cascade loading the different faces.
  125337. */
  125338. readonly supportCascades: boolean;
  125339. /**
  125340. * This returns if the loader support the current file information.
  125341. * @param extension defines the file extension of the file being loaded
  125342. * @returns true if the loader can load the specified file
  125343. */
  125344. canLoad(extension: string): boolean;
  125345. /**
  125346. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125347. * @param data contains the texture data
  125348. * @param texture defines the BabylonJS internal texture
  125349. * @param createPolynomials will be true if polynomials have been requested
  125350. * @param onLoad defines the callback to trigger once the texture is ready
  125351. * @param onError defines the callback to trigger in case of error
  125352. */
  125353. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125354. /**
  125355. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125356. * @param data contains the texture data
  125357. * @param texture defines the BabylonJS internal texture
  125358. * @param callback defines the method to call once ready to upload
  125359. */
  125360. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125361. }
  125362. }
  125363. declare module BABYLON {
  125364. /**
  125365. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125366. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125367. */
  125368. export class KhronosTextureContainer {
  125369. /** contents of the KTX container file */
  125370. data: ArrayBufferView;
  125371. private static HEADER_LEN;
  125372. private static COMPRESSED_2D;
  125373. private static COMPRESSED_3D;
  125374. private static TEX_2D;
  125375. private static TEX_3D;
  125376. /**
  125377. * Gets the openGL type
  125378. */
  125379. glType: number;
  125380. /**
  125381. * Gets the openGL type size
  125382. */
  125383. glTypeSize: number;
  125384. /**
  125385. * Gets the openGL format
  125386. */
  125387. glFormat: number;
  125388. /**
  125389. * Gets the openGL internal format
  125390. */
  125391. glInternalFormat: number;
  125392. /**
  125393. * Gets the base internal format
  125394. */
  125395. glBaseInternalFormat: number;
  125396. /**
  125397. * Gets image width in pixel
  125398. */
  125399. pixelWidth: number;
  125400. /**
  125401. * Gets image height in pixel
  125402. */
  125403. pixelHeight: number;
  125404. /**
  125405. * Gets image depth in pixels
  125406. */
  125407. pixelDepth: number;
  125408. /**
  125409. * Gets the number of array elements
  125410. */
  125411. numberOfArrayElements: number;
  125412. /**
  125413. * Gets the number of faces
  125414. */
  125415. numberOfFaces: number;
  125416. /**
  125417. * Gets the number of mipmap levels
  125418. */
  125419. numberOfMipmapLevels: number;
  125420. /**
  125421. * Gets the bytes of key value data
  125422. */
  125423. bytesOfKeyValueData: number;
  125424. /**
  125425. * Gets the load type
  125426. */
  125427. loadType: number;
  125428. /**
  125429. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125430. */
  125431. isInvalid: boolean;
  125432. /**
  125433. * Creates a new KhronosTextureContainer
  125434. * @param data contents of the KTX container file
  125435. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125436. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125437. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125438. */
  125439. constructor(
  125440. /** contents of the KTX container file */
  125441. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125442. /**
  125443. * Uploads KTX content to a Babylon Texture.
  125444. * It is assumed that the texture has already been created & is currently bound
  125445. * @hidden
  125446. */
  125447. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125448. private _upload2DCompressedLevels;
  125449. /**
  125450. * Checks if the given data starts with a KTX file identifier.
  125451. * @param data the data to check
  125452. * @returns true if the data is a KTX file or false otherwise
  125453. */
  125454. static IsValid(data: ArrayBufferView): boolean;
  125455. }
  125456. }
  125457. declare module BABYLON {
  125458. /**
  125459. * Class for loading KTX2 files
  125460. * !!! Experimental Extension Subject to Changes !!!
  125461. * @hidden
  125462. */
  125463. export class KhronosTextureContainer2 {
  125464. private static _ModulePromise;
  125465. private static _TranscodeFormat;
  125466. constructor(engine: ThinEngine);
  125467. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  125468. private _determineTranscodeFormat;
  125469. /**
  125470. * Checks if the given data starts with a KTX2 file identifier.
  125471. * @param data the data to check
  125472. * @returns true if the data is a KTX2 file or false otherwise
  125473. */
  125474. static IsValid(data: ArrayBufferView): boolean;
  125475. }
  125476. }
  125477. declare module BABYLON {
  125478. /**
  125479. * Implementation of the KTX Texture Loader.
  125480. * @hidden
  125481. */
  125482. export class _KTXTextureLoader implements IInternalTextureLoader {
  125483. /**
  125484. * Defines wether the loader supports cascade loading the different faces.
  125485. */
  125486. readonly supportCascades: boolean;
  125487. /**
  125488. * This returns if the loader support the current file information.
  125489. * @param extension defines the file extension of the file being loaded
  125490. * @returns true if the loader can load the specified file
  125491. */
  125492. canLoad(extension: string): boolean;
  125493. /**
  125494. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125495. * @param data contains the texture data
  125496. * @param texture defines the BabylonJS internal texture
  125497. * @param createPolynomials will be true if polynomials have been requested
  125498. * @param onLoad defines the callback to trigger once the texture is ready
  125499. * @param onError defines the callback to trigger in case of error
  125500. */
  125501. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125502. /**
  125503. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125504. * @param data contains the texture data
  125505. * @param texture defines the BabylonJS internal texture
  125506. * @param callback defines the method to call once ready to upload
  125507. */
  125508. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125509. }
  125510. }
  125511. declare module BABYLON {
  125512. /** @hidden */
  125513. export var _forceSceneHelpersToBundle: boolean;
  125514. interface Scene {
  125515. /**
  125516. * Creates a default light for the scene.
  125517. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125518. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125519. */
  125520. createDefaultLight(replace?: boolean): void;
  125521. /**
  125522. * Creates a default camera for the scene.
  125523. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125524. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125525. * @param replace has default false, when true replaces the active camera in the scene
  125526. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125527. */
  125528. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125529. /**
  125530. * Creates a default camera and a default light.
  125531. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125532. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125533. * @param replace has the default false, when true replaces the active camera/light in the scene
  125534. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125535. */
  125536. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125537. /**
  125538. * Creates a new sky box
  125539. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125540. * @param environmentTexture defines the texture to use as environment texture
  125541. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125542. * @param scale defines the overall scale of the skybox
  125543. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125544. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125545. * @returns a new mesh holding the sky box
  125546. */
  125547. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125548. /**
  125549. * Creates a new environment
  125550. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125551. * @param options defines the options you can use to configure the environment
  125552. * @returns the new EnvironmentHelper
  125553. */
  125554. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125555. /**
  125556. * Creates a new VREXperienceHelper
  125557. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125558. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125559. * @returns a new VREXperienceHelper
  125560. */
  125561. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125562. /**
  125563. * Creates a new WebXRDefaultExperience
  125564. * @see http://doc.babylonjs.com/how_to/webxr
  125565. * @param options experience options
  125566. * @returns a promise for a new WebXRDefaultExperience
  125567. */
  125568. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125569. }
  125570. }
  125571. declare module BABYLON {
  125572. /**
  125573. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125574. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125575. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125576. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125577. */
  125578. export class VideoDome extends TransformNode {
  125579. /**
  125580. * Define the video source as a Monoscopic panoramic 360 video.
  125581. */
  125582. static readonly MODE_MONOSCOPIC: number;
  125583. /**
  125584. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125585. */
  125586. static readonly MODE_TOPBOTTOM: number;
  125587. /**
  125588. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125589. */
  125590. static readonly MODE_SIDEBYSIDE: number;
  125591. private _halfDome;
  125592. private _useDirectMapping;
  125593. /**
  125594. * The video texture being displayed on the sphere
  125595. */
  125596. protected _videoTexture: VideoTexture;
  125597. /**
  125598. * Gets the video texture being displayed on the sphere
  125599. */
  125600. get videoTexture(): VideoTexture;
  125601. /**
  125602. * The skybox material
  125603. */
  125604. protected _material: BackgroundMaterial;
  125605. /**
  125606. * The surface used for the skybox
  125607. */
  125608. protected _mesh: Mesh;
  125609. /**
  125610. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125611. */
  125612. private _halfDomeMask;
  125613. /**
  125614. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125615. * Also see the options.resolution property.
  125616. */
  125617. get fovMultiplier(): number;
  125618. set fovMultiplier(value: number);
  125619. private _videoMode;
  125620. /**
  125621. * Gets or set the current video mode for the video. It can be:
  125622. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125623. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125624. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125625. */
  125626. get videoMode(): number;
  125627. set videoMode(value: number);
  125628. /**
  125629. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125630. *
  125631. */
  125632. get halfDome(): boolean;
  125633. /**
  125634. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125635. */
  125636. set halfDome(enabled: boolean);
  125637. /**
  125638. * Oberserver used in Stereoscopic VR Mode.
  125639. */
  125640. private _onBeforeCameraRenderObserver;
  125641. /**
  125642. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125643. * @param name Element's name, child elements will append suffixes for their own names.
  125644. * @param urlsOrVideo defines the url(s) or the video element to use
  125645. * @param options An object containing optional or exposed sub element properties
  125646. */
  125647. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125648. resolution?: number;
  125649. clickToPlay?: boolean;
  125650. autoPlay?: boolean;
  125651. loop?: boolean;
  125652. size?: number;
  125653. poster?: string;
  125654. faceForward?: boolean;
  125655. useDirectMapping?: boolean;
  125656. halfDomeMode?: boolean;
  125657. }, scene: Scene);
  125658. private _changeVideoMode;
  125659. /**
  125660. * Releases resources associated with this node.
  125661. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125662. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125663. */
  125664. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125665. }
  125666. }
  125667. declare module BABYLON {
  125668. /**
  125669. * This class can be used to get instrumentation data from a Babylon engine
  125670. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125671. */
  125672. export class EngineInstrumentation implements IDisposable {
  125673. /**
  125674. * Define the instrumented engine.
  125675. */
  125676. engine: Engine;
  125677. private _captureGPUFrameTime;
  125678. private _gpuFrameTimeToken;
  125679. private _gpuFrameTime;
  125680. private _captureShaderCompilationTime;
  125681. private _shaderCompilationTime;
  125682. private _onBeginFrameObserver;
  125683. private _onEndFrameObserver;
  125684. private _onBeforeShaderCompilationObserver;
  125685. private _onAfterShaderCompilationObserver;
  125686. /**
  125687. * Gets the perf counter used for GPU frame time
  125688. */
  125689. get gpuFrameTimeCounter(): PerfCounter;
  125690. /**
  125691. * Gets the GPU frame time capture status
  125692. */
  125693. get captureGPUFrameTime(): boolean;
  125694. /**
  125695. * Enable or disable the GPU frame time capture
  125696. */
  125697. set captureGPUFrameTime(value: boolean);
  125698. /**
  125699. * Gets the perf counter used for shader compilation time
  125700. */
  125701. get shaderCompilationTimeCounter(): PerfCounter;
  125702. /**
  125703. * Gets the shader compilation time capture status
  125704. */
  125705. get captureShaderCompilationTime(): boolean;
  125706. /**
  125707. * Enable or disable the shader compilation time capture
  125708. */
  125709. set captureShaderCompilationTime(value: boolean);
  125710. /**
  125711. * Instantiates a new engine instrumentation.
  125712. * This class can be used to get instrumentation data from a Babylon engine
  125713. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125714. * @param engine Defines the engine to instrument
  125715. */
  125716. constructor(
  125717. /**
  125718. * Define the instrumented engine.
  125719. */
  125720. engine: Engine);
  125721. /**
  125722. * Dispose and release associated resources.
  125723. */
  125724. dispose(): void;
  125725. }
  125726. }
  125727. declare module BABYLON {
  125728. /**
  125729. * This class can be used to get instrumentation data from a Babylon engine
  125730. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125731. */
  125732. export class SceneInstrumentation implements IDisposable {
  125733. /**
  125734. * Defines the scene to instrument
  125735. */
  125736. scene: Scene;
  125737. private _captureActiveMeshesEvaluationTime;
  125738. private _activeMeshesEvaluationTime;
  125739. private _captureRenderTargetsRenderTime;
  125740. private _renderTargetsRenderTime;
  125741. private _captureFrameTime;
  125742. private _frameTime;
  125743. private _captureRenderTime;
  125744. private _renderTime;
  125745. private _captureInterFrameTime;
  125746. private _interFrameTime;
  125747. private _captureParticlesRenderTime;
  125748. private _particlesRenderTime;
  125749. private _captureSpritesRenderTime;
  125750. private _spritesRenderTime;
  125751. private _capturePhysicsTime;
  125752. private _physicsTime;
  125753. private _captureAnimationsTime;
  125754. private _animationsTime;
  125755. private _captureCameraRenderTime;
  125756. private _cameraRenderTime;
  125757. private _onBeforeActiveMeshesEvaluationObserver;
  125758. private _onAfterActiveMeshesEvaluationObserver;
  125759. private _onBeforeRenderTargetsRenderObserver;
  125760. private _onAfterRenderTargetsRenderObserver;
  125761. private _onAfterRenderObserver;
  125762. private _onBeforeDrawPhaseObserver;
  125763. private _onAfterDrawPhaseObserver;
  125764. private _onBeforeAnimationsObserver;
  125765. private _onBeforeParticlesRenderingObserver;
  125766. private _onAfterParticlesRenderingObserver;
  125767. private _onBeforeSpritesRenderingObserver;
  125768. private _onAfterSpritesRenderingObserver;
  125769. private _onBeforePhysicsObserver;
  125770. private _onAfterPhysicsObserver;
  125771. private _onAfterAnimationsObserver;
  125772. private _onBeforeCameraRenderObserver;
  125773. private _onAfterCameraRenderObserver;
  125774. /**
  125775. * Gets the perf counter used for active meshes evaluation time
  125776. */
  125777. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125778. /**
  125779. * Gets the active meshes evaluation time capture status
  125780. */
  125781. get captureActiveMeshesEvaluationTime(): boolean;
  125782. /**
  125783. * Enable or disable the active meshes evaluation time capture
  125784. */
  125785. set captureActiveMeshesEvaluationTime(value: boolean);
  125786. /**
  125787. * Gets the perf counter used for render targets render time
  125788. */
  125789. get renderTargetsRenderTimeCounter(): PerfCounter;
  125790. /**
  125791. * Gets the render targets render time capture status
  125792. */
  125793. get captureRenderTargetsRenderTime(): boolean;
  125794. /**
  125795. * Enable or disable the render targets render time capture
  125796. */
  125797. set captureRenderTargetsRenderTime(value: boolean);
  125798. /**
  125799. * Gets the perf counter used for particles render time
  125800. */
  125801. get particlesRenderTimeCounter(): PerfCounter;
  125802. /**
  125803. * Gets the particles render time capture status
  125804. */
  125805. get captureParticlesRenderTime(): boolean;
  125806. /**
  125807. * Enable or disable the particles render time capture
  125808. */
  125809. set captureParticlesRenderTime(value: boolean);
  125810. /**
  125811. * Gets the perf counter used for sprites render time
  125812. */
  125813. get spritesRenderTimeCounter(): PerfCounter;
  125814. /**
  125815. * Gets the sprites render time capture status
  125816. */
  125817. get captureSpritesRenderTime(): boolean;
  125818. /**
  125819. * Enable or disable the sprites render time capture
  125820. */
  125821. set captureSpritesRenderTime(value: boolean);
  125822. /**
  125823. * Gets the perf counter used for physics time
  125824. */
  125825. get physicsTimeCounter(): PerfCounter;
  125826. /**
  125827. * Gets the physics time capture status
  125828. */
  125829. get capturePhysicsTime(): boolean;
  125830. /**
  125831. * Enable or disable the physics time capture
  125832. */
  125833. set capturePhysicsTime(value: boolean);
  125834. /**
  125835. * Gets the perf counter used for animations time
  125836. */
  125837. get animationsTimeCounter(): PerfCounter;
  125838. /**
  125839. * Gets the animations time capture status
  125840. */
  125841. get captureAnimationsTime(): boolean;
  125842. /**
  125843. * Enable or disable the animations time capture
  125844. */
  125845. set captureAnimationsTime(value: boolean);
  125846. /**
  125847. * Gets the perf counter used for frame time capture
  125848. */
  125849. get frameTimeCounter(): PerfCounter;
  125850. /**
  125851. * Gets the frame time capture status
  125852. */
  125853. get captureFrameTime(): boolean;
  125854. /**
  125855. * Enable or disable the frame time capture
  125856. */
  125857. set captureFrameTime(value: boolean);
  125858. /**
  125859. * Gets the perf counter used for inter-frames time capture
  125860. */
  125861. get interFrameTimeCounter(): PerfCounter;
  125862. /**
  125863. * Gets the inter-frames time capture status
  125864. */
  125865. get captureInterFrameTime(): boolean;
  125866. /**
  125867. * Enable or disable the inter-frames time capture
  125868. */
  125869. set captureInterFrameTime(value: boolean);
  125870. /**
  125871. * Gets the perf counter used for render time capture
  125872. */
  125873. get renderTimeCounter(): PerfCounter;
  125874. /**
  125875. * Gets the render time capture status
  125876. */
  125877. get captureRenderTime(): boolean;
  125878. /**
  125879. * Enable or disable the render time capture
  125880. */
  125881. set captureRenderTime(value: boolean);
  125882. /**
  125883. * Gets the perf counter used for camera render time capture
  125884. */
  125885. get cameraRenderTimeCounter(): PerfCounter;
  125886. /**
  125887. * Gets the camera render time capture status
  125888. */
  125889. get captureCameraRenderTime(): boolean;
  125890. /**
  125891. * Enable or disable the camera render time capture
  125892. */
  125893. set captureCameraRenderTime(value: boolean);
  125894. /**
  125895. * Gets the perf counter used for draw calls
  125896. */
  125897. get drawCallsCounter(): PerfCounter;
  125898. /**
  125899. * Instantiates a new scene instrumentation.
  125900. * This class can be used to get instrumentation data from a Babylon engine
  125901. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125902. * @param scene Defines the scene to instrument
  125903. */
  125904. constructor(
  125905. /**
  125906. * Defines the scene to instrument
  125907. */
  125908. scene: Scene);
  125909. /**
  125910. * Dispose and release associated resources.
  125911. */
  125912. dispose(): void;
  125913. }
  125914. }
  125915. declare module BABYLON {
  125916. /** @hidden */
  125917. export var glowMapGenerationPixelShader: {
  125918. name: string;
  125919. shader: string;
  125920. };
  125921. }
  125922. declare module BABYLON {
  125923. /** @hidden */
  125924. export var glowMapGenerationVertexShader: {
  125925. name: string;
  125926. shader: string;
  125927. };
  125928. }
  125929. declare module BABYLON {
  125930. /**
  125931. * Effect layer options. This helps customizing the behaviour
  125932. * of the effect layer.
  125933. */
  125934. export interface IEffectLayerOptions {
  125935. /**
  125936. * Multiplication factor apply to the canvas size to compute the render target size
  125937. * used to generated the objects (the smaller the faster).
  125938. */
  125939. mainTextureRatio: number;
  125940. /**
  125941. * Enforces a fixed size texture to ensure effect stability across devices.
  125942. */
  125943. mainTextureFixedSize?: number;
  125944. /**
  125945. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125946. */
  125947. alphaBlendingMode: number;
  125948. /**
  125949. * The camera attached to the layer.
  125950. */
  125951. camera: Nullable<Camera>;
  125952. /**
  125953. * The rendering group to draw the layer in.
  125954. */
  125955. renderingGroupId: number;
  125956. }
  125957. /**
  125958. * The effect layer Helps adding post process effect blended with the main pass.
  125959. *
  125960. * This can be for instance use to generate glow or higlight effects on the scene.
  125961. *
  125962. * The effect layer class can not be used directly and is intented to inherited from to be
  125963. * customized per effects.
  125964. */
  125965. export abstract class EffectLayer {
  125966. private _vertexBuffers;
  125967. private _indexBuffer;
  125968. private _cachedDefines;
  125969. private _effectLayerMapGenerationEffect;
  125970. private _effectLayerOptions;
  125971. private _mergeEffect;
  125972. protected _scene: Scene;
  125973. protected _engine: Engine;
  125974. protected _maxSize: number;
  125975. protected _mainTextureDesiredSize: ISize;
  125976. protected _mainTexture: RenderTargetTexture;
  125977. protected _shouldRender: boolean;
  125978. protected _postProcesses: PostProcess[];
  125979. protected _textures: BaseTexture[];
  125980. protected _emissiveTextureAndColor: {
  125981. texture: Nullable<BaseTexture>;
  125982. color: Color4;
  125983. };
  125984. /**
  125985. * The name of the layer
  125986. */
  125987. name: string;
  125988. /**
  125989. * The clear color of the texture used to generate the glow map.
  125990. */
  125991. neutralColor: Color4;
  125992. /**
  125993. * Specifies whether the highlight layer is enabled or not.
  125994. */
  125995. isEnabled: boolean;
  125996. /**
  125997. * Gets the camera attached to the layer.
  125998. */
  125999. get camera(): Nullable<Camera>;
  126000. /**
  126001. * Gets the rendering group id the layer should render in.
  126002. */
  126003. get renderingGroupId(): number;
  126004. set renderingGroupId(renderingGroupId: number);
  126005. /**
  126006. * An event triggered when the effect layer has been disposed.
  126007. */
  126008. onDisposeObservable: Observable<EffectLayer>;
  126009. /**
  126010. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  126011. */
  126012. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  126013. /**
  126014. * An event triggered when the generated texture is being merged in the scene.
  126015. */
  126016. onBeforeComposeObservable: Observable<EffectLayer>;
  126017. /**
  126018. * An event triggered when the mesh is rendered into the effect render target.
  126019. */
  126020. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126021. /**
  126022. * An event triggered after the mesh has been rendered into the effect render target.
  126023. */
  126024. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126025. /**
  126026. * An event triggered when the generated texture has been merged in the scene.
  126027. */
  126028. onAfterComposeObservable: Observable<EffectLayer>;
  126029. /**
  126030. * An event triggered when the efffect layer changes its size.
  126031. */
  126032. onSizeChangedObservable: Observable<EffectLayer>;
  126033. /** @hidden */
  126034. static _SceneComponentInitialization: (scene: Scene) => void;
  126035. /**
  126036. * Instantiates a new effect Layer and references it in the scene.
  126037. * @param name The name of the layer
  126038. * @param scene The scene to use the layer in
  126039. */
  126040. constructor(
  126041. /** The Friendly of the effect in the scene */
  126042. name: string, scene: Scene);
  126043. /**
  126044. * Get the effect name of the layer.
  126045. * @return The effect name
  126046. */
  126047. abstract getEffectName(): string;
  126048. /**
  126049. * Checks for the readiness of the element composing the layer.
  126050. * @param subMesh the mesh to check for
  126051. * @param useInstances specify whether or not to use instances to render the mesh
  126052. * @return true if ready otherwise, false
  126053. */
  126054. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126055. /**
  126056. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126057. * @returns true if the effect requires stencil during the main canvas render pass.
  126058. */
  126059. abstract needStencil(): boolean;
  126060. /**
  126061. * Create the merge effect. This is the shader use to blit the information back
  126062. * to the main canvas at the end of the scene rendering.
  126063. * @returns The effect containing the shader used to merge the effect on the main canvas
  126064. */
  126065. protected abstract _createMergeEffect(): Effect;
  126066. /**
  126067. * Creates the render target textures and post processes used in the effect layer.
  126068. */
  126069. protected abstract _createTextureAndPostProcesses(): void;
  126070. /**
  126071. * Implementation specific of rendering the generating effect on the main canvas.
  126072. * @param effect The effect used to render through
  126073. */
  126074. protected abstract _internalRender(effect: Effect): void;
  126075. /**
  126076. * Sets the required values for both the emissive texture and and the main color.
  126077. */
  126078. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126079. /**
  126080. * Free any resources and references associated to a mesh.
  126081. * Internal use
  126082. * @param mesh The mesh to free.
  126083. */
  126084. abstract _disposeMesh(mesh: Mesh): void;
  126085. /**
  126086. * Serializes this layer (Glow or Highlight for example)
  126087. * @returns a serialized layer object
  126088. */
  126089. abstract serialize?(): any;
  126090. /**
  126091. * Initializes the effect layer with the required options.
  126092. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126093. */
  126094. protected _init(options: Partial<IEffectLayerOptions>): void;
  126095. /**
  126096. * Generates the index buffer of the full screen quad blending to the main canvas.
  126097. */
  126098. private _generateIndexBuffer;
  126099. /**
  126100. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126101. */
  126102. private _generateVertexBuffer;
  126103. /**
  126104. * Sets the main texture desired size which is the closest power of two
  126105. * of the engine canvas size.
  126106. */
  126107. private _setMainTextureSize;
  126108. /**
  126109. * Creates the main texture for the effect layer.
  126110. */
  126111. protected _createMainTexture(): void;
  126112. /**
  126113. * Adds specific effects defines.
  126114. * @param defines The defines to add specifics to.
  126115. */
  126116. protected _addCustomEffectDefines(defines: string[]): void;
  126117. /**
  126118. * Checks for the readiness of the element composing the layer.
  126119. * @param subMesh the mesh to check for
  126120. * @param useInstances specify whether or not to use instances to render the mesh
  126121. * @param emissiveTexture the associated emissive texture used to generate the glow
  126122. * @return true if ready otherwise, false
  126123. */
  126124. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126125. /**
  126126. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126127. */
  126128. render(): void;
  126129. /**
  126130. * Determine if a given mesh will be used in the current effect.
  126131. * @param mesh mesh to test
  126132. * @returns true if the mesh will be used
  126133. */
  126134. hasMesh(mesh: AbstractMesh): boolean;
  126135. /**
  126136. * Returns true if the layer contains information to display, otherwise false.
  126137. * @returns true if the glow layer should be rendered
  126138. */
  126139. shouldRender(): boolean;
  126140. /**
  126141. * Returns true if the mesh should render, otherwise false.
  126142. * @param mesh The mesh to render
  126143. * @returns true if it should render otherwise false
  126144. */
  126145. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126146. /**
  126147. * Returns true if the mesh can be rendered, otherwise false.
  126148. * @param mesh The mesh to render
  126149. * @param material The material used on the mesh
  126150. * @returns true if it can be rendered otherwise false
  126151. */
  126152. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126153. /**
  126154. * Returns true if the mesh should render, otherwise false.
  126155. * @param mesh The mesh to render
  126156. * @returns true if it should render otherwise false
  126157. */
  126158. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126159. /**
  126160. * Renders the submesh passed in parameter to the generation map.
  126161. */
  126162. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126163. /**
  126164. * Defines whether the current material of the mesh should be use to render the effect.
  126165. * @param mesh defines the current mesh to render
  126166. */
  126167. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126168. /**
  126169. * Rebuild the required buffers.
  126170. * @hidden Internal use only.
  126171. */
  126172. _rebuild(): void;
  126173. /**
  126174. * Dispose only the render target textures and post process.
  126175. */
  126176. private _disposeTextureAndPostProcesses;
  126177. /**
  126178. * Dispose the highlight layer and free resources.
  126179. */
  126180. dispose(): void;
  126181. /**
  126182. * Gets the class name of the effect layer
  126183. * @returns the string with the class name of the effect layer
  126184. */
  126185. getClassName(): string;
  126186. /**
  126187. * Creates an effect layer from parsed effect layer data
  126188. * @param parsedEffectLayer defines effect layer data
  126189. * @param scene defines the current scene
  126190. * @param rootUrl defines the root URL containing the effect layer information
  126191. * @returns a parsed effect Layer
  126192. */
  126193. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126194. }
  126195. }
  126196. declare module BABYLON {
  126197. interface AbstractScene {
  126198. /**
  126199. * The list of effect layers (highlights/glow) added to the scene
  126200. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126201. * @see http://doc.babylonjs.com/how_to/glow_layer
  126202. */
  126203. effectLayers: Array<EffectLayer>;
  126204. /**
  126205. * Removes the given effect layer from this scene.
  126206. * @param toRemove defines the effect layer to remove
  126207. * @returns the index of the removed effect layer
  126208. */
  126209. removeEffectLayer(toRemove: EffectLayer): number;
  126210. /**
  126211. * Adds the given effect layer to this scene
  126212. * @param newEffectLayer defines the effect layer to add
  126213. */
  126214. addEffectLayer(newEffectLayer: EffectLayer): void;
  126215. }
  126216. /**
  126217. * Defines the layer scene component responsible to manage any effect layers
  126218. * in a given scene.
  126219. */
  126220. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126221. /**
  126222. * The component name helpfull to identify the component in the list of scene components.
  126223. */
  126224. readonly name: string;
  126225. /**
  126226. * The scene the component belongs to.
  126227. */
  126228. scene: Scene;
  126229. private _engine;
  126230. private _renderEffects;
  126231. private _needStencil;
  126232. private _previousStencilState;
  126233. /**
  126234. * Creates a new instance of the component for the given scene
  126235. * @param scene Defines the scene to register the component in
  126236. */
  126237. constructor(scene: Scene);
  126238. /**
  126239. * Registers the component in a given scene
  126240. */
  126241. register(): void;
  126242. /**
  126243. * Rebuilds the elements related to this component in case of
  126244. * context lost for instance.
  126245. */
  126246. rebuild(): void;
  126247. /**
  126248. * Serializes the component data to the specified json object
  126249. * @param serializationObject The object to serialize to
  126250. */
  126251. serialize(serializationObject: any): void;
  126252. /**
  126253. * Adds all the elements from the container to the scene
  126254. * @param container the container holding the elements
  126255. */
  126256. addFromContainer(container: AbstractScene): void;
  126257. /**
  126258. * Removes all the elements in the container from the scene
  126259. * @param container contains the elements to remove
  126260. * @param dispose if the removed element should be disposed (default: false)
  126261. */
  126262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126263. /**
  126264. * Disposes the component and the associated ressources.
  126265. */
  126266. dispose(): void;
  126267. private _isReadyForMesh;
  126268. private _renderMainTexture;
  126269. private _setStencil;
  126270. private _setStencilBack;
  126271. private _draw;
  126272. private _drawCamera;
  126273. private _drawRenderingGroup;
  126274. }
  126275. }
  126276. declare module BABYLON {
  126277. /** @hidden */
  126278. export var glowMapMergePixelShader: {
  126279. name: string;
  126280. shader: string;
  126281. };
  126282. }
  126283. declare module BABYLON {
  126284. /** @hidden */
  126285. export var glowMapMergeVertexShader: {
  126286. name: string;
  126287. shader: string;
  126288. };
  126289. }
  126290. declare module BABYLON {
  126291. interface AbstractScene {
  126292. /**
  126293. * Return a the first highlight layer of the scene with a given name.
  126294. * @param name The name of the highlight layer to look for.
  126295. * @return The highlight layer if found otherwise null.
  126296. */
  126297. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126298. }
  126299. /**
  126300. * Glow layer options. This helps customizing the behaviour
  126301. * of the glow layer.
  126302. */
  126303. export interface IGlowLayerOptions {
  126304. /**
  126305. * Multiplication factor apply to the canvas size to compute the render target size
  126306. * used to generated the glowing objects (the smaller the faster).
  126307. */
  126308. mainTextureRatio: number;
  126309. /**
  126310. * Enforces a fixed size texture to ensure resize independant blur.
  126311. */
  126312. mainTextureFixedSize?: number;
  126313. /**
  126314. * How big is the kernel of the blur texture.
  126315. */
  126316. blurKernelSize: number;
  126317. /**
  126318. * The camera attached to the layer.
  126319. */
  126320. camera: Nullable<Camera>;
  126321. /**
  126322. * Enable MSAA by chosing the number of samples.
  126323. */
  126324. mainTextureSamples?: number;
  126325. /**
  126326. * The rendering group to draw the layer in.
  126327. */
  126328. renderingGroupId: number;
  126329. }
  126330. /**
  126331. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126332. *
  126333. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126334. *
  126335. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126336. */
  126337. export class GlowLayer extends EffectLayer {
  126338. /**
  126339. * Effect Name of the layer.
  126340. */
  126341. static readonly EffectName: string;
  126342. /**
  126343. * The default blur kernel size used for the glow.
  126344. */
  126345. static DefaultBlurKernelSize: number;
  126346. /**
  126347. * The default texture size ratio used for the glow.
  126348. */
  126349. static DefaultTextureRatio: number;
  126350. /**
  126351. * Sets the kernel size of the blur.
  126352. */
  126353. set blurKernelSize(value: number);
  126354. /**
  126355. * Gets the kernel size of the blur.
  126356. */
  126357. get blurKernelSize(): number;
  126358. /**
  126359. * Sets the glow intensity.
  126360. */
  126361. set intensity(value: number);
  126362. /**
  126363. * Gets the glow intensity.
  126364. */
  126365. get intensity(): number;
  126366. private _options;
  126367. private _intensity;
  126368. private _horizontalBlurPostprocess1;
  126369. private _verticalBlurPostprocess1;
  126370. private _horizontalBlurPostprocess2;
  126371. private _verticalBlurPostprocess2;
  126372. private _blurTexture1;
  126373. private _blurTexture2;
  126374. private _postProcesses1;
  126375. private _postProcesses2;
  126376. private _includedOnlyMeshes;
  126377. private _excludedMeshes;
  126378. private _meshesUsingTheirOwnMaterials;
  126379. /**
  126380. * Callback used to let the user override the color selection on a per mesh basis
  126381. */
  126382. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126383. /**
  126384. * Callback used to let the user override the texture selection on a per mesh basis
  126385. */
  126386. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126387. /**
  126388. * Instantiates a new glow Layer and references it to the scene.
  126389. * @param name The name of the layer
  126390. * @param scene The scene to use the layer in
  126391. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126392. */
  126393. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126394. /**
  126395. * Get the effect name of the layer.
  126396. * @return The effect name
  126397. */
  126398. getEffectName(): string;
  126399. /**
  126400. * Create the merge effect. This is the shader use to blit the information back
  126401. * to the main canvas at the end of the scene rendering.
  126402. */
  126403. protected _createMergeEffect(): Effect;
  126404. /**
  126405. * Creates the render target textures and post processes used in the glow layer.
  126406. */
  126407. protected _createTextureAndPostProcesses(): void;
  126408. /**
  126409. * Checks for the readiness of the element composing the layer.
  126410. * @param subMesh the mesh to check for
  126411. * @param useInstances specify wether or not to use instances to render the mesh
  126412. * @param emissiveTexture the associated emissive texture used to generate the glow
  126413. * @return true if ready otherwise, false
  126414. */
  126415. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126416. /**
  126417. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126418. */
  126419. needStencil(): boolean;
  126420. /**
  126421. * Returns true if the mesh can be rendered, otherwise false.
  126422. * @param mesh The mesh to render
  126423. * @param material The material used on the mesh
  126424. * @returns true if it can be rendered otherwise false
  126425. */
  126426. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126427. /**
  126428. * Implementation specific of rendering the generating effect on the main canvas.
  126429. * @param effect The effect used to render through
  126430. */
  126431. protected _internalRender(effect: Effect): void;
  126432. /**
  126433. * Sets the required values for both the emissive texture and and the main color.
  126434. */
  126435. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126436. /**
  126437. * Returns true if the mesh should render, otherwise false.
  126438. * @param mesh The mesh to render
  126439. * @returns true if it should render otherwise false
  126440. */
  126441. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126442. /**
  126443. * Adds specific effects defines.
  126444. * @param defines The defines to add specifics to.
  126445. */
  126446. protected _addCustomEffectDefines(defines: string[]): void;
  126447. /**
  126448. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126449. * @param mesh The mesh to exclude from the glow layer
  126450. */
  126451. addExcludedMesh(mesh: Mesh): void;
  126452. /**
  126453. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126454. * @param mesh The mesh to remove
  126455. */
  126456. removeExcludedMesh(mesh: Mesh): void;
  126457. /**
  126458. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126459. * @param mesh The mesh to include in the glow layer
  126460. */
  126461. addIncludedOnlyMesh(mesh: Mesh): void;
  126462. /**
  126463. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126464. * @param mesh The mesh to remove
  126465. */
  126466. removeIncludedOnlyMesh(mesh: Mesh): void;
  126467. /**
  126468. * Determine if a given mesh will be used in the glow layer
  126469. * @param mesh The mesh to test
  126470. * @returns true if the mesh will be highlighted by the current glow layer
  126471. */
  126472. hasMesh(mesh: AbstractMesh): boolean;
  126473. /**
  126474. * Defines whether the current material of the mesh should be use to render the effect.
  126475. * @param mesh defines the current mesh to render
  126476. */
  126477. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126478. /**
  126479. * Add a mesh to be rendered through its own material and not with emissive only.
  126480. * @param mesh The mesh for which we need to use its material
  126481. */
  126482. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126483. /**
  126484. * Remove a mesh from being rendered through its own material and not with emissive only.
  126485. * @param mesh The mesh for which we need to not use its material
  126486. */
  126487. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126488. /**
  126489. * Free any resources and references associated to a mesh.
  126490. * Internal use
  126491. * @param mesh The mesh to free.
  126492. * @hidden
  126493. */
  126494. _disposeMesh(mesh: Mesh): void;
  126495. /**
  126496. * Gets the class name of the effect layer
  126497. * @returns the string with the class name of the effect layer
  126498. */
  126499. getClassName(): string;
  126500. /**
  126501. * Serializes this glow layer
  126502. * @returns a serialized glow layer object
  126503. */
  126504. serialize(): any;
  126505. /**
  126506. * Creates a Glow Layer from parsed glow layer data
  126507. * @param parsedGlowLayer defines glow layer data
  126508. * @param scene defines the current scene
  126509. * @param rootUrl defines the root URL containing the glow layer information
  126510. * @returns a parsed Glow Layer
  126511. */
  126512. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126513. }
  126514. }
  126515. declare module BABYLON {
  126516. /** @hidden */
  126517. export var glowBlurPostProcessPixelShader: {
  126518. name: string;
  126519. shader: string;
  126520. };
  126521. }
  126522. declare module BABYLON {
  126523. interface AbstractScene {
  126524. /**
  126525. * Return a the first highlight layer of the scene with a given name.
  126526. * @param name The name of the highlight layer to look for.
  126527. * @return The highlight layer if found otherwise null.
  126528. */
  126529. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126530. }
  126531. /**
  126532. * Highlight layer options. This helps customizing the behaviour
  126533. * of the highlight layer.
  126534. */
  126535. export interface IHighlightLayerOptions {
  126536. /**
  126537. * Multiplication factor apply to the canvas size to compute the render target size
  126538. * used to generated the glowing objects (the smaller the faster).
  126539. */
  126540. mainTextureRatio: number;
  126541. /**
  126542. * Enforces a fixed size texture to ensure resize independant blur.
  126543. */
  126544. mainTextureFixedSize?: number;
  126545. /**
  126546. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126547. * of the picture to blur (the smaller the faster).
  126548. */
  126549. blurTextureSizeRatio: number;
  126550. /**
  126551. * How big in texel of the blur texture is the vertical blur.
  126552. */
  126553. blurVerticalSize: number;
  126554. /**
  126555. * How big in texel of the blur texture is the horizontal blur.
  126556. */
  126557. blurHorizontalSize: number;
  126558. /**
  126559. * Alpha blending mode used to apply the blur. Default is combine.
  126560. */
  126561. alphaBlendingMode: number;
  126562. /**
  126563. * The camera attached to the layer.
  126564. */
  126565. camera: Nullable<Camera>;
  126566. /**
  126567. * Should we display highlight as a solid stroke?
  126568. */
  126569. isStroke?: boolean;
  126570. /**
  126571. * The rendering group to draw the layer in.
  126572. */
  126573. renderingGroupId: number;
  126574. }
  126575. /**
  126576. * The highlight layer Helps adding a glow effect around a mesh.
  126577. *
  126578. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126579. * glowy meshes to your scene.
  126580. *
  126581. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126582. */
  126583. export class HighlightLayer extends EffectLayer {
  126584. name: string;
  126585. /**
  126586. * Effect Name of the highlight layer.
  126587. */
  126588. static readonly EffectName: string;
  126589. /**
  126590. * The neutral color used during the preparation of the glow effect.
  126591. * This is black by default as the blend operation is a blend operation.
  126592. */
  126593. static NeutralColor: Color4;
  126594. /**
  126595. * Stencil value used for glowing meshes.
  126596. */
  126597. static GlowingMeshStencilReference: number;
  126598. /**
  126599. * Stencil value used for the other meshes in the scene.
  126600. */
  126601. static NormalMeshStencilReference: number;
  126602. /**
  126603. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126604. */
  126605. innerGlow: boolean;
  126606. /**
  126607. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126608. */
  126609. outerGlow: boolean;
  126610. /**
  126611. * Specifies the horizontal size of the blur.
  126612. */
  126613. set blurHorizontalSize(value: number);
  126614. /**
  126615. * Specifies the vertical size of the blur.
  126616. */
  126617. set blurVerticalSize(value: number);
  126618. /**
  126619. * Gets the horizontal size of the blur.
  126620. */
  126621. get blurHorizontalSize(): number;
  126622. /**
  126623. * Gets the vertical size of the blur.
  126624. */
  126625. get blurVerticalSize(): number;
  126626. /**
  126627. * An event triggered when the highlight layer is being blurred.
  126628. */
  126629. onBeforeBlurObservable: Observable<HighlightLayer>;
  126630. /**
  126631. * An event triggered when the highlight layer has been blurred.
  126632. */
  126633. onAfterBlurObservable: Observable<HighlightLayer>;
  126634. private _instanceGlowingMeshStencilReference;
  126635. private _options;
  126636. private _downSamplePostprocess;
  126637. private _horizontalBlurPostprocess;
  126638. private _verticalBlurPostprocess;
  126639. private _blurTexture;
  126640. private _meshes;
  126641. private _excludedMeshes;
  126642. /**
  126643. * Instantiates a new highlight Layer and references it to the scene..
  126644. * @param name The name of the layer
  126645. * @param scene The scene to use the layer in
  126646. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126647. */
  126648. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126649. /**
  126650. * Get the effect name of the layer.
  126651. * @return The effect name
  126652. */
  126653. getEffectName(): string;
  126654. /**
  126655. * Create the merge effect. This is the shader use to blit the information back
  126656. * to the main canvas at the end of the scene rendering.
  126657. */
  126658. protected _createMergeEffect(): Effect;
  126659. /**
  126660. * Creates the render target textures and post processes used in the highlight layer.
  126661. */
  126662. protected _createTextureAndPostProcesses(): void;
  126663. /**
  126664. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126665. */
  126666. needStencil(): boolean;
  126667. /**
  126668. * Checks for the readiness of the element composing the layer.
  126669. * @param subMesh the mesh to check for
  126670. * @param useInstances specify wether or not to use instances to render the mesh
  126671. * @param emissiveTexture the associated emissive texture used to generate the glow
  126672. * @return true if ready otherwise, false
  126673. */
  126674. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126675. /**
  126676. * Implementation specific of rendering the generating effect on the main canvas.
  126677. * @param effect The effect used to render through
  126678. */
  126679. protected _internalRender(effect: Effect): void;
  126680. /**
  126681. * Returns true if the layer contains information to display, otherwise false.
  126682. */
  126683. shouldRender(): boolean;
  126684. /**
  126685. * Returns true if the mesh should render, otherwise false.
  126686. * @param mesh The mesh to render
  126687. * @returns true if it should render otherwise false
  126688. */
  126689. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126690. /**
  126691. * Sets the required values for both the emissive texture and and the main color.
  126692. */
  126693. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126694. /**
  126695. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126696. * @param mesh The mesh to exclude from the highlight layer
  126697. */
  126698. addExcludedMesh(mesh: Mesh): void;
  126699. /**
  126700. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126701. * @param mesh The mesh to highlight
  126702. */
  126703. removeExcludedMesh(mesh: Mesh): void;
  126704. /**
  126705. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126706. * @param mesh mesh to test
  126707. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126708. */
  126709. hasMesh(mesh: AbstractMesh): boolean;
  126710. /**
  126711. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126712. * @param mesh The mesh to highlight
  126713. * @param color The color of the highlight
  126714. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126715. */
  126716. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126717. /**
  126718. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126719. * @param mesh The mesh to highlight
  126720. */
  126721. removeMesh(mesh: Mesh): void;
  126722. /**
  126723. * Remove all the meshes currently referenced in the highlight layer
  126724. */
  126725. removeAllMeshes(): void;
  126726. /**
  126727. * Force the stencil to the normal expected value for none glowing parts
  126728. */
  126729. private _defaultStencilReference;
  126730. /**
  126731. * Free any resources and references associated to a mesh.
  126732. * Internal use
  126733. * @param mesh The mesh to free.
  126734. * @hidden
  126735. */
  126736. _disposeMesh(mesh: Mesh): void;
  126737. /**
  126738. * Dispose the highlight layer and free resources.
  126739. */
  126740. dispose(): void;
  126741. /**
  126742. * Gets the class name of the effect layer
  126743. * @returns the string with the class name of the effect layer
  126744. */
  126745. getClassName(): string;
  126746. /**
  126747. * Serializes this Highlight layer
  126748. * @returns a serialized Highlight layer object
  126749. */
  126750. serialize(): any;
  126751. /**
  126752. * Creates a Highlight layer from parsed Highlight layer data
  126753. * @param parsedHightlightLayer defines the Highlight layer data
  126754. * @param scene defines the current scene
  126755. * @param rootUrl defines the root URL containing the Highlight layer information
  126756. * @returns a parsed Highlight layer
  126757. */
  126758. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126759. }
  126760. }
  126761. declare module BABYLON {
  126762. interface AbstractScene {
  126763. /**
  126764. * The list of layers (background and foreground) of the scene
  126765. */
  126766. layers: Array<Layer>;
  126767. }
  126768. /**
  126769. * Defines the layer scene component responsible to manage any layers
  126770. * in a given scene.
  126771. */
  126772. export class LayerSceneComponent implements ISceneComponent {
  126773. /**
  126774. * The component name helpfull to identify the component in the list of scene components.
  126775. */
  126776. readonly name: string;
  126777. /**
  126778. * The scene the component belongs to.
  126779. */
  126780. scene: Scene;
  126781. private _engine;
  126782. /**
  126783. * Creates a new instance of the component for the given scene
  126784. * @param scene Defines the scene to register the component in
  126785. */
  126786. constructor(scene: Scene);
  126787. /**
  126788. * Registers the component in a given scene
  126789. */
  126790. register(): void;
  126791. /**
  126792. * Rebuilds the elements related to this component in case of
  126793. * context lost for instance.
  126794. */
  126795. rebuild(): void;
  126796. /**
  126797. * Disposes the component and the associated ressources.
  126798. */
  126799. dispose(): void;
  126800. private _draw;
  126801. private _drawCameraPredicate;
  126802. private _drawCameraBackground;
  126803. private _drawCameraForeground;
  126804. private _drawRenderTargetPredicate;
  126805. private _drawRenderTargetBackground;
  126806. private _drawRenderTargetForeground;
  126807. /**
  126808. * Adds all the elements from the container to the scene
  126809. * @param container the container holding the elements
  126810. */
  126811. addFromContainer(container: AbstractScene): void;
  126812. /**
  126813. * Removes all the elements in the container from the scene
  126814. * @param container contains the elements to remove
  126815. * @param dispose if the removed element should be disposed (default: false)
  126816. */
  126817. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126818. }
  126819. }
  126820. declare module BABYLON {
  126821. /** @hidden */
  126822. export var layerPixelShader: {
  126823. name: string;
  126824. shader: string;
  126825. };
  126826. }
  126827. declare module BABYLON {
  126828. /** @hidden */
  126829. export var layerVertexShader: {
  126830. name: string;
  126831. shader: string;
  126832. };
  126833. }
  126834. declare module BABYLON {
  126835. /**
  126836. * This represents a full screen 2d layer.
  126837. * This can be useful to display a picture in the background of your scene for instance.
  126838. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126839. */
  126840. export class Layer {
  126841. /**
  126842. * Define the name of the layer.
  126843. */
  126844. name: string;
  126845. /**
  126846. * Define the texture the layer should display.
  126847. */
  126848. texture: Nullable<Texture>;
  126849. /**
  126850. * Is the layer in background or foreground.
  126851. */
  126852. isBackground: boolean;
  126853. /**
  126854. * Define the color of the layer (instead of texture).
  126855. */
  126856. color: Color4;
  126857. /**
  126858. * Define the scale of the layer in order to zoom in out of the texture.
  126859. */
  126860. scale: Vector2;
  126861. /**
  126862. * Define an offset for the layer in order to shift the texture.
  126863. */
  126864. offset: Vector2;
  126865. /**
  126866. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126867. */
  126868. alphaBlendingMode: number;
  126869. /**
  126870. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126871. * Alpha test will not mix with the background color in case of transparency.
  126872. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126873. */
  126874. alphaTest: boolean;
  126875. /**
  126876. * Define a mask to restrict the layer to only some of the scene cameras.
  126877. */
  126878. layerMask: number;
  126879. /**
  126880. * Define the list of render target the layer is visible into.
  126881. */
  126882. renderTargetTextures: RenderTargetTexture[];
  126883. /**
  126884. * Define if the layer is only used in renderTarget or if it also
  126885. * renders in the main frame buffer of the canvas.
  126886. */
  126887. renderOnlyInRenderTargetTextures: boolean;
  126888. private _scene;
  126889. private _vertexBuffers;
  126890. private _indexBuffer;
  126891. private _effect;
  126892. private _previousDefines;
  126893. /**
  126894. * An event triggered when the layer is disposed.
  126895. */
  126896. onDisposeObservable: Observable<Layer>;
  126897. private _onDisposeObserver;
  126898. /**
  126899. * Back compatibility with callback before the onDisposeObservable existed.
  126900. * The set callback will be triggered when the layer has been disposed.
  126901. */
  126902. set onDispose(callback: () => void);
  126903. /**
  126904. * An event triggered before rendering the scene
  126905. */
  126906. onBeforeRenderObservable: Observable<Layer>;
  126907. private _onBeforeRenderObserver;
  126908. /**
  126909. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126910. * The set callback will be triggered just before rendering the layer.
  126911. */
  126912. set onBeforeRender(callback: () => void);
  126913. /**
  126914. * An event triggered after rendering the scene
  126915. */
  126916. onAfterRenderObservable: Observable<Layer>;
  126917. private _onAfterRenderObserver;
  126918. /**
  126919. * Back compatibility with callback before the onAfterRenderObservable existed.
  126920. * The set callback will be triggered just after rendering the layer.
  126921. */
  126922. set onAfterRender(callback: () => void);
  126923. /**
  126924. * Instantiates a new layer.
  126925. * This represents a full screen 2d layer.
  126926. * This can be useful to display a picture in the background of your scene for instance.
  126927. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126928. * @param name Define the name of the layer in the scene
  126929. * @param imgUrl Define the url of the texture to display in the layer
  126930. * @param scene Define the scene the layer belongs to
  126931. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126932. * @param color Defines a color for the layer
  126933. */
  126934. constructor(
  126935. /**
  126936. * Define the name of the layer.
  126937. */
  126938. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126939. private _createIndexBuffer;
  126940. /** @hidden */
  126941. _rebuild(): void;
  126942. /**
  126943. * Renders the layer in the scene.
  126944. */
  126945. render(): void;
  126946. /**
  126947. * Disposes and releases the associated ressources.
  126948. */
  126949. dispose(): void;
  126950. }
  126951. }
  126952. declare module BABYLON {
  126953. /** @hidden */
  126954. export var lensFlarePixelShader: {
  126955. name: string;
  126956. shader: string;
  126957. };
  126958. }
  126959. declare module BABYLON {
  126960. /** @hidden */
  126961. export var lensFlareVertexShader: {
  126962. name: string;
  126963. shader: string;
  126964. };
  126965. }
  126966. declare module BABYLON {
  126967. /**
  126968. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126969. * It is usually composed of several `lensFlare`.
  126970. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126971. */
  126972. export class LensFlareSystem {
  126973. /**
  126974. * Define the name of the lens flare system
  126975. */
  126976. name: string;
  126977. /**
  126978. * List of lens flares used in this system.
  126979. */
  126980. lensFlares: LensFlare[];
  126981. /**
  126982. * Define a limit from the border the lens flare can be visible.
  126983. */
  126984. borderLimit: number;
  126985. /**
  126986. * Define a viewport border we do not want to see the lens flare in.
  126987. */
  126988. viewportBorder: number;
  126989. /**
  126990. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126991. */
  126992. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126993. /**
  126994. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126995. */
  126996. layerMask: number;
  126997. /**
  126998. * Define the id of the lens flare system in the scene.
  126999. * (equal to name by default)
  127000. */
  127001. id: string;
  127002. private _scene;
  127003. private _emitter;
  127004. private _vertexBuffers;
  127005. private _indexBuffer;
  127006. private _effect;
  127007. private _positionX;
  127008. private _positionY;
  127009. private _isEnabled;
  127010. /** @hidden */
  127011. static _SceneComponentInitialization: (scene: Scene) => void;
  127012. /**
  127013. * Instantiates a lens flare system.
  127014. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127015. * It is usually composed of several `lensFlare`.
  127016. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127017. * @param name Define the name of the lens flare system in the scene
  127018. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  127019. * @param scene Define the scene the lens flare system belongs to
  127020. */
  127021. constructor(
  127022. /**
  127023. * Define the name of the lens flare system
  127024. */
  127025. name: string, emitter: any, scene: Scene);
  127026. /**
  127027. * Define if the lens flare system is enabled.
  127028. */
  127029. get isEnabled(): boolean;
  127030. set isEnabled(value: boolean);
  127031. /**
  127032. * Get the scene the effects belongs to.
  127033. * @returns the scene holding the lens flare system
  127034. */
  127035. getScene(): Scene;
  127036. /**
  127037. * Get the emitter of the lens flare system.
  127038. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127039. * @returns the emitter of the lens flare system
  127040. */
  127041. getEmitter(): any;
  127042. /**
  127043. * Set the emitter of the lens flare system.
  127044. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127045. * @param newEmitter Define the new emitter of the system
  127046. */
  127047. setEmitter(newEmitter: any): void;
  127048. /**
  127049. * Get the lens flare system emitter position.
  127050. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127051. * @returns the position
  127052. */
  127053. getEmitterPosition(): Vector3;
  127054. /**
  127055. * @hidden
  127056. */
  127057. computeEffectivePosition(globalViewport: Viewport): boolean;
  127058. /** @hidden */
  127059. _isVisible(): boolean;
  127060. /**
  127061. * @hidden
  127062. */
  127063. render(): boolean;
  127064. /**
  127065. * Dispose and release the lens flare with its associated resources.
  127066. */
  127067. dispose(): void;
  127068. /**
  127069. * Parse a lens flare system from a JSON repressentation
  127070. * @param parsedLensFlareSystem Define the JSON to parse
  127071. * @param scene Define the scene the parsed system should be instantiated in
  127072. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127073. * @returns the parsed system
  127074. */
  127075. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127076. /**
  127077. * Serialize the current Lens Flare System into a JSON representation.
  127078. * @returns the serialized JSON
  127079. */
  127080. serialize(): any;
  127081. }
  127082. }
  127083. declare module BABYLON {
  127084. /**
  127085. * This represents one of the lens effect in a `lensFlareSystem`.
  127086. * It controls one of the indiviual texture used in the effect.
  127087. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127088. */
  127089. export class LensFlare {
  127090. /**
  127091. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127092. */
  127093. size: number;
  127094. /**
  127095. * 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. */
  127097. position: number;
  127098. /**
  127099. * Define the lens color.
  127100. */
  127101. color: Color3;
  127102. /**
  127103. * Define the lens texture.
  127104. */
  127105. texture: Nullable<Texture>;
  127106. /**
  127107. * Define the alpha mode to render this particular lens.
  127108. */
  127109. alphaMode: number;
  127110. private _system;
  127111. /**
  127112. * Creates a new Lens Flare.
  127113. * This represents one of the lens effect in a `lensFlareSystem`.
  127114. * It controls one of the indiviual texture used in the effect.
  127115. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127116. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127117. * @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.
  127118. * @param color Define the lens color
  127119. * @param imgUrl Define the lens texture url
  127120. * @param system Define the `lensFlareSystem` this flare is part of
  127121. * @returns The newly created Lens Flare
  127122. */
  127123. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127124. /**
  127125. * Instantiates a new Lens Flare.
  127126. * This represents one of the lens effect in a `lensFlareSystem`.
  127127. * It controls one of the indiviual texture used in the effect.
  127128. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127129. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127130. * @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.
  127131. * @param color Define the lens color
  127132. * @param imgUrl Define the lens texture url
  127133. * @param system Define the `lensFlareSystem` this flare is part of
  127134. */
  127135. constructor(
  127136. /**
  127137. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127138. */
  127139. size: number,
  127140. /**
  127141. * 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.
  127142. */
  127143. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127144. /**
  127145. * Dispose and release the lens flare with its associated resources.
  127146. */
  127147. dispose(): void;
  127148. }
  127149. }
  127150. declare module BABYLON {
  127151. interface AbstractScene {
  127152. /**
  127153. * The list of lens flare system added to the scene
  127154. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127155. */
  127156. lensFlareSystems: Array<LensFlareSystem>;
  127157. /**
  127158. * Removes the given lens flare system from this scene.
  127159. * @param toRemove The lens flare system to remove
  127160. * @returns The index of the removed lens flare system
  127161. */
  127162. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127163. /**
  127164. * Adds the given lens flare system to this scene
  127165. * @param newLensFlareSystem The lens flare system to add
  127166. */
  127167. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127168. /**
  127169. * Gets a lens flare system using its name
  127170. * @param name defines the name to look for
  127171. * @returns the lens flare system or null if not found
  127172. */
  127173. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127174. /**
  127175. * Gets a lens flare system using its id
  127176. * @param id defines the id to look for
  127177. * @returns the lens flare system or null if not found
  127178. */
  127179. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127180. }
  127181. /**
  127182. * Defines the lens flare scene component responsible to manage any lens flares
  127183. * in a given scene.
  127184. */
  127185. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127186. /**
  127187. * The component name helpfull to identify the component in the list of scene components.
  127188. */
  127189. readonly name: string;
  127190. /**
  127191. * The scene the component belongs to.
  127192. */
  127193. scene: Scene;
  127194. /**
  127195. * Creates a new instance of the component for the given scene
  127196. * @param scene Defines the scene to register the component in
  127197. */
  127198. constructor(scene: Scene);
  127199. /**
  127200. * Registers the component in a given scene
  127201. */
  127202. register(): void;
  127203. /**
  127204. * Rebuilds the elements related to this component in case of
  127205. * context lost for instance.
  127206. */
  127207. rebuild(): void;
  127208. /**
  127209. * Adds all the elements from the container to the scene
  127210. * @param container the container holding the elements
  127211. */
  127212. addFromContainer(container: AbstractScene): void;
  127213. /**
  127214. * Removes all the elements in the container from the scene
  127215. * @param container contains the elements to remove
  127216. * @param dispose if the removed element should be disposed (default: false)
  127217. */
  127218. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127219. /**
  127220. * Serializes the component data to the specified json object
  127221. * @param serializationObject The object to serialize to
  127222. */
  127223. serialize(serializationObject: any): void;
  127224. /**
  127225. * Disposes the component and the associated ressources.
  127226. */
  127227. dispose(): void;
  127228. private _draw;
  127229. }
  127230. }
  127231. declare module BABYLON {
  127232. /** @hidden */
  127233. export var depthPixelShader: {
  127234. name: string;
  127235. shader: string;
  127236. };
  127237. }
  127238. declare module BABYLON {
  127239. /** @hidden */
  127240. export var depthVertexShader: {
  127241. name: string;
  127242. shader: string;
  127243. };
  127244. }
  127245. declare module BABYLON {
  127246. /**
  127247. * This represents a depth renderer in Babylon.
  127248. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127249. */
  127250. export class DepthRenderer {
  127251. private _scene;
  127252. private _depthMap;
  127253. private _effect;
  127254. private readonly _storeNonLinearDepth;
  127255. private readonly _clearColor;
  127256. /** Get if the depth renderer is using packed depth or not */
  127257. readonly isPacked: boolean;
  127258. private _cachedDefines;
  127259. private _camera;
  127260. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127261. enabled: boolean;
  127262. /**
  127263. * Specifiess that the depth renderer will only be used within
  127264. * the camera it is created for.
  127265. * This can help forcing its rendering during the camera processing.
  127266. */
  127267. useOnlyInActiveCamera: boolean;
  127268. /** @hidden */
  127269. static _SceneComponentInitialization: (scene: Scene) => void;
  127270. /**
  127271. * Instantiates a depth renderer
  127272. * @param scene The scene the renderer belongs to
  127273. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127274. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127275. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127276. */
  127277. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127278. /**
  127279. * Creates the depth rendering effect and checks if the effect is ready.
  127280. * @param subMesh The submesh to be used to render the depth map of
  127281. * @param useInstances If multiple world instances should be used
  127282. * @returns if the depth renderer is ready to render the depth map
  127283. */
  127284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127285. /**
  127286. * Gets the texture which the depth map will be written to.
  127287. * @returns The depth map texture
  127288. */
  127289. getDepthMap(): RenderTargetTexture;
  127290. /**
  127291. * Disposes of the depth renderer.
  127292. */
  127293. dispose(): void;
  127294. }
  127295. }
  127296. declare module BABYLON {
  127297. /** @hidden */
  127298. export var minmaxReduxPixelShader: {
  127299. name: string;
  127300. shader: string;
  127301. };
  127302. }
  127303. declare module BABYLON {
  127304. /**
  127305. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127306. * and maximum values from all values of the texture.
  127307. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127308. * The source values are read from the red channel of the texture.
  127309. */
  127310. export class MinMaxReducer {
  127311. /**
  127312. * Observable triggered when the computation has been performed
  127313. */
  127314. onAfterReductionPerformed: Observable<{
  127315. min: number;
  127316. max: number;
  127317. }>;
  127318. protected _camera: Camera;
  127319. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127320. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127321. protected _postProcessManager: PostProcessManager;
  127322. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127323. protected _forceFullscreenViewport: boolean;
  127324. /**
  127325. * Creates a min/max reducer
  127326. * @param camera The camera to use for the post processes
  127327. */
  127328. constructor(camera: Camera);
  127329. /**
  127330. * Gets the texture used to read the values from.
  127331. */
  127332. get sourceTexture(): Nullable<RenderTargetTexture>;
  127333. /**
  127334. * Sets the source texture to read the values from.
  127335. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127336. * because in such textures '1' value must not be taken into account to compute the maximum
  127337. * as this value is used to clear the texture.
  127338. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127339. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127340. * @param depthRedux Indicates if the texture is a depth texture or not
  127341. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127342. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127343. */
  127344. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127345. /**
  127346. * Defines the refresh rate of the computation.
  127347. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127348. */
  127349. get refreshRate(): number;
  127350. set refreshRate(value: number);
  127351. protected _activated: boolean;
  127352. /**
  127353. * Gets the activation status of the reducer
  127354. */
  127355. get activated(): boolean;
  127356. /**
  127357. * Activates the reduction computation.
  127358. * When activated, the observers registered in onAfterReductionPerformed are
  127359. * called after the compuation is performed
  127360. */
  127361. activate(): void;
  127362. /**
  127363. * Deactivates the reduction computation.
  127364. */
  127365. deactivate(): void;
  127366. /**
  127367. * Disposes the min/max reducer
  127368. * @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.
  127369. */
  127370. dispose(disposeAll?: boolean): void;
  127371. }
  127372. }
  127373. declare module BABYLON {
  127374. /**
  127375. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127376. */
  127377. export class DepthReducer extends MinMaxReducer {
  127378. private _depthRenderer;
  127379. private _depthRendererId;
  127380. /**
  127381. * Gets the depth renderer used for the computation.
  127382. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127383. */
  127384. get depthRenderer(): Nullable<DepthRenderer>;
  127385. /**
  127386. * Creates a depth reducer
  127387. * @param camera The camera used to render the depth texture
  127388. */
  127389. constructor(camera: Camera);
  127390. /**
  127391. * Sets the depth renderer to use to generate the depth map
  127392. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127393. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127394. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127395. */
  127396. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127397. /** @hidden */
  127398. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127399. /**
  127400. * Activates the reduction computation.
  127401. * When activated, the observers registered in onAfterReductionPerformed are
  127402. * called after the compuation is performed
  127403. */
  127404. activate(): void;
  127405. /**
  127406. * Deactivates the reduction computation.
  127407. */
  127408. deactivate(): void;
  127409. /**
  127410. * Disposes the depth reducer
  127411. * @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.
  127412. */
  127413. dispose(disposeAll?: boolean): void;
  127414. }
  127415. }
  127416. declare module BABYLON {
  127417. /**
  127418. * A CSM implementation allowing casting shadows on large scenes.
  127419. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127420. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127421. */
  127422. export class CascadedShadowGenerator extends ShadowGenerator {
  127423. private static readonly frustumCornersNDCSpace;
  127424. /**
  127425. * Name of the CSM class
  127426. */
  127427. static CLASSNAME: string;
  127428. /**
  127429. * Defines the default number of cascades used by the CSM.
  127430. */
  127431. static readonly DEFAULT_CASCADES_COUNT: number;
  127432. /**
  127433. * Defines the minimum number of cascades used by the CSM.
  127434. */
  127435. static readonly MIN_CASCADES_COUNT: number;
  127436. /**
  127437. * Defines the maximum number of cascades used by the CSM.
  127438. */
  127439. static readonly MAX_CASCADES_COUNT: number;
  127440. protected _validateFilter(filter: number): number;
  127441. /**
  127442. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127443. */
  127444. penumbraDarkness: number;
  127445. private _numCascades;
  127446. /**
  127447. * Gets or set the number of cascades used by the CSM.
  127448. */
  127449. get numCascades(): number;
  127450. set numCascades(value: number);
  127451. /**
  127452. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127453. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127454. */
  127455. stabilizeCascades: boolean;
  127456. private _freezeShadowCastersBoundingInfo;
  127457. private _freezeShadowCastersBoundingInfoObservable;
  127458. /**
  127459. * Enables or disables the shadow casters bounding info computation.
  127460. * If your shadow casters don't move, you can disable this feature.
  127461. * If it is enabled, the bounding box computation is done every frame.
  127462. */
  127463. get freezeShadowCastersBoundingInfo(): boolean;
  127464. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127465. private _scbiMin;
  127466. private _scbiMax;
  127467. protected _computeShadowCastersBoundingInfo(): void;
  127468. protected _shadowCastersBoundingInfo: BoundingInfo;
  127469. /**
  127470. * Gets or sets the shadow casters bounding info.
  127471. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127472. * so that the system won't overwrite the bounds you provide
  127473. */
  127474. get shadowCastersBoundingInfo(): BoundingInfo;
  127475. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127476. protected _breaksAreDirty: boolean;
  127477. protected _minDistance: number;
  127478. protected _maxDistance: number;
  127479. /**
  127480. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127481. *
  127482. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127483. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127484. * @param min minimal distance for the breaks (default to 0.)
  127485. * @param max maximal distance for the breaks (default to 1.)
  127486. */
  127487. setMinMaxDistance(min: number, max: number): void;
  127488. /** Gets the minimal distance used in the cascade break computation */
  127489. get minDistance(): number;
  127490. /** Gets the maximal distance used in the cascade break computation */
  127491. get maxDistance(): number;
  127492. /**
  127493. * Gets the class name of that object
  127494. * @returns "CascadedShadowGenerator"
  127495. */
  127496. getClassName(): string;
  127497. private _cascadeMinExtents;
  127498. private _cascadeMaxExtents;
  127499. /**
  127500. * Gets a cascade minimum extents
  127501. * @param cascadeIndex index of the cascade
  127502. * @returns the minimum cascade extents
  127503. */
  127504. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127505. /**
  127506. * Gets a cascade maximum extents
  127507. * @param cascadeIndex index of the cascade
  127508. * @returns the maximum cascade extents
  127509. */
  127510. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127511. private _cascades;
  127512. private _currentLayer;
  127513. private _viewSpaceFrustumsZ;
  127514. private _viewMatrices;
  127515. private _projectionMatrices;
  127516. private _transformMatrices;
  127517. private _transformMatricesAsArray;
  127518. private _frustumLengths;
  127519. private _lightSizeUVCorrection;
  127520. private _depthCorrection;
  127521. private _frustumCornersWorldSpace;
  127522. private _frustumCenter;
  127523. private _shadowCameraPos;
  127524. private _shadowMaxZ;
  127525. /**
  127526. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127527. * It defaults to camera.maxZ
  127528. */
  127529. get shadowMaxZ(): number;
  127530. /**
  127531. * Sets the shadow max z distance.
  127532. */
  127533. set shadowMaxZ(value: number);
  127534. protected _debug: boolean;
  127535. /**
  127536. * Gets or sets the debug flag.
  127537. * When enabled, the cascades are materialized by different colors on the screen.
  127538. */
  127539. get debug(): boolean;
  127540. set debug(dbg: boolean);
  127541. private _depthClamp;
  127542. /**
  127543. * Gets or sets the depth clamping value.
  127544. *
  127545. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127546. * to account for the shadow casters far away.
  127547. *
  127548. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127549. */
  127550. get depthClamp(): boolean;
  127551. set depthClamp(value: boolean);
  127552. private _cascadeBlendPercentage;
  127553. /**
  127554. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127555. * It defaults to 0.1 (10% blending).
  127556. */
  127557. get cascadeBlendPercentage(): number;
  127558. set cascadeBlendPercentage(value: number);
  127559. private _lambda;
  127560. /**
  127561. * Gets or set the lambda parameter.
  127562. * This parameter is used to split the camera frustum and create the cascades.
  127563. * 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.
  127564. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127565. */
  127566. get lambda(): number;
  127567. set lambda(value: number);
  127568. /**
  127569. * Gets the view matrix corresponding to a given cascade
  127570. * @param cascadeNum cascade to retrieve the view matrix from
  127571. * @returns the cascade view matrix
  127572. */
  127573. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127574. /**
  127575. * Gets the projection matrix corresponding to a given cascade
  127576. * @param cascadeNum cascade to retrieve the projection matrix from
  127577. * @returns the cascade projection matrix
  127578. */
  127579. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127580. /**
  127581. * Gets the transformation matrix corresponding to a given cascade
  127582. * @param cascadeNum cascade to retrieve the transformation matrix from
  127583. * @returns the cascade transformation matrix
  127584. */
  127585. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127586. private _depthRenderer;
  127587. /**
  127588. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127589. *
  127590. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127591. *
  127592. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127593. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127594. * @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
  127595. */
  127596. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127597. private _depthReducer;
  127598. private _autoCalcDepthBounds;
  127599. /**
  127600. * Gets or sets the autoCalcDepthBounds property.
  127601. *
  127602. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127603. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127604. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127605. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127606. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127607. */
  127608. get autoCalcDepthBounds(): boolean;
  127609. set autoCalcDepthBounds(value: boolean);
  127610. /**
  127611. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127612. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127613. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127614. * for setting the refresh rate on the renderer yourself!
  127615. */
  127616. get autoCalcDepthBoundsRefreshRate(): number;
  127617. set autoCalcDepthBoundsRefreshRate(value: number);
  127618. /**
  127619. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127620. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127621. * you change the camera near/far planes!
  127622. */
  127623. splitFrustum(): void;
  127624. private _splitFrustum;
  127625. private _computeMatrices;
  127626. private _computeFrustumInWorldSpace;
  127627. private _computeCascadeFrustum;
  127628. /** @hidden */
  127629. static _SceneComponentInitialization: (scene: Scene) => void;
  127630. /**
  127631. * Creates a Cascaded Shadow Generator object.
  127632. * A ShadowGenerator is the required tool to use the shadows.
  127633. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127634. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127635. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127636. * @param light The directional light object generating the shadows.
  127637. * @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.
  127638. */
  127639. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127640. protected _initializeGenerator(): void;
  127641. protected _createTargetRenderTexture(): void;
  127642. protected _initializeShadowMap(): void;
  127643. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127644. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127645. /**
  127646. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127647. * @param defines Defines of the material we want to update
  127648. * @param lightIndex Index of the light in the enabled light list of the material
  127649. */
  127650. prepareDefines(defines: any, lightIndex: number): void;
  127651. /**
  127652. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127653. * defined in the generator but impacting the effect).
  127654. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127655. * @param effect The effect we are binfing the information for
  127656. */
  127657. bindShadowLight(lightIndex: string, effect: Effect): void;
  127658. /**
  127659. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127660. * (eq to view projection * shadow projection matrices)
  127661. * @returns The transform matrix used to create the shadow map
  127662. */
  127663. getTransformMatrix(): Matrix;
  127664. /**
  127665. * Disposes the ShadowGenerator.
  127666. * Returns nothing.
  127667. */
  127668. dispose(): void;
  127669. /**
  127670. * Serializes the shadow generator setup to a json object.
  127671. * @returns The serialized JSON object
  127672. */
  127673. serialize(): any;
  127674. /**
  127675. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127676. * @param parsedShadowGenerator The JSON object to parse
  127677. * @param scene The scene to create the shadow map for
  127678. * @returns The parsed shadow generator
  127679. */
  127680. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127681. }
  127682. }
  127683. declare module BABYLON {
  127684. /**
  127685. * Defines the shadow generator component responsible to manage any shadow generators
  127686. * in a given scene.
  127687. */
  127688. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127689. /**
  127690. * The component name helpfull to identify the component in the list of scene components.
  127691. */
  127692. readonly name: string;
  127693. /**
  127694. * The scene the component belongs to.
  127695. */
  127696. scene: Scene;
  127697. /**
  127698. * Creates a new instance of the component for the given scene
  127699. * @param scene Defines the scene to register the component in
  127700. */
  127701. constructor(scene: Scene);
  127702. /**
  127703. * Registers the component in a given scene
  127704. */
  127705. register(): void;
  127706. /**
  127707. * Rebuilds the elements related to this component in case of
  127708. * context lost for instance.
  127709. */
  127710. rebuild(): void;
  127711. /**
  127712. * Serializes the component data to the specified json object
  127713. * @param serializationObject The object to serialize to
  127714. */
  127715. serialize(serializationObject: any): void;
  127716. /**
  127717. * Adds all the elements from the container to the scene
  127718. * @param container the container holding the elements
  127719. */
  127720. addFromContainer(container: AbstractScene): void;
  127721. /**
  127722. * Removes all the elements in the container from the scene
  127723. * @param container contains the elements to remove
  127724. * @param dispose if the removed element should be disposed (default: false)
  127725. */
  127726. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127727. /**
  127728. * Rebuilds the elements related to this component in case of
  127729. * context lost for instance.
  127730. */
  127731. dispose(): void;
  127732. private _gatherRenderTargets;
  127733. }
  127734. }
  127735. declare module BABYLON {
  127736. /**
  127737. * A point light is a light defined by an unique point in world space.
  127738. * The light is emitted in every direction from this point.
  127739. * A good example of a point light is a standard light bulb.
  127740. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127741. */
  127742. export class PointLight extends ShadowLight {
  127743. private _shadowAngle;
  127744. /**
  127745. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127746. * This specifies what angle the shadow will use to be created.
  127747. *
  127748. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127749. */
  127750. get shadowAngle(): number;
  127751. /**
  127752. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127753. * This specifies what angle the shadow will use to be created.
  127754. *
  127755. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127756. */
  127757. set shadowAngle(value: number);
  127758. /**
  127759. * Gets the direction if it has been set.
  127760. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127761. */
  127762. get direction(): Vector3;
  127763. /**
  127764. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127765. */
  127766. set direction(value: Vector3);
  127767. /**
  127768. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127769. * A PointLight emits the light in every direction.
  127770. * It can cast shadows.
  127771. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127772. * ```javascript
  127773. * var pointLight = new PointLight("pl", camera.position, scene);
  127774. * ```
  127775. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127776. * @param name The light friendly name
  127777. * @param position The position of the point light in the scene
  127778. * @param scene The scene the lights belongs to
  127779. */
  127780. constructor(name: string, position: Vector3, scene: Scene);
  127781. /**
  127782. * Returns the string "PointLight"
  127783. * @returns the class name
  127784. */
  127785. getClassName(): string;
  127786. /**
  127787. * Returns the integer 0.
  127788. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127789. */
  127790. getTypeID(): number;
  127791. /**
  127792. * Specifies wether or not the shadowmap should be a cube texture.
  127793. * @returns true if the shadowmap needs to be a cube texture.
  127794. */
  127795. needCube(): boolean;
  127796. /**
  127797. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127798. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127799. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127800. */
  127801. getShadowDirection(faceIndex?: number): Vector3;
  127802. /**
  127803. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127804. * - fov = PI / 2
  127805. * - aspect ratio : 1.0
  127806. * - z-near and far equal to the active camera minZ and maxZ.
  127807. * Returns the PointLight.
  127808. */
  127809. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127810. protected _buildUniformLayout(): void;
  127811. /**
  127812. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127813. * @param effect The effect to update
  127814. * @param lightIndex The index of the light in the effect to update
  127815. * @returns The point light
  127816. */
  127817. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127818. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127819. /**
  127820. * Prepares the list of defines specific to the light type.
  127821. * @param defines the list of defines
  127822. * @param lightIndex defines the index of the light for the effect
  127823. */
  127824. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127825. }
  127826. }
  127827. declare module BABYLON {
  127828. /**
  127829. * Header information of HDR texture files.
  127830. */
  127831. export interface HDRInfo {
  127832. /**
  127833. * The height of the texture in pixels.
  127834. */
  127835. height: number;
  127836. /**
  127837. * The width of the texture in pixels.
  127838. */
  127839. width: number;
  127840. /**
  127841. * The index of the beginning of the data in the binary file.
  127842. */
  127843. dataPosition: number;
  127844. }
  127845. /**
  127846. * This groups tools to convert HDR texture to native colors array.
  127847. */
  127848. export class HDRTools {
  127849. private static Ldexp;
  127850. private static Rgbe2float;
  127851. private static readStringLine;
  127852. /**
  127853. * Reads header information from an RGBE texture stored in a native array.
  127854. * More information on this format are available here:
  127855. * https://en.wikipedia.org/wiki/RGBE_image_format
  127856. *
  127857. * @param uint8array The binary file stored in native array.
  127858. * @return The header information.
  127859. */
  127860. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127861. /**
  127862. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127863. * This RGBE texture needs to store the information as a panorama.
  127864. *
  127865. * More information on this format are available here:
  127866. * https://en.wikipedia.org/wiki/RGBE_image_format
  127867. *
  127868. * @param buffer The binary file stored in an array buffer.
  127869. * @param size The expected size of the extracted cubemap.
  127870. * @return The Cube Map information.
  127871. */
  127872. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127873. /**
  127874. * Returns the pixels data extracted from an RGBE texture.
  127875. * This pixels will be stored left to right up to down in the R G B order in one array.
  127876. *
  127877. * More information on this format are available here:
  127878. * https://en.wikipedia.org/wiki/RGBE_image_format
  127879. *
  127880. * @param uint8array The binary file stored in an array buffer.
  127881. * @param hdrInfo The header information of the file.
  127882. * @return The pixels data in RGB right to left up to down order.
  127883. */
  127884. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127885. private static RGBE_ReadPixels_RLE;
  127886. }
  127887. }
  127888. declare module BABYLON {
  127889. /**
  127890. * This represents a texture coming from an HDR input.
  127891. *
  127892. * The only supported format is currently panorama picture stored in RGBE format.
  127893. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127894. */
  127895. export class HDRCubeTexture extends BaseTexture {
  127896. private static _facesMapping;
  127897. private _generateHarmonics;
  127898. private _noMipmap;
  127899. private _textureMatrix;
  127900. private _size;
  127901. private _onLoad;
  127902. private _onError;
  127903. /**
  127904. * The texture URL.
  127905. */
  127906. url: string;
  127907. /**
  127908. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127909. */
  127910. coordinatesMode: number;
  127911. protected _isBlocking: boolean;
  127912. /**
  127913. * Sets wether or not the texture is blocking during loading.
  127914. */
  127915. set isBlocking(value: boolean);
  127916. /**
  127917. * Gets wether or not the texture is blocking during loading.
  127918. */
  127919. get isBlocking(): boolean;
  127920. protected _rotationY: number;
  127921. /**
  127922. * Sets texture matrix rotation angle around Y axis in radians.
  127923. */
  127924. set rotationY(value: number);
  127925. /**
  127926. * Gets texture matrix rotation angle around Y axis radians.
  127927. */
  127928. get rotationY(): number;
  127929. /**
  127930. * Gets or sets the center of the bounding box associated with the cube texture
  127931. * It must define where the camera used to render the texture was set
  127932. */
  127933. boundingBoxPosition: Vector3;
  127934. private _boundingBoxSize;
  127935. /**
  127936. * Gets or sets the size of the bounding box associated with the cube texture
  127937. * When defined, the cubemap will switch to local mode
  127938. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127939. * @example https://www.babylonjs-playground.com/#RNASML
  127940. */
  127941. set boundingBoxSize(value: Vector3);
  127942. get boundingBoxSize(): Vector3;
  127943. /**
  127944. * Instantiates an HDRTexture from the following parameters.
  127945. *
  127946. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127947. * @param scene The scene the texture will be used in
  127948. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127949. * @param noMipmap Forces to not generate the mipmap if true
  127950. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127951. * @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)
  127952. * @param reserved Reserved flag for internal use.
  127953. */
  127954. 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>);
  127955. /**
  127956. * Get the current class name of the texture useful for serialization or dynamic coding.
  127957. * @returns "HDRCubeTexture"
  127958. */
  127959. getClassName(): string;
  127960. /**
  127961. * Occurs when the file is raw .hdr file.
  127962. */
  127963. private loadTexture;
  127964. clone(): HDRCubeTexture;
  127965. delayLoad(): void;
  127966. /**
  127967. * Get the texture reflection matrix used to rotate/transform the reflection.
  127968. * @returns the reflection matrix
  127969. */
  127970. getReflectionTextureMatrix(): Matrix;
  127971. /**
  127972. * Set the texture reflection matrix used to rotate/transform the reflection.
  127973. * @param value Define the reflection matrix to set
  127974. */
  127975. setReflectionTextureMatrix(value: Matrix): void;
  127976. /**
  127977. * Parses a JSON representation of an HDR Texture in order to create the texture
  127978. * @param parsedTexture Define the JSON representation
  127979. * @param scene Define the scene the texture should be created in
  127980. * @param rootUrl Define the root url in case we need to load relative dependencies
  127981. * @returns the newly created texture after parsing
  127982. */
  127983. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127984. serialize(): any;
  127985. }
  127986. }
  127987. declare module BABYLON {
  127988. /**
  127989. * Class used to control physics engine
  127990. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127991. */
  127992. export class PhysicsEngine implements IPhysicsEngine {
  127993. private _physicsPlugin;
  127994. /**
  127995. * Global value used to control the smallest number supported by the simulation
  127996. */
  127997. static Epsilon: number;
  127998. private _impostors;
  127999. private _joints;
  128000. private _subTimeStep;
  128001. /**
  128002. * Gets the gravity vector used by the simulation
  128003. */
  128004. gravity: Vector3;
  128005. /**
  128006. * Factory used to create the default physics plugin.
  128007. * @returns The default physics plugin
  128008. */
  128009. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  128010. /**
  128011. * Creates a new Physics Engine
  128012. * @param gravity defines the gravity vector used by the simulation
  128013. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  128014. */
  128015. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  128016. /**
  128017. * Sets the gravity vector used by the simulation
  128018. * @param gravity defines the gravity vector to use
  128019. */
  128020. setGravity(gravity: Vector3): void;
  128021. /**
  128022. * Set the time step of the physics engine.
  128023. * Default is 1/60.
  128024. * To slow it down, enter 1/600 for example.
  128025. * To speed it up, 1/30
  128026. * @param newTimeStep defines the new timestep to apply to this world.
  128027. */
  128028. setTimeStep(newTimeStep?: number): void;
  128029. /**
  128030. * Get the time step of the physics engine.
  128031. * @returns the current time step
  128032. */
  128033. getTimeStep(): number;
  128034. /**
  128035. * Set the sub time step of the physics engine.
  128036. * Default is 0 meaning there is no sub steps
  128037. * To increase physics resolution precision, set a small value (like 1 ms)
  128038. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128039. */
  128040. setSubTimeStep(subTimeStep?: number): void;
  128041. /**
  128042. * Get the sub time step of the physics engine.
  128043. * @returns the current sub time step
  128044. */
  128045. getSubTimeStep(): number;
  128046. /**
  128047. * Release all resources
  128048. */
  128049. dispose(): void;
  128050. /**
  128051. * Gets the name of the current physics plugin
  128052. * @returns the name of the plugin
  128053. */
  128054. getPhysicsPluginName(): string;
  128055. /**
  128056. * Adding a new impostor for the impostor tracking.
  128057. * This will be done by the impostor itself.
  128058. * @param impostor the impostor to add
  128059. */
  128060. addImpostor(impostor: PhysicsImpostor): void;
  128061. /**
  128062. * Remove an impostor from the engine.
  128063. * This impostor and its mesh will not longer be updated by the physics engine.
  128064. * @param impostor the impostor to remove
  128065. */
  128066. removeImpostor(impostor: PhysicsImpostor): void;
  128067. /**
  128068. * Add a joint to the physics engine
  128069. * @param mainImpostor defines the main impostor to which the joint is added.
  128070. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128071. * @param joint defines the joint that will connect both impostors.
  128072. */
  128073. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128074. /**
  128075. * Removes a joint from the simulation
  128076. * @param mainImpostor defines the impostor used with the joint
  128077. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128078. * @param joint defines the joint to remove
  128079. */
  128080. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128081. /**
  128082. * Called by the scene. No need to call it.
  128083. * @param delta defines the timespam between frames
  128084. */
  128085. _step(delta: number): void;
  128086. /**
  128087. * Gets the current plugin used to run the simulation
  128088. * @returns current plugin
  128089. */
  128090. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128091. /**
  128092. * Gets the list of physic impostors
  128093. * @returns an array of PhysicsImpostor
  128094. */
  128095. getImpostors(): Array<PhysicsImpostor>;
  128096. /**
  128097. * Gets the impostor for a physics enabled object
  128098. * @param object defines the object impersonated by the impostor
  128099. * @returns the PhysicsImpostor or null if not found
  128100. */
  128101. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128102. /**
  128103. * Gets the impostor for a physics body object
  128104. * @param body defines physics body used by the impostor
  128105. * @returns the PhysicsImpostor or null if not found
  128106. */
  128107. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128108. /**
  128109. * Does a raycast in the physics world
  128110. * @param from when should the ray start?
  128111. * @param to when should the ray end?
  128112. * @returns PhysicsRaycastResult
  128113. */
  128114. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128115. }
  128116. }
  128117. declare module BABYLON {
  128118. /** @hidden */
  128119. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128120. private _useDeltaForWorldStep;
  128121. world: any;
  128122. name: string;
  128123. private _physicsMaterials;
  128124. private _fixedTimeStep;
  128125. private _cannonRaycastResult;
  128126. private _raycastResult;
  128127. private _physicsBodysToRemoveAfterStep;
  128128. BJSCANNON: any;
  128129. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128130. setGravity(gravity: Vector3): void;
  128131. setTimeStep(timeStep: number): void;
  128132. getTimeStep(): number;
  128133. executeStep(delta: number): void;
  128134. private _removeMarkedPhysicsBodiesFromWorld;
  128135. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128136. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128137. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128138. private _processChildMeshes;
  128139. removePhysicsBody(impostor: PhysicsImpostor): void;
  128140. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128141. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128142. private _addMaterial;
  128143. private _checkWithEpsilon;
  128144. private _createShape;
  128145. private _createHeightmap;
  128146. private _minus90X;
  128147. private _plus90X;
  128148. private _tmpPosition;
  128149. private _tmpDeltaPosition;
  128150. private _tmpUnityRotation;
  128151. private _updatePhysicsBodyTransformation;
  128152. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128153. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128154. isSupported(): boolean;
  128155. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128156. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128157. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128158. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128159. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128160. getBodyMass(impostor: PhysicsImpostor): number;
  128161. getBodyFriction(impostor: PhysicsImpostor): number;
  128162. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128163. getBodyRestitution(impostor: PhysicsImpostor): number;
  128164. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128165. sleepBody(impostor: PhysicsImpostor): void;
  128166. wakeUpBody(impostor: PhysicsImpostor): void;
  128167. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128168. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128169. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128170. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128171. getRadius(impostor: PhysicsImpostor): number;
  128172. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128173. dispose(): void;
  128174. private _extendNamespace;
  128175. /**
  128176. * Does a raycast in the physics world
  128177. * @param from when should the ray start?
  128178. * @param to when should the ray end?
  128179. * @returns PhysicsRaycastResult
  128180. */
  128181. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128182. }
  128183. }
  128184. declare module BABYLON {
  128185. /** @hidden */
  128186. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128187. world: any;
  128188. name: string;
  128189. BJSOIMO: any;
  128190. private _raycastResult;
  128191. constructor(iterations?: number, oimoInjection?: any);
  128192. setGravity(gravity: Vector3): void;
  128193. setTimeStep(timeStep: number): void;
  128194. getTimeStep(): number;
  128195. private _tmpImpostorsArray;
  128196. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128197. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128198. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128199. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128200. private _tmpPositionVector;
  128201. removePhysicsBody(impostor: PhysicsImpostor): void;
  128202. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128203. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128204. isSupported(): boolean;
  128205. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128206. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128207. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128208. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128209. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128210. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128211. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128212. getBodyMass(impostor: PhysicsImpostor): number;
  128213. getBodyFriction(impostor: PhysicsImpostor): number;
  128214. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128215. getBodyRestitution(impostor: PhysicsImpostor): number;
  128216. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128217. sleepBody(impostor: PhysicsImpostor): void;
  128218. wakeUpBody(impostor: PhysicsImpostor): void;
  128219. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128220. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128221. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128222. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128223. getRadius(impostor: PhysicsImpostor): number;
  128224. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128225. dispose(): void;
  128226. /**
  128227. * Does a raycast in the physics world
  128228. * @param from when should the ray start?
  128229. * @param to when should the ray end?
  128230. * @returns PhysicsRaycastResult
  128231. */
  128232. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128233. }
  128234. }
  128235. declare module BABYLON {
  128236. /**
  128237. * Class containing static functions to help procedurally build meshes
  128238. */
  128239. export class RibbonBuilder {
  128240. /**
  128241. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128242. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128243. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128244. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128245. * * 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
  128246. * * 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
  128247. * * 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
  128248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128250. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128251. * * 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
  128252. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128253. * * 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
  128254. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128256. * @param name defines the name of the mesh
  128257. * @param options defines the options used to create the mesh
  128258. * @param scene defines the hosting scene
  128259. * @returns the ribbon mesh
  128260. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128262. */
  128263. static CreateRibbon(name: string, options: {
  128264. pathArray: Vector3[][];
  128265. closeArray?: boolean;
  128266. closePath?: boolean;
  128267. offset?: number;
  128268. updatable?: boolean;
  128269. sideOrientation?: number;
  128270. frontUVs?: Vector4;
  128271. backUVs?: Vector4;
  128272. instance?: Mesh;
  128273. invertUV?: boolean;
  128274. uvs?: Vector2[];
  128275. colors?: Color4[];
  128276. }, scene?: Nullable<Scene>): Mesh;
  128277. }
  128278. }
  128279. declare module BABYLON {
  128280. /**
  128281. * Class containing static functions to help procedurally build meshes
  128282. */
  128283. export class ShapeBuilder {
  128284. /**
  128285. * 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.
  128286. * * 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.
  128287. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128288. * * 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.
  128289. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128290. * * 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
  128291. * * 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
  128292. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128295. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128297. * @param name defines the name of the mesh
  128298. * @param options defines the options used to create the mesh
  128299. * @param scene defines the hosting scene
  128300. * @returns the extruded shape mesh
  128301. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128303. */
  128304. static ExtrudeShape(name: string, options: {
  128305. shape: Vector3[];
  128306. path: Vector3[];
  128307. scale?: number;
  128308. rotation?: number;
  128309. cap?: number;
  128310. updatable?: boolean;
  128311. sideOrientation?: number;
  128312. frontUVs?: Vector4;
  128313. backUVs?: Vector4;
  128314. instance?: Mesh;
  128315. invertUV?: boolean;
  128316. }, scene?: Nullable<Scene>): Mesh;
  128317. /**
  128318. * Creates an custom extruded shape mesh.
  128319. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128320. * * 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.
  128321. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128322. * * 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
  128323. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128324. * * 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
  128325. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128326. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128327. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128328. * * 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
  128329. * * 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
  128330. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128333. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128335. * @param name defines the name of the mesh
  128336. * @param options defines the options used to create the mesh
  128337. * @param scene defines the hosting scene
  128338. * @returns the custom extruded shape mesh
  128339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128342. */
  128343. static ExtrudeShapeCustom(name: string, options: {
  128344. shape: Vector3[];
  128345. path: Vector3[];
  128346. scaleFunction?: any;
  128347. rotationFunction?: any;
  128348. ribbonCloseArray?: boolean;
  128349. ribbonClosePath?: boolean;
  128350. cap?: number;
  128351. updatable?: boolean;
  128352. sideOrientation?: number;
  128353. frontUVs?: Vector4;
  128354. backUVs?: Vector4;
  128355. instance?: Mesh;
  128356. invertUV?: boolean;
  128357. }, scene?: Nullable<Scene>): Mesh;
  128358. private static _ExtrudeShapeGeneric;
  128359. }
  128360. }
  128361. declare module BABYLON {
  128362. /**
  128363. * AmmoJS Physics plugin
  128364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128365. * @see https://github.com/kripken/ammo.js/
  128366. */
  128367. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128368. private _useDeltaForWorldStep;
  128369. /**
  128370. * Reference to the Ammo library
  128371. */
  128372. bjsAMMO: any;
  128373. /**
  128374. * Created ammoJS world which physics bodies are added to
  128375. */
  128376. world: any;
  128377. /**
  128378. * Name of the plugin
  128379. */
  128380. name: string;
  128381. private _timeStep;
  128382. private _fixedTimeStep;
  128383. private _maxSteps;
  128384. private _tmpQuaternion;
  128385. private _tmpAmmoTransform;
  128386. private _tmpAmmoQuaternion;
  128387. private _tmpAmmoConcreteContactResultCallback;
  128388. private _collisionConfiguration;
  128389. private _dispatcher;
  128390. private _overlappingPairCache;
  128391. private _solver;
  128392. private _softBodySolver;
  128393. private _tmpAmmoVectorA;
  128394. private _tmpAmmoVectorB;
  128395. private _tmpAmmoVectorC;
  128396. private _tmpAmmoVectorD;
  128397. private _tmpContactCallbackResult;
  128398. private _tmpAmmoVectorRCA;
  128399. private _tmpAmmoVectorRCB;
  128400. private _raycastResult;
  128401. private static readonly DISABLE_COLLISION_FLAG;
  128402. private static readonly KINEMATIC_FLAG;
  128403. private static readonly DISABLE_DEACTIVATION_FLAG;
  128404. /**
  128405. * Initializes the ammoJS plugin
  128406. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128407. * @param ammoInjection can be used to inject your own ammo reference
  128408. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128409. */
  128410. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128411. /**
  128412. * Sets the gravity of the physics world (m/(s^2))
  128413. * @param gravity Gravity to set
  128414. */
  128415. setGravity(gravity: Vector3): void;
  128416. /**
  128417. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128418. * @param timeStep timestep to use in seconds
  128419. */
  128420. setTimeStep(timeStep: number): void;
  128421. /**
  128422. * 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)
  128423. * @param fixedTimeStep fixedTimeStep to use in seconds
  128424. */
  128425. setFixedTimeStep(fixedTimeStep: number): void;
  128426. /**
  128427. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128428. * @param maxSteps the maximum number of steps by the physics engine per frame
  128429. */
  128430. setMaxSteps(maxSteps: number): void;
  128431. /**
  128432. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128433. * @returns the current timestep in seconds
  128434. */
  128435. getTimeStep(): number;
  128436. /**
  128437. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128438. */
  128439. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128440. private _isImpostorInContact;
  128441. private _isImpostorPairInContact;
  128442. private _stepSimulation;
  128443. /**
  128444. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128445. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128446. * After the step the babylon meshes are set to the position of the physics imposters
  128447. * @param delta amount of time to step forward
  128448. * @param impostors array of imposters to update before/after the step
  128449. */
  128450. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128451. /**
  128452. * Update babylon mesh to match physics world object
  128453. * @param impostor imposter to match
  128454. */
  128455. private _afterSoftStep;
  128456. /**
  128457. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128458. * @param impostor imposter to match
  128459. */
  128460. private _ropeStep;
  128461. /**
  128462. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128463. * @param impostor imposter to match
  128464. */
  128465. private _softbodyOrClothStep;
  128466. private _tmpVector;
  128467. private _tmpMatrix;
  128468. /**
  128469. * Applies an impulse on the imposter
  128470. * @param impostor imposter to apply impulse to
  128471. * @param force amount of force to be applied to the imposter
  128472. * @param contactPoint the location to apply the impulse on the imposter
  128473. */
  128474. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128475. /**
  128476. * Applies a force on the imposter
  128477. * @param impostor imposter to apply force
  128478. * @param force amount of force to be applied to the imposter
  128479. * @param contactPoint the location to apply the force on the imposter
  128480. */
  128481. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128482. /**
  128483. * Creates a physics body using the plugin
  128484. * @param impostor the imposter to create the physics body on
  128485. */
  128486. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128487. /**
  128488. * Removes the physics body from the imposter and disposes of the body's memory
  128489. * @param impostor imposter to remove the physics body from
  128490. */
  128491. removePhysicsBody(impostor: PhysicsImpostor): void;
  128492. /**
  128493. * Generates a joint
  128494. * @param impostorJoint the imposter joint to create the joint with
  128495. */
  128496. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128497. /**
  128498. * Removes a joint
  128499. * @param impostorJoint the imposter joint to remove the joint from
  128500. */
  128501. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128502. private _addMeshVerts;
  128503. /**
  128504. * Initialise the soft body vertices to match its object's (mesh) vertices
  128505. * Softbody vertices (nodes) are in world space and to match this
  128506. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128507. * @param impostor to create the softbody for
  128508. */
  128509. private _softVertexData;
  128510. /**
  128511. * Create an impostor's soft body
  128512. * @param impostor to create the softbody for
  128513. */
  128514. private _createSoftbody;
  128515. /**
  128516. * Create cloth for an impostor
  128517. * @param impostor to create the softbody for
  128518. */
  128519. private _createCloth;
  128520. /**
  128521. * Create rope for an impostor
  128522. * @param impostor to create the softbody for
  128523. */
  128524. private _createRope;
  128525. /**
  128526. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128527. * @param impostor to create the custom physics shape for
  128528. */
  128529. private _createCustom;
  128530. private _addHullVerts;
  128531. private _createShape;
  128532. /**
  128533. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128534. * @param impostor imposter containing the physics body and babylon object
  128535. */
  128536. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128537. /**
  128538. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128539. * @param impostor imposter containing the physics body and babylon object
  128540. * @param newPosition new position
  128541. * @param newRotation new rotation
  128542. */
  128543. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128544. /**
  128545. * If this plugin is supported
  128546. * @returns true if its supported
  128547. */
  128548. isSupported(): boolean;
  128549. /**
  128550. * Sets the linear velocity of the physics body
  128551. * @param impostor imposter to set the velocity on
  128552. * @param velocity velocity to set
  128553. */
  128554. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128555. /**
  128556. * Sets the angular velocity of the physics body
  128557. * @param impostor imposter to set the velocity on
  128558. * @param velocity velocity to set
  128559. */
  128560. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128561. /**
  128562. * gets the linear velocity
  128563. * @param impostor imposter to get linear velocity from
  128564. * @returns linear velocity
  128565. */
  128566. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128567. /**
  128568. * gets the angular velocity
  128569. * @param impostor imposter to get angular velocity from
  128570. * @returns angular velocity
  128571. */
  128572. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128573. /**
  128574. * Sets the mass of physics body
  128575. * @param impostor imposter to set the mass on
  128576. * @param mass mass to set
  128577. */
  128578. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128579. /**
  128580. * Gets the mass of the physics body
  128581. * @param impostor imposter to get the mass from
  128582. * @returns mass
  128583. */
  128584. getBodyMass(impostor: PhysicsImpostor): number;
  128585. /**
  128586. * Gets friction of the impostor
  128587. * @param impostor impostor to get friction from
  128588. * @returns friction value
  128589. */
  128590. getBodyFriction(impostor: PhysicsImpostor): number;
  128591. /**
  128592. * Sets friction of the impostor
  128593. * @param impostor impostor to set friction on
  128594. * @param friction friction value
  128595. */
  128596. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128597. /**
  128598. * Gets restitution of the impostor
  128599. * @param impostor impostor to get restitution from
  128600. * @returns restitution value
  128601. */
  128602. getBodyRestitution(impostor: PhysicsImpostor): number;
  128603. /**
  128604. * Sets resitution of the impostor
  128605. * @param impostor impostor to set resitution on
  128606. * @param restitution resitution value
  128607. */
  128608. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128609. /**
  128610. * Gets pressure inside the impostor
  128611. * @param impostor impostor to get pressure from
  128612. * @returns pressure value
  128613. */
  128614. getBodyPressure(impostor: PhysicsImpostor): number;
  128615. /**
  128616. * Sets pressure inside a soft body impostor
  128617. * Cloth and rope must remain 0 pressure
  128618. * @param impostor impostor to set pressure on
  128619. * @param pressure pressure value
  128620. */
  128621. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128622. /**
  128623. * Gets stiffness of the impostor
  128624. * @param impostor impostor to get stiffness from
  128625. * @returns pressure value
  128626. */
  128627. getBodyStiffness(impostor: PhysicsImpostor): number;
  128628. /**
  128629. * Sets stiffness of the impostor
  128630. * @param impostor impostor to set stiffness on
  128631. * @param stiffness stiffness value from 0 to 1
  128632. */
  128633. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128634. /**
  128635. * Gets velocityIterations of the impostor
  128636. * @param impostor impostor to get velocity iterations from
  128637. * @returns velocityIterations value
  128638. */
  128639. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128640. /**
  128641. * Sets velocityIterations of the impostor
  128642. * @param impostor impostor to set velocity iterations on
  128643. * @param velocityIterations velocityIterations value
  128644. */
  128645. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128646. /**
  128647. * Gets positionIterations of the impostor
  128648. * @param impostor impostor to get position iterations from
  128649. * @returns positionIterations value
  128650. */
  128651. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128652. /**
  128653. * Sets positionIterations of the impostor
  128654. * @param impostor impostor to set position on
  128655. * @param positionIterations positionIterations value
  128656. */
  128657. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128658. /**
  128659. * Append an anchor to a cloth object
  128660. * @param impostor is the cloth impostor to add anchor to
  128661. * @param otherImpostor is the rigid impostor to anchor to
  128662. * @param width ratio across width from 0 to 1
  128663. * @param height ratio up height from 0 to 1
  128664. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128665. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128666. */
  128667. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128668. /**
  128669. * Append an hook to a rope object
  128670. * @param impostor is the rope impostor to add hook to
  128671. * @param otherImpostor is the rigid impostor to hook to
  128672. * @param length ratio along the rope from 0 to 1
  128673. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128674. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128675. */
  128676. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128677. /**
  128678. * Sleeps the physics body and stops it from being active
  128679. * @param impostor impostor to sleep
  128680. */
  128681. sleepBody(impostor: PhysicsImpostor): void;
  128682. /**
  128683. * Activates the physics body
  128684. * @param impostor impostor to activate
  128685. */
  128686. wakeUpBody(impostor: PhysicsImpostor): void;
  128687. /**
  128688. * Updates the distance parameters of the joint
  128689. * @param joint joint to update
  128690. * @param maxDistance maximum distance of the joint
  128691. * @param minDistance minimum distance of the joint
  128692. */
  128693. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128694. /**
  128695. * Sets a motor on the joint
  128696. * @param joint joint to set motor on
  128697. * @param speed speed of the motor
  128698. * @param maxForce maximum force of the motor
  128699. * @param motorIndex index of the motor
  128700. */
  128701. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128702. /**
  128703. * Sets the motors limit
  128704. * @param joint joint to set limit on
  128705. * @param upperLimit upper limit
  128706. * @param lowerLimit lower limit
  128707. */
  128708. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128709. /**
  128710. * Syncs the position and rotation of a mesh with the impostor
  128711. * @param mesh mesh to sync
  128712. * @param impostor impostor to update the mesh with
  128713. */
  128714. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128715. /**
  128716. * Gets the radius of the impostor
  128717. * @param impostor impostor to get radius from
  128718. * @returns the radius
  128719. */
  128720. getRadius(impostor: PhysicsImpostor): number;
  128721. /**
  128722. * Gets the box size of the impostor
  128723. * @param impostor impostor to get box size from
  128724. * @param result the resulting box size
  128725. */
  128726. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128727. /**
  128728. * Disposes of the impostor
  128729. */
  128730. dispose(): void;
  128731. /**
  128732. * Does a raycast in the physics world
  128733. * @param from when should the ray start?
  128734. * @param to when should the ray end?
  128735. * @returns PhysicsRaycastResult
  128736. */
  128737. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128738. }
  128739. }
  128740. declare module BABYLON {
  128741. interface AbstractScene {
  128742. /**
  128743. * The list of reflection probes added to the scene
  128744. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128745. */
  128746. reflectionProbes: Array<ReflectionProbe>;
  128747. /**
  128748. * Removes the given reflection probe from this scene.
  128749. * @param toRemove The reflection probe to remove
  128750. * @returns The index of the removed reflection probe
  128751. */
  128752. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128753. /**
  128754. * Adds the given reflection probe to this scene.
  128755. * @param newReflectionProbe The reflection probe to add
  128756. */
  128757. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128758. }
  128759. /**
  128760. * Class used to generate realtime reflection / refraction cube textures
  128761. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128762. */
  128763. export class ReflectionProbe {
  128764. /** defines the name of the probe */
  128765. name: string;
  128766. private _scene;
  128767. private _renderTargetTexture;
  128768. private _projectionMatrix;
  128769. private _viewMatrix;
  128770. private _target;
  128771. private _add;
  128772. private _attachedMesh;
  128773. private _invertYAxis;
  128774. /** Gets or sets probe position (center of the cube map) */
  128775. position: Vector3;
  128776. /**
  128777. * Creates a new reflection probe
  128778. * @param name defines the name of the probe
  128779. * @param size defines the texture resolution (for each face)
  128780. * @param scene defines the hosting scene
  128781. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128782. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128783. */
  128784. constructor(
  128785. /** defines the name of the probe */
  128786. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128787. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128788. get samples(): number;
  128789. set samples(value: number);
  128790. /** Gets or sets the refresh rate to use (on every frame by default) */
  128791. get refreshRate(): number;
  128792. set refreshRate(value: number);
  128793. /**
  128794. * Gets the hosting scene
  128795. * @returns a Scene
  128796. */
  128797. getScene(): Scene;
  128798. /** Gets the internal CubeTexture used to render to */
  128799. get cubeTexture(): RenderTargetTexture;
  128800. /** Gets the list of meshes to render */
  128801. get renderList(): Nullable<AbstractMesh[]>;
  128802. /**
  128803. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128804. * @param mesh defines the mesh to attach to
  128805. */
  128806. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128807. /**
  128808. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128809. * @param renderingGroupId The rendering group id corresponding to its index
  128810. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128811. */
  128812. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128813. /**
  128814. * Clean all associated resources
  128815. */
  128816. dispose(): void;
  128817. /**
  128818. * Converts the reflection probe information to a readable string for debug purpose.
  128819. * @param fullDetails Supports for multiple levels of logging within scene loading
  128820. * @returns the human readable reflection probe info
  128821. */
  128822. toString(fullDetails?: boolean): string;
  128823. /**
  128824. * Get the class name of the relfection probe.
  128825. * @returns "ReflectionProbe"
  128826. */
  128827. getClassName(): string;
  128828. /**
  128829. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128830. * @returns The JSON representation of the texture
  128831. */
  128832. serialize(): any;
  128833. /**
  128834. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128835. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128836. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128837. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128838. * @returns The parsed reflection probe if successful
  128839. */
  128840. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128841. }
  128842. }
  128843. declare module BABYLON {
  128844. /** @hidden */
  128845. export var _BabylonLoaderRegistered: boolean;
  128846. /**
  128847. * Helps setting up some configuration for the babylon file loader.
  128848. */
  128849. export class BabylonFileLoaderConfiguration {
  128850. /**
  128851. * The loader does not allow injecting custom physix engine into the plugins.
  128852. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128853. * So you could set this variable to your engine import to make it work.
  128854. */
  128855. static LoaderInjectedPhysicsEngine: any;
  128856. }
  128857. }
  128858. declare module BABYLON {
  128859. /**
  128860. * The Physically based simple base material of BJS.
  128861. *
  128862. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128863. * It is used as the base class for both the specGloss and metalRough conventions.
  128864. */
  128865. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128866. /**
  128867. * Number of Simultaneous lights allowed on the material.
  128868. */
  128869. maxSimultaneousLights: number;
  128870. /**
  128871. * If sets to true, disables all the lights affecting the material.
  128872. */
  128873. disableLighting: boolean;
  128874. /**
  128875. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128876. */
  128877. environmentTexture: BaseTexture;
  128878. /**
  128879. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128880. */
  128881. invertNormalMapX: boolean;
  128882. /**
  128883. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128884. */
  128885. invertNormalMapY: boolean;
  128886. /**
  128887. * Normal map used in the model.
  128888. */
  128889. normalTexture: BaseTexture;
  128890. /**
  128891. * Emissivie color used to self-illuminate the model.
  128892. */
  128893. emissiveColor: Color3;
  128894. /**
  128895. * Emissivie texture used to self-illuminate the model.
  128896. */
  128897. emissiveTexture: BaseTexture;
  128898. /**
  128899. * Occlusion Channel Strenght.
  128900. */
  128901. occlusionStrength: number;
  128902. /**
  128903. * Occlusion Texture of the material (adding extra occlusion effects).
  128904. */
  128905. occlusionTexture: BaseTexture;
  128906. /**
  128907. * Defines the alpha limits in alpha test mode.
  128908. */
  128909. alphaCutOff: number;
  128910. /**
  128911. * Gets the current double sided mode.
  128912. */
  128913. get doubleSided(): boolean;
  128914. /**
  128915. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128916. */
  128917. set doubleSided(value: boolean);
  128918. /**
  128919. * Stores the pre-calculated light information of a mesh in a texture.
  128920. */
  128921. lightmapTexture: BaseTexture;
  128922. /**
  128923. * If true, the light map contains occlusion information instead of lighting info.
  128924. */
  128925. useLightmapAsShadowmap: boolean;
  128926. /**
  128927. * Instantiates a new PBRMaterial instance.
  128928. *
  128929. * @param name The material name
  128930. * @param scene The scene the material will be use in.
  128931. */
  128932. constructor(name: string, scene: Scene);
  128933. getClassName(): string;
  128934. }
  128935. }
  128936. declare module BABYLON {
  128937. /**
  128938. * The PBR material of BJS following the metal roughness convention.
  128939. *
  128940. * This fits to the PBR convention in the GLTF definition:
  128941. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128942. */
  128943. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128944. /**
  128945. * The base color has two different interpretations depending on the value of metalness.
  128946. * When the material is a metal, the base color is the specific measured reflectance value
  128947. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128948. * of the material.
  128949. */
  128950. baseColor: Color3;
  128951. /**
  128952. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128953. * well as opacity information in the alpha channel.
  128954. */
  128955. baseTexture: BaseTexture;
  128956. /**
  128957. * Specifies the metallic scalar value of the material.
  128958. * Can also be used to scale the metalness values of the metallic texture.
  128959. */
  128960. metallic: number;
  128961. /**
  128962. * Specifies the roughness scalar value of the material.
  128963. * Can also be used to scale the roughness values of the metallic texture.
  128964. */
  128965. roughness: number;
  128966. /**
  128967. * Texture containing both the metallic value in the B channel and the
  128968. * roughness value in the G channel to keep better precision.
  128969. */
  128970. metallicRoughnessTexture: BaseTexture;
  128971. /**
  128972. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128973. *
  128974. * @param name The material name
  128975. * @param scene The scene the material will be use in.
  128976. */
  128977. constructor(name: string, scene: Scene);
  128978. /**
  128979. * Return the currrent class name of the material.
  128980. */
  128981. getClassName(): string;
  128982. /**
  128983. * Makes a duplicate of the current material.
  128984. * @param name - name to use for the new material.
  128985. */
  128986. clone(name: string): PBRMetallicRoughnessMaterial;
  128987. /**
  128988. * Serialize the material to a parsable JSON object.
  128989. */
  128990. serialize(): any;
  128991. /**
  128992. * Parses a JSON object correponding to the serialize function.
  128993. */
  128994. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128995. }
  128996. }
  128997. declare module BABYLON {
  128998. /**
  128999. * The PBR material of BJS following the specular glossiness convention.
  129000. *
  129001. * This fits to the PBR convention in the GLTF definition:
  129002. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  129003. */
  129004. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  129005. /**
  129006. * Specifies the diffuse color of the material.
  129007. */
  129008. diffuseColor: Color3;
  129009. /**
  129010. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  129011. * channel.
  129012. */
  129013. diffuseTexture: BaseTexture;
  129014. /**
  129015. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  129016. */
  129017. specularColor: Color3;
  129018. /**
  129019. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  129020. */
  129021. glossiness: number;
  129022. /**
  129023. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129024. */
  129025. specularGlossinessTexture: BaseTexture;
  129026. /**
  129027. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129028. *
  129029. * @param name The material name
  129030. * @param scene The scene the material will be use in.
  129031. */
  129032. constructor(name: string, scene: Scene);
  129033. /**
  129034. * Return the currrent class name of the material.
  129035. */
  129036. getClassName(): string;
  129037. /**
  129038. * Makes a duplicate of the current material.
  129039. * @param name - name to use for the new material.
  129040. */
  129041. clone(name: string): PBRSpecularGlossinessMaterial;
  129042. /**
  129043. * Serialize the material to a parsable JSON object.
  129044. */
  129045. serialize(): any;
  129046. /**
  129047. * Parses a JSON object correponding to the serialize function.
  129048. */
  129049. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129050. }
  129051. }
  129052. declare module BABYLON {
  129053. /**
  129054. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129055. * It can help converting any input color in a desired output one. This can then be used to create effects
  129056. * from sepia, black and white to sixties or futuristic rendering...
  129057. *
  129058. * The only supported format is currently 3dl.
  129059. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129060. */
  129061. export class ColorGradingTexture extends BaseTexture {
  129062. /**
  129063. * The current texture matrix. (will always be identity in color grading texture)
  129064. */
  129065. private _textureMatrix;
  129066. /**
  129067. * The texture URL.
  129068. */
  129069. url: string;
  129070. /**
  129071. * Empty line regex stored for GC.
  129072. */
  129073. private static _noneEmptyLineRegex;
  129074. private _engine;
  129075. /**
  129076. * Instantiates a ColorGradingTexture from the following parameters.
  129077. *
  129078. * @param url The location of the color gradind data (currently only supporting 3dl)
  129079. * @param scene The scene the texture will be used in
  129080. */
  129081. constructor(url: string, scene: Scene);
  129082. /**
  129083. * Returns the texture matrix used in most of the material.
  129084. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129085. */
  129086. getTextureMatrix(): Matrix;
  129087. /**
  129088. * Occurs when the file being loaded is a .3dl LUT file.
  129089. */
  129090. private load3dlTexture;
  129091. /**
  129092. * Starts the loading process of the texture.
  129093. */
  129094. private loadTexture;
  129095. /**
  129096. * Clones the color gradind texture.
  129097. */
  129098. clone(): ColorGradingTexture;
  129099. /**
  129100. * Called during delayed load for textures.
  129101. */
  129102. delayLoad(): void;
  129103. /**
  129104. * Parses a color grading texture serialized by Babylon.
  129105. * @param parsedTexture The texture information being parsedTexture
  129106. * @param scene The scene to load the texture in
  129107. * @param rootUrl The root url of the data assets to load
  129108. * @return A color gradind texture
  129109. */
  129110. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129111. /**
  129112. * Serializes the LUT texture to json format.
  129113. */
  129114. serialize(): any;
  129115. }
  129116. }
  129117. declare module BABYLON {
  129118. /**
  129119. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129120. */
  129121. export class EquiRectangularCubeTexture extends BaseTexture {
  129122. /** The six faces of the cube. */
  129123. private static _FacesMapping;
  129124. private _noMipmap;
  129125. private _onLoad;
  129126. private _onError;
  129127. /** The size of the cubemap. */
  129128. private _size;
  129129. /** The buffer of the image. */
  129130. private _buffer;
  129131. /** The width of the input image. */
  129132. private _width;
  129133. /** The height of the input image. */
  129134. private _height;
  129135. /** The URL to the image. */
  129136. url: string;
  129137. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129138. coordinatesMode: number;
  129139. /**
  129140. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129141. * @param url The location of the image
  129142. * @param scene The scene the texture will be used in
  129143. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129144. * @param noMipmap Forces to not generate the mipmap if true
  129145. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129146. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129147. * @param onLoad — defines a callback called when texture is loaded
  129148. * @param onError — defines a callback called if there is an error
  129149. */
  129150. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129151. /**
  129152. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129153. */
  129154. private loadImage;
  129155. /**
  129156. * Convert the image buffer into a cubemap and create a CubeTexture.
  129157. */
  129158. private loadTexture;
  129159. /**
  129160. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129161. * @param buffer The ArrayBuffer that should be converted.
  129162. * @returns The buffer as Float32Array.
  129163. */
  129164. private getFloat32ArrayFromArrayBuffer;
  129165. /**
  129166. * Get the current class name of the texture useful for serialization or dynamic coding.
  129167. * @returns "EquiRectangularCubeTexture"
  129168. */
  129169. getClassName(): string;
  129170. /**
  129171. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129172. * @returns A clone of the current EquiRectangularCubeTexture.
  129173. */
  129174. clone(): EquiRectangularCubeTexture;
  129175. }
  129176. }
  129177. declare module BABYLON {
  129178. /**
  129179. * Based on jsTGALoader - Javascript loader for TGA file
  129180. * By Vincent Thibault
  129181. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129182. */
  129183. export class TGATools {
  129184. private static _TYPE_INDEXED;
  129185. private static _TYPE_RGB;
  129186. private static _TYPE_GREY;
  129187. private static _TYPE_RLE_INDEXED;
  129188. private static _TYPE_RLE_RGB;
  129189. private static _TYPE_RLE_GREY;
  129190. private static _ORIGIN_MASK;
  129191. private static _ORIGIN_SHIFT;
  129192. private static _ORIGIN_BL;
  129193. private static _ORIGIN_BR;
  129194. private static _ORIGIN_UL;
  129195. private static _ORIGIN_UR;
  129196. /**
  129197. * Gets the header of a TGA file
  129198. * @param data defines the TGA data
  129199. * @returns the header
  129200. */
  129201. static GetTGAHeader(data: Uint8Array): any;
  129202. /**
  129203. * Uploads TGA content to a Babylon Texture
  129204. * @hidden
  129205. */
  129206. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129207. /** @hidden */
  129208. 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;
  129209. /** @hidden */
  129210. 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;
  129211. /** @hidden */
  129212. 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;
  129213. /** @hidden */
  129214. 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;
  129215. /** @hidden */
  129216. 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;
  129217. /** @hidden */
  129218. 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;
  129219. }
  129220. }
  129221. declare module BABYLON {
  129222. /**
  129223. * Implementation of the TGA Texture Loader.
  129224. * @hidden
  129225. */
  129226. export class _TGATextureLoader implements IInternalTextureLoader {
  129227. /**
  129228. * Defines wether the loader supports cascade loading the different faces.
  129229. */
  129230. readonly supportCascades: boolean;
  129231. /**
  129232. * This returns if the loader support the current file information.
  129233. * @param extension defines the file extension of the file being loaded
  129234. * @returns true if the loader can load the specified file
  129235. */
  129236. canLoad(extension: string): boolean;
  129237. /**
  129238. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129239. * @param data contains the texture data
  129240. * @param texture defines the BabylonJS internal texture
  129241. * @param createPolynomials will be true if polynomials have been requested
  129242. * @param onLoad defines the callback to trigger once the texture is ready
  129243. * @param onError defines the callback to trigger in case of error
  129244. */
  129245. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129246. /**
  129247. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129248. * @param data contains the texture data
  129249. * @param texture defines the BabylonJS internal texture
  129250. * @param callback defines the method to call once ready to upload
  129251. */
  129252. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129253. }
  129254. }
  129255. declare module BABYLON {
  129256. /**
  129257. * Info about the .basis files
  129258. */
  129259. class BasisFileInfo {
  129260. /**
  129261. * If the file has alpha
  129262. */
  129263. hasAlpha: boolean;
  129264. /**
  129265. * Info about each image of the basis file
  129266. */
  129267. images: Array<{
  129268. levels: Array<{
  129269. width: number;
  129270. height: number;
  129271. transcodedPixels: ArrayBufferView;
  129272. }>;
  129273. }>;
  129274. }
  129275. /**
  129276. * Result of transcoding a basis file
  129277. */
  129278. class TranscodeResult {
  129279. /**
  129280. * Info about the .basis file
  129281. */
  129282. fileInfo: BasisFileInfo;
  129283. /**
  129284. * Format to use when loading the file
  129285. */
  129286. format: number;
  129287. }
  129288. /**
  129289. * Configuration options for the Basis transcoder
  129290. */
  129291. export class BasisTranscodeConfiguration {
  129292. /**
  129293. * Supported compression formats used to determine the supported output format of the transcoder
  129294. */
  129295. supportedCompressionFormats?: {
  129296. /**
  129297. * etc1 compression format
  129298. */
  129299. etc1?: boolean;
  129300. /**
  129301. * s3tc compression format
  129302. */
  129303. s3tc?: boolean;
  129304. /**
  129305. * pvrtc compression format
  129306. */
  129307. pvrtc?: boolean;
  129308. /**
  129309. * etc2 compression format
  129310. */
  129311. etc2?: boolean;
  129312. };
  129313. /**
  129314. * If mipmap levels should be loaded for transcoded images (Default: true)
  129315. */
  129316. loadMipmapLevels?: boolean;
  129317. /**
  129318. * Index of a single image to load (Default: all images)
  129319. */
  129320. loadSingleImage?: number;
  129321. }
  129322. /**
  129323. * Used to load .Basis files
  129324. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129325. */
  129326. export class BasisTools {
  129327. private static _IgnoreSupportedFormats;
  129328. /**
  129329. * URL to use when loading the basis transcoder
  129330. */
  129331. static JSModuleURL: string;
  129332. /**
  129333. * URL to use when loading the wasm module for the transcoder
  129334. */
  129335. static WasmModuleURL: string;
  129336. /**
  129337. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129338. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129339. * @returns internal format corresponding to the Basis format
  129340. */
  129341. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129342. private static _WorkerPromise;
  129343. private static _Worker;
  129344. private static _actionId;
  129345. private static _CreateWorkerAsync;
  129346. /**
  129347. * Transcodes a loaded image file to compressed pixel data
  129348. * @param data image data to transcode
  129349. * @param config configuration options for the transcoding
  129350. * @returns a promise resulting in the transcoded image
  129351. */
  129352. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129353. /**
  129354. * Loads a texture from the transcode result
  129355. * @param texture texture load to
  129356. * @param transcodeResult the result of transcoding the basis file to load from
  129357. */
  129358. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129359. }
  129360. }
  129361. declare module BABYLON {
  129362. /**
  129363. * Loader for .basis file format
  129364. */
  129365. export class _BasisTextureLoader implements IInternalTextureLoader {
  129366. /**
  129367. * Defines whether the loader supports cascade loading the different faces.
  129368. */
  129369. readonly supportCascades: boolean;
  129370. /**
  129371. * This returns if the loader support the current file information.
  129372. * @param extension defines the file extension of the file being loaded
  129373. * @returns true if the loader can load the specified file
  129374. */
  129375. canLoad(extension: string): boolean;
  129376. /**
  129377. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129378. * @param data contains the texture data
  129379. * @param texture defines the BabylonJS internal texture
  129380. * @param createPolynomials will be true if polynomials have been requested
  129381. * @param onLoad defines the callback to trigger once the texture is ready
  129382. * @param onError defines the callback to trigger in case of error
  129383. */
  129384. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129385. /**
  129386. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129387. * @param data contains the texture data
  129388. * @param texture defines the BabylonJS internal texture
  129389. * @param callback defines the method to call once ready to upload
  129390. */
  129391. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129392. }
  129393. }
  129394. declare module BABYLON {
  129395. /**
  129396. * 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.
  129397. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129398. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129399. */
  129400. export class CustomProceduralTexture extends ProceduralTexture {
  129401. private _animate;
  129402. private _time;
  129403. private _config;
  129404. private _texturePath;
  129405. /**
  129406. * Instantiates a new Custom Procedural Texture.
  129407. * 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.
  129408. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129409. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129410. * @param name Define the name of the texture
  129411. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129412. * @param size Define the size of the texture to create
  129413. * @param scene Define the scene the texture belongs to
  129414. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129415. * @param generateMipMaps Define if the texture should creates mip maps or not
  129416. */
  129417. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129418. private _loadJson;
  129419. /**
  129420. * Is the texture ready to be used ? (rendered at least once)
  129421. * @returns true if ready, otherwise, false.
  129422. */
  129423. isReady(): boolean;
  129424. /**
  129425. * Render the texture to its associated render target.
  129426. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129427. */
  129428. render(useCameraPostProcess?: boolean): void;
  129429. /**
  129430. * Update the list of dependant textures samplers in the shader.
  129431. */
  129432. updateTextures(): void;
  129433. /**
  129434. * Update the uniform values of the procedural texture in the shader.
  129435. */
  129436. updateShaderUniforms(): void;
  129437. /**
  129438. * Define if the texture animates or not.
  129439. */
  129440. get animate(): boolean;
  129441. set animate(value: boolean);
  129442. }
  129443. }
  129444. declare module BABYLON {
  129445. /** @hidden */
  129446. export var noisePixelShader: {
  129447. name: string;
  129448. shader: string;
  129449. };
  129450. }
  129451. declare module BABYLON {
  129452. /**
  129453. * Class used to generate noise procedural textures
  129454. */
  129455. export class NoiseProceduralTexture extends ProceduralTexture {
  129456. private _time;
  129457. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129458. brightness: number;
  129459. /** Defines the number of octaves to process */
  129460. octaves: number;
  129461. /** Defines the level of persistence (0.8 by default) */
  129462. persistence: number;
  129463. /** Gets or sets animation speed factor (default is 1) */
  129464. animationSpeedFactor: number;
  129465. /**
  129466. * Creates a new NoiseProceduralTexture
  129467. * @param name defines the name fo the texture
  129468. * @param size defines the size of the texture (default is 256)
  129469. * @param scene defines the hosting scene
  129470. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129471. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129472. */
  129473. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129474. private _updateShaderUniforms;
  129475. protected _getDefines(): string;
  129476. /** Generate the current state of the procedural texture */
  129477. render(useCameraPostProcess?: boolean): void;
  129478. /**
  129479. * Serializes this noise procedural texture
  129480. * @returns a serialized noise procedural texture object
  129481. */
  129482. serialize(): any;
  129483. /**
  129484. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129485. * @param parsedTexture defines parsed texture data
  129486. * @param scene defines the current scene
  129487. * @param rootUrl defines the root URL containing noise procedural texture information
  129488. * @returns a parsed NoiseProceduralTexture
  129489. */
  129490. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129491. }
  129492. }
  129493. declare module BABYLON {
  129494. /**
  129495. * Raw cube texture where the raw buffers are passed in
  129496. */
  129497. export class RawCubeTexture extends CubeTexture {
  129498. /**
  129499. * Creates a cube texture where the raw buffers are passed in.
  129500. * @param scene defines the scene the texture is attached to
  129501. * @param data defines the array of data to use to create each face
  129502. * @param size defines the size of the textures
  129503. * @param format defines the format of the data
  129504. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129505. * @param generateMipMaps defines if the engine should generate the mip levels
  129506. * @param invertY defines if data must be stored with Y axis inverted
  129507. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129508. * @param compression defines the compression used (null by default)
  129509. */
  129510. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129511. /**
  129512. * Updates the raw cube texture.
  129513. * @param data defines the data to store
  129514. * @param format defines the data format
  129515. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129516. * @param invertY defines if data must be stored with Y axis inverted
  129517. * @param compression defines the compression used (null by default)
  129518. * @param level defines which level of the texture to update
  129519. */
  129520. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129521. /**
  129522. * Updates a raw cube texture with RGBD encoded data.
  129523. * @param data defines the array of data [mipmap][face] to use to create each face
  129524. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129525. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129526. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129527. * @returns a promsie that resolves when the operation is complete
  129528. */
  129529. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129530. /**
  129531. * Clones the raw cube texture.
  129532. * @return a new cube texture
  129533. */
  129534. clone(): CubeTexture;
  129535. /** @hidden */
  129536. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129537. }
  129538. }
  129539. declare module BABYLON {
  129540. /**
  129541. * Class used to store 3D textures containing user data
  129542. */
  129543. export class RawTexture3D extends Texture {
  129544. /** Gets or sets the texture format to use */
  129545. format: number;
  129546. private _engine;
  129547. /**
  129548. * Create a new RawTexture3D
  129549. * @param data defines the data of the texture
  129550. * @param width defines the width of the texture
  129551. * @param height defines the height of the texture
  129552. * @param depth defines the depth of the texture
  129553. * @param format defines the texture format to use
  129554. * @param scene defines the hosting scene
  129555. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129556. * @param invertY defines if texture must be stored with Y axis inverted
  129557. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129558. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129559. */
  129560. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129561. /** Gets or sets the texture format to use */
  129562. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129563. /**
  129564. * Update the texture with new data
  129565. * @param data defines the data to store in the texture
  129566. */
  129567. update(data: ArrayBufferView): void;
  129568. }
  129569. }
  129570. declare module BABYLON {
  129571. /**
  129572. * Class used to store 2D array textures containing user data
  129573. */
  129574. export class RawTexture2DArray extends Texture {
  129575. /** Gets or sets the texture format to use */
  129576. format: number;
  129577. private _engine;
  129578. /**
  129579. * Create a new RawTexture2DArray
  129580. * @param data defines the data of the texture
  129581. * @param width defines the width of the texture
  129582. * @param height defines the height of the texture
  129583. * @param depth defines the number of layers of the texture
  129584. * @param format defines the texture format to use
  129585. * @param scene defines the hosting scene
  129586. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129587. * @param invertY defines if texture must be stored with Y axis inverted
  129588. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129589. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129590. */
  129591. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129592. /** Gets or sets the texture format to use */
  129593. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129594. /**
  129595. * Update the texture with new data
  129596. * @param data defines the data to store in the texture
  129597. */
  129598. update(data: ArrayBufferView): void;
  129599. }
  129600. }
  129601. declare module BABYLON {
  129602. /**
  129603. * Creates a refraction texture used by refraction channel of the standard material.
  129604. * It is like a mirror but to see through a material.
  129605. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129606. */
  129607. export class RefractionTexture extends RenderTargetTexture {
  129608. /**
  129609. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129610. * 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.
  129611. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129612. */
  129613. refractionPlane: Plane;
  129614. /**
  129615. * Define how deep under the surface we should see.
  129616. */
  129617. depth: number;
  129618. /**
  129619. * Creates a refraction texture used by refraction channel of the standard material.
  129620. * It is like a mirror but to see through a material.
  129621. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129622. * @param name Define the texture name
  129623. * @param size Define the size of the underlying texture
  129624. * @param scene Define the scene the refraction belongs to
  129625. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129626. */
  129627. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129628. /**
  129629. * Clone the refraction texture.
  129630. * @returns the cloned texture
  129631. */
  129632. clone(): RefractionTexture;
  129633. /**
  129634. * Serialize the texture to a JSON representation you could use in Parse later on
  129635. * @returns the serialized JSON representation
  129636. */
  129637. serialize(): any;
  129638. }
  129639. }
  129640. declare module BABYLON {
  129641. /**
  129642. * Defines the options related to the creation of an HtmlElementTexture
  129643. */
  129644. export interface IHtmlElementTextureOptions {
  129645. /**
  129646. * Defines wether mip maps should be created or not.
  129647. */
  129648. generateMipMaps?: boolean;
  129649. /**
  129650. * Defines the sampling mode of the texture.
  129651. */
  129652. samplingMode?: number;
  129653. /**
  129654. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129655. */
  129656. engine: Nullable<ThinEngine>;
  129657. /**
  129658. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129659. */
  129660. scene: Nullable<Scene>;
  129661. }
  129662. /**
  129663. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129664. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129665. * is automatically managed.
  129666. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129667. * in your application.
  129668. *
  129669. * As the update is not automatic, you need to call them manually.
  129670. */
  129671. export class HtmlElementTexture extends BaseTexture {
  129672. /**
  129673. * The texture URL.
  129674. */
  129675. element: HTMLVideoElement | HTMLCanvasElement;
  129676. private static readonly DefaultOptions;
  129677. private _textureMatrix;
  129678. private _engine;
  129679. private _isVideo;
  129680. private _generateMipMaps;
  129681. private _samplingMode;
  129682. /**
  129683. * Instantiates a HtmlElementTexture from the following parameters.
  129684. *
  129685. * @param name Defines the name of the texture
  129686. * @param element Defines the video or canvas the texture is filled with
  129687. * @param options Defines the other none mandatory texture creation options
  129688. */
  129689. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129690. private _createInternalTexture;
  129691. /**
  129692. * Returns the texture matrix used in most of the material.
  129693. */
  129694. getTextureMatrix(): Matrix;
  129695. /**
  129696. * Updates the content of the texture.
  129697. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129698. */
  129699. update(invertY?: Nullable<boolean>): void;
  129700. }
  129701. }
  129702. declare module BABYLON {
  129703. /**
  129704. * Defines the basic options interface of a TexturePacker Frame
  129705. */
  129706. export interface ITexturePackerFrame {
  129707. /**
  129708. * The frame ID
  129709. */
  129710. id: number;
  129711. /**
  129712. * The frames Scale
  129713. */
  129714. scale: Vector2;
  129715. /**
  129716. * The Frames offset
  129717. */
  129718. offset: Vector2;
  129719. }
  129720. /**
  129721. * This is a support class for frame Data on texture packer sets.
  129722. */
  129723. export class TexturePackerFrame implements ITexturePackerFrame {
  129724. /**
  129725. * The frame ID
  129726. */
  129727. id: number;
  129728. /**
  129729. * The frames Scale
  129730. */
  129731. scale: Vector2;
  129732. /**
  129733. * The Frames offset
  129734. */
  129735. offset: Vector2;
  129736. /**
  129737. * Initializes a texture package frame.
  129738. * @param id The numerical frame identifier
  129739. * @param scale Scalar Vector2 for UV frame
  129740. * @param offset Vector2 for the frame position in UV units.
  129741. * @returns TexturePackerFrame
  129742. */
  129743. constructor(id: number, scale: Vector2, offset: Vector2);
  129744. }
  129745. }
  129746. declare module BABYLON {
  129747. /**
  129748. * Defines the basic options interface of a TexturePacker
  129749. */
  129750. export interface ITexturePackerOptions {
  129751. /**
  129752. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129753. */
  129754. map?: string[];
  129755. /**
  129756. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129757. */
  129758. uvsIn?: string;
  129759. /**
  129760. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129761. */
  129762. uvsOut?: string;
  129763. /**
  129764. * number representing the layout style. Defaults to LAYOUT_STRIP
  129765. */
  129766. layout?: number;
  129767. /**
  129768. * number of columns if using custom column count layout(2). This defaults to 4.
  129769. */
  129770. colnum?: number;
  129771. /**
  129772. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129773. */
  129774. updateInputMeshes?: boolean;
  129775. /**
  129776. * boolean flag to dispose all the source textures. Defaults to true.
  129777. */
  129778. disposeSources?: boolean;
  129779. /**
  129780. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129781. */
  129782. fillBlanks?: boolean;
  129783. /**
  129784. * string value representing the context fill style color. Defaults to 'black'.
  129785. */
  129786. customFillColor?: string;
  129787. /**
  129788. * Width and Height Value of each Frame in the TexturePacker Sets
  129789. */
  129790. frameSize?: number;
  129791. /**
  129792. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129793. */
  129794. paddingRatio?: number;
  129795. /**
  129796. * Number that declares the fill method for the padding gutter.
  129797. */
  129798. paddingMode?: number;
  129799. /**
  129800. * If in SUBUV_COLOR padding mode what color to use.
  129801. */
  129802. paddingColor?: Color3 | Color4;
  129803. }
  129804. /**
  129805. * Defines the basic interface of a TexturePacker JSON File
  129806. */
  129807. export interface ITexturePackerJSON {
  129808. /**
  129809. * The frame ID
  129810. */
  129811. name: string;
  129812. /**
  129813. * The base64 channel data
  129814. */
  129815. sets: any;
  129816. /**
  129817. * The options of the Packer
  129818. */
  129819. options: ITexturePackerOptions;
  129820. /**
  129821. * The frame data of the Packer
  129822. */
  129823. frames: Array<number>;
  129824. }
  129825. /**
  129826. * This is a support class that generates a series of packed texture sets.
  129827. * @see https://doc.babylonjs.com/babylon101/materials
  129828. */
  129829. export class TexturePacker {
  129830. /** Packer Layout Constant 0 */
  129831. static readonly LAYOUT_STRIP: number;
  129832. /** Packer Layout Constant 1 */
  129833. static readonly LAYOUT_POWER2: number;
  129834. /** Packer Layout Constant 2 */
  129835. static readonly LAYOUT_COLNUM: number;
  129836. /** Packer Layout Constant 0 */
  129837. static readonly SUBUV_WRAP: number;
  129838. /** Packer Layout Constant 1 */
  129839. static readonly SUBUV_EXTEND: number;
  129840. /** Packer Layout Constant 2 */
  129841. static readonly SUBUV_COLOR: number;
  129842. /** The Name of the Texture Package */
  129843. name: string;
  129844. /** The scene scope of the TexturePacker */
  129845. scene: Scene;
  129846. /** The Meshes to target */
  129847. meshes: AbstractMesh[];
  129848. /** Arguments passed with the Constructor */
  129849. options: ITexturePackerOptions;
  129850. /** The promise that is started upon initialization */
  129851. promise: Nullable<Promise<TexturePacker | string>>;
  129852. /** The Container object for the channel sets that are generated */
  129853. sets: object;
  129854. /** The Container array for the frames that are generated */
  129855. frames: TexturePackerFrame[];
  129856. /** The expected number of textures the system is parsing. */
  129857. private _expecting;
  129858. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129859. private _paddingValue;
  129860. /**
  129861. * Initializes a texture package series from an array of meshes or a single mesh.
  129862. * @param name The name of the package
  129863. * @param meshes The target meshes to compose the package from
  129864. * @param options The arguments that texture packer should follow while building.
  129865. * @param scene The scene which the textures are scoped to.
  129866. * @returns TexturePacker
  129867. */
  129868. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129869. /**
  129870. * Starts the package process
  129871. * @param resolve The promises resolution function
  129872. * @returns TexturePacker
  129873. */
  129874. private _createFrames;
  129875. /**
  129876. * Calculates the Size of the Channel Sets
  129877. * @returns Vector2
  129878. */
  129879. private _calculateSize;
  129880. /**
  129881. * Calculates the UV data for the frames.
  129882. * @param baseSize the base frameSize
  129883. * @param padding the base frame padding
  129884. * @param dtSize size of the Dynamic Texture for that channel
  129885. * @param dtUnits is 1/dtSize
  129886. * @param update flag to update the input meshes
  129887. */
  129888. private _calculateMeshUVFrames;
  129889. /**
  129890. * Calculates the frames Offset.
  129891. * @param index of the frame
  129892. * @returns Vector2
  129893. */
  129894. private _getFrameOffset;
  129895. /**
  129896. * Updates a Mesh to the frame data
  129897. * @param mesh that is the target
  129898. * @param frameID or the frame index
  129899. */
  129900. private _updateMeshUV;
  129901. /**
  129902. * Updates a Meshes materials to use the texture packer channels
  129903. * @param m is the mesh to target
  129904. * @param force all channels on the packer to be set.
  129905. */
  129906. private _updateTextureReferences;
  129907. /**
  129908. * Public method to set a Mesh to a frame
  129909. * @param m that is the target
  129910. * @param frameID or the frame index
  129911. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  129912. */
  129913. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  129914. /**
  129915. * Starts the async promise to compile the texture packer.
  129916. * @returns Promise<void>
  129917. */
  129918. processAsync(): Promise<void>;
  129919. /**
  129920. * Disposes all textures associated with this packer
  129921. */
  129922. dispose(): void;
  129923. /**
  129924. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  129925. * @param imageType is the image type to use.
  129926. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  129927. */
  129928. download(imageType?: string, quality?: number): void;
  129929. /**
  129930. * Public method to load a texturePacker JSON file.
  129931. * @param data of the JSON file in string format.
  129932. */
  129933. updateFromJSON(data: string): void;
  129934. }
  129935. }
  129936. declare module BABYLON {
  129937. /**
  129938. * Enum used to define the target of a block
  129939. */
  129940. export enum NodeMaterialBlockTargets {
  129941. /** Vertex shader */
  129942. Vertex = 1,
  129943. /** Fragment shader */
  129944. Fragment = 2,
  129945. /** Neutral */
  129946. Neutral = 4,
  129947. /** Vertex and Fragment */
  129948. VertexAndFragment = 3
  129949. }
  129950. }
  129951. declare module BABYLON {
  129952. /**
  129953. * Defines the kind of connection point for node based material
  129954. */
  129955. export enum NodeMaterialBlockConnectionPointTypes {
  129956. /** Float */
  129957. Float = 1,
  129958. /** Int */
  129959. Int = 2,
  129960. /** Vector2 */
  129961. Vector2 = 4,
  129962. /** Vector3 */
  129963. Vector3 = 8,
  129964. /** Vector4 */
  129965. Vector4 = 16,
  129966. /** Color3 */
  129967. Color3 = 32,
  129968. /** Color4 */
  129969. Color4 = 64,
  129970. /** Matrix */
  129971. Matrix = 128,
  129972. /** Detect type based on connection */
  129973. AutoDetect = 1024,
  129974. /** Output type that will be defined by input type */
  129975. BasedOnInput = 2048
  129976. }
  129977. }
  129978. declare module BABYLON {
  129979. /**
  129980. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129981. */
  129982. export enum NodeMaterialBlockConnectionPointMode {
  129983. /** Value is an uniform */
  129984. Uniform = 0,
  129985. /** Value is a mesh attribute */
  129986. Attribute = 1,
  129987. /** Value is a varying between vertex and fragment shaders */
  129988. Varying = 2,
  129989. /** Mode is undefined */
  129990. Undefined = 3
  129991. }
  129992. }
  129993. declare module BABYLON {
  129994. /**
  129995. * Enum used to define system values e.g. values automatically provided by the system
  129996. */
  129997. export enum NodeMaterialSystemValues {
  129998. /** World */
  129999. World = 1,
  130000. /** View */
  130001. View = 2,
  130002. /** Projection */
  130003. Projection = 3,
  130004. /** ViewProjection */
  130005. ViewProjection = 4,
  130006. /** WorldView */
  130007. WorldView = 5,
  130008. /** WorldViewProjection */
  130009. WorldViewProjection = 6,
  130010. /** CameraPosition */
  130011. CameraPosition = 7,
  130012. /** Fog Color */
  130013. FogColor = 8,
  130014. /** Delta time */
  130015. DeltaTime = 9
  130016. }
  130017. }
  130018. declare module BABYLON {
  130019. /**
  130020. * Root class for all node material optimizers
  130021. */
  130022. export class NodeMaterialOptimizer {
  130023. /**
  130024. * Function used to optimize a NodeMaterial graph
  130025. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130026. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130027. */
  130028. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130029. }
  130030. }
  130031. declare module BABYLON {
  130032. /**
  130033. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130034. */
  130035. export class TransformBlock extends NodeMaterialBlock {
  130036. /**
  130037. * Defines the value to use to complement W value to transform it to a Vector4
  130038. */
  130039. complementW: number;
  130040. /**
  130041. * Defines the value to use to complement z value to transform it to a Vector4
  130042. */
  130043. complementZ: number;
  130044. /**
  130045. * Creates a new TransformBlock
  130046. * @param name defines the block name
  130047. */
  130048. constructor(name: string);
  130049. /**
  130050. * Gets the current class name
  130051. * @returns the class name
  130052. */
  130053. getClassName(): string;
  130054. /**
  130055. * Gets the vector input
  130056. */
  130057. get vector(): NodeMaterialConnectionPoint;
  130058. /**
  130059. * Gets the output component
  130060. */
  130061. get output(): NodeMaterialConnectionPoint;
  130062. /**
  130063. * Gets the xyz output component
  130064. */
  130065. get xyz(): NodeMaterialConnectionPoint;
  130066. /**
  130067. * Gets the matrix transform input
  130068. */
  130069. get transform(): NodeMaterialConnectionPoint;
  130070. protected _buildBlock(state: NodeMaterialBuildState): this;
  130071. serialize(): any;
  130072. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130073. protected _dumpPropertiesCode(): string;
  130074. }
  130075. }
  130076. declare module BABYLON {
  130077. /**
  130078. * Block used to output the vertex position
  130079. */
  130080. export class VertexOutputBlock extends NodeMaterialBlock {
  130081. /**
  130082. * Creates a new VertexOutputBlock
  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 vector input component
  130093. */
  130094. get vector(): NodeMaterialConnectionPoint;
  130095. protected _buildBlock(state: NodeMaterialBuildState): this;
  130096. }
  130097. }
  130098. declare module BABYLON {
  130099. /**
  130100. * Block used to output the final color
  130101. */
  130102. export class FragmentOutputBlock extends NodeMaterialBlock {
  130103. /**
  130104. * Create a new FragmentOutputBlock
  130105. * @param name defines the block name
  130106. */
  130107. constructor(name: string);
  130108. /**
  130109. * Gets the current class name
  130110. * @returns the class name
  130111. */
  130112. getClassName(): string;
  130113. /**
  130114. * Gets the rgba input component
  130115. */
  130116. get rgba(): NodeMaterialConnectionPoint;
  130117. /**
  130118. * Gets the rgb input component
  130119. */
  130120. get rgb(): NodeMaterialConnectionPoint;
  130121. /**
  130122. * Gets the a input component
  130123. */
  130124. get a(): NodeMaterialConnectionPoint;
  130125. protected _buildBlock(state: NodeMaterialBuildState): this;
  130126. }
  130127. }
  130128. declare module BABYLON {
  130129. /**
  130130. * Block used to read a reflection texture from a sampler
  130131. */
  130132. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130133. private _define3DName;
  130134. private _defineCubicName;
  130135. private _defineExplicitName;
  130136. private _defineProjectionName;
  130137. private _defineLocalCubicName;
  130138. private _defineSphericalName;
  130139. private _definePlanarName;
  130140. private _defineEquirectangularName;
  130141. private _defineMirroredEquirectangularFixedName;
  130142. private _defineEquirectangularFixedName;
  130143. private _defineSkyboxName;
  130144. private _cubeSamplerName;
  130145. private _2DSamplerName;
  130146. private _positionUVWName;
  130147. private _directionWName;
  130148. private _reflectionCoordsName;
  130149. private _reflection2DCoordsName;
  130150. private _reflectionColorName;
  130151. private _reflectionMatrixName;
  130152. /**
  130153. * Gets or sets the texture associated with the node
  130154. */
  130155. texture: Nullable<BaseTexture>;
  130156. /**
  130157. * Create a new TextureBlock
  130158. * @param name defines the block name
  130159. */
  130160. constructor(name: string);
  130161. /**
  130162. * Gets the current class name
  130163. * @returns the class name
  130164. */
  130165. getClassName(): string;
  130166. /**
  130167. * Gets the world position input component
  130168. */
  130169. get position(): NodeMaterialConnectionPoint;
  130170. /**
  130171. * Gets the world position input component
  130172. */
  130173. get worldPosition(): NodeMaterialConnectionPoint;
  130174. /**
  130175. * Gets the world normal input component
  130176. */
  130177. get worldNormal(): NodeMaterialConnectionPoint;
  130178. /**
  130179. * Gets the world input component
  130180. */
  130181. get world(): NodeMaterialConnectionPoint;
  130182. /**
  130183. * Gets the camera (or eye) position component
  130184. */
  130185. get cameraPosition(): NodeMaterialConnectionPoint;
  130186. /**
  130187. * Gets the view input component
  130188. */
  130189. get view(): NodeMaterialConnectionPoint;
  130190. /**
  130191. * Gets the rgb output component
  130192. */
  130193. get rgb(): NodeMaterialConnectionPoint;
  130194. /**
  130195. * Gets the r output component
  130196. */
  130197. get r(): NodeMaterialConnectionPoint;
  130198. /**
  130199. * Gets the g output component
  130200. */
  130201. get g(): NodeMaterialConnectionPoint;
  130202. /**
  130203. * Gets the b output component
  130204. */
  130205. get b(): NodeMaterialConnectionPoint;
  130206. autoConfigure(material: NodeMaterial): void;
  130207. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130208. isReady(): boolean;
  130209. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130210. private _injectVertexCode;
  130211. private _writeOutput;
  130212. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130213. protected _dumpPropertiesCode(): string;
  130214. serialize(): any;
  130215. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130216. }
  130217. }
  130218. declare module BABYLON {
  130219. /**
  130220. * Interface used to configure the node material editor
  130221. */
  130222. export interface INodeMaterialEditorOptions {
  130223. /** Define the URl to load node editor script */
  130224. editorURL?: string;
  130225. }
  130226. /** @hidden */
  130227. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130228. NORMAL: boolean;
  130229. TANGENT: boolean;
  130230. UV1: boolean;
  130231. /** BONES */
  130232. NUM_BONE_INFLUENCERS: number;
  130233. BonesPerMesh: number;
  130234. BONETEXTURE: boolean;
  130235. /** MORPH TARGETS */
  130236. MORPHTARGETS: boolean;
  130237. MORPHTARGETS_NORMAL: boolean;
  130238. MORPHTARGETS_TANGENT: boolean;
  130239. MORPHTARGETS_UV: boolean;
  130240. NUM_MORPH_INFLUENCERS: number;
  130241. /** IMAGE PROCESSING */
  130242. IMAGEPROCESSING: boolean;
  130243. VIGNETTE: boolean;
  130244. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130245. VIGNETTEBLENDMODEOPAQUE: boolean;
  130246. TONEMAPPING: boolean;
  130247. TONEMAPPING_ACES: boolean;
  130248. CONTRAST: boolean;
  130249. EXPOSURE: boolean;
  130250. COLORCURVES: boolean;
  130251. COLORGRADING: boolean;
  130252. COLORGRADING3D: boolean;
  130253. SAMPLER3DGREENDEPTH: boolean;
  130254. SAMPLER3DBGRMAP: boolean;
  130255. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130256. /** MISC. */
  130257. BUMPDIRECTUV: number;
  130258. constructor();
  130259. setValue(name: string, value: boolean): void;
  130260. }
  130261. /**
  130262. * Class used to configure NodeMaterial
  130263. */
  130264. export interface INodeMaterialOptions {
  130265. /**
  130266. * Defines if blocks should emit comments
  130267. */
  130268. emitComments: boolean;
  130269. }
  130270. /**
  130271. * Class used to create a node based material built by assembling shader blocks
  130272. */
  130273. export class NodeMaterial extends PushMaterial {
  130274. private static _BuildIdGenerator;
  130275. private _options;
  130276. private _vertexCompilationState;
  130277. private _fragmentCompilationState;
  130278. private _sharedData;
  130279. private _buildId;
  130280. private _buildWasSuccessful;
  130281. private _cachedWorldViewMatrix;
  130282. private _cachedWorldViewProjectionMatrix;
  130283. private _optimizers;
  130284. private _animationFrame;
  130285. /** Define the Url to load node editor script */
  130286. static EditorURL: string;
  130287. /** Define the Url to load snippets */
  130288. static SnippetUrl: string;
  130289. private BJSNODEMATERIALEDITOR;
  130290. /** Get the inspector from bundle or global */
  130291. private _getGlobalNodeMaterialEditor;
  130292. /**
  130293. * Gets or sets data used by visual editor
  130294. * @see https://nme.babylonjs.com
  130295. */
  130296. editorData: any;
  130297. /**
  130298. * 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)
  130299. */
  130300. ignoreAlpha: boolean;
  130301. /**
  130302. * Defines the maximum number of lights that can be used in the material
  130303. */
  130304. maxSimultaneousLights: number;
  130305. /**
  130306. * Observable raised when the material is built
  130307. */
  130308. onBuildObservable: Observable<NodeMaterial>;
  130309. /**
  130310. * Gets or sets the root nodes of the material vertex shader
  130311. */
  130312. _vertexOutputNodes: NodeMaterialBlock[];
  130313. /**
  130314. * Gets or sets the root nodes of the material fragment (pixel) shader
  130315. */
  130316. _fragmentOutputNodes: NodeMaterialBlock[];
  130317. /** Gets or sets options to control the node material overall behavior */
  130318. get options(): INodeMaterialOptions;
  130319. set options(options: INodeMaterialOptions);
  130320. /**
  130321. * Default configuration related to image processing available in the standard Material.
  130322. */
  130323. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130324. /**
  130325. * Gets the image processing configuration used either in this material.
  130326. */
  130327. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130328. /**
  130329. * Sets the Default image processing configuration used either in the this material.
  130330. *
  130331. * If sets to null, the scene one is in use.
  130332. */
  130333. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130334. /**
  130335. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130336. */
  130337. attachedBlocks: NodeMaterialBlock[];
  130338. /**
  130339. * Create a new node based material
  130340. * @param name defines the material name
  130341. * @param scene defines the hosting scene
  130342. * @param options defines creation option
  130343. */
  130344. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130345. /**
  130346. * Gets the current class name of the material e.g. "NodeMaterial"
  130347. * @returns the class name
  130348. */
  130349. getClassName(): string;
  130350. /**
  130351. * Keep track of the image processing observer to allow dispose and replace.
  130352. */
  130353. private _imageProcessingObserver;
  130354. /**
  130355. * Attaches a new image processing configuration to the Standard Material.
  130356. * @param configuration
  130357. */
  130358. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130359. /**
  130360. * Get a block by its name
  130361. * @param name defines the name of the block to retrieve
  130362. * @returns the required block or null if not found
  130363. */
  130364. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130365. /**
  130366. * Get a block by its name
  130367. * @param predicate defines the predicate used to find the good candidate
  130368. * @returns the required block or null if not found
  130369. */
  130370. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130371. /**
  130372. * Get an input block by its name
  130373. * @param predicate defines the predicate used to find the good candidate
  130374. * @returns the required input block or null if not found
  130375. */
  130376. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130377. /**
  130378. * Gets the list of input blocks attached to this material
  130379. * @returns an array of InputBlocks
  130380. */
  130381. getInputBlocks(): InputBlock[];
  130382. /**
  130383. * Adds a new optimizer to the list of optimizers
  130384. * @param optimizer defines the optimizers to add
  130385. * @returns the current material
  130386. */
  130387. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130388. /**
  130389. * Remove an optimizer from the list of optimizers
  130390. * @param optimizer defines the optimizers to remove
  130391. * @returns the current material
  130392. */
  130393. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130394. /**
  130395. * Add a new block to the list of output nodes
  130396. * @param node defines the node to add
  130397. * @returns the current material
  130398. */
  130399. addOutputNode(node: NodeMaterialBlock): this;
  130400. /**
  130401. * Remove a block from the list of root nodes
  130402. * @param node defines the node to remove
  130403. * @returns the current material
  130404. */
  130405. removeOutputNode(node: NodeMaterialBlock): this;
  130406. private _addVertexOutputNode;
  130407. private _removeVertexOutputNode;
  130408. private _addFragmentOutputNode;
  130409. private _removeFragmentOutputNode;
  130410. /**
  130411. * Specifies if the material will require alpha blending
  130412. * @returns a boolean specifying if alpha blending is needed
  130413. */
  130414. needAlphaBlending(): boolean;
  130415. /**
  130416. * Specifies if this material should be rendered in alpha test mode
  130417. * @returns a boolean specifying if an alpha test is needed.
  130418. */
  130419. needAlphaTesting(): boolean;
  130420. private _initializeBlock;
  130421. private _resetDualBlocks;
  130422. /**
  130423. * Remove a block from the current node material
  130424. * @param block defines the block to remove
  130425. */
  130426. removeBlock(block: NodeMaterialBlock): void;
  130427. /**
  130428. * Build the material and generates the inner effect
  130429. * @param verbose defines if the build should log activity
  130430. */
  130431. build(verbose?: boolean): void;
  130432. /**
  130433. * Runs an otpimization phase to try to improve the shader code
  130434. */
  130435. optimize(): void;
  130436. private _prepareDefinesForAttributes;
  130437. /**
  130438. * Get if the submesh is ready to be used and all its information available.
  130439. * Child classes can use it to update shaders
  130440. * @param mesh defines the mesh to check
  130441. * @param subMesh defines which submesh to check
  130442. * @param useInstances specifies that instances should be used
  130443. * @returns a boolean indicating that the submesh is ready or not
  130444. */
  130445. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130446. /**
  130447. * Get a string representing the shaders built by the current node graph
  130448. */
  130449. get compiledShaders(): string;
  130450. /**
  130451. * Binds the world matrix to the material
  130452. * @param world defines the world transformation matrix
  130453. */
  130454. bindOnlyWorldMatrix(world: Matrix): void;
  130455. /**
  130456. * Binds the submesh to this material by preparing the effect and shader to draw
  130457. * @param world defines the world transformation matrix
  130458. * @param mesh defines the mesh containing the submesh
  130459. * @param subMesh defines the submesh to bind the material to
  130460. */
  130461. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130462. /**
  130463. * Gets the active textures from the material
  130464. * @returns an array of textures
  130465. */
  130466. getActiveTextures(): BaseTexture[];
  130467. /**
  130468. * Gets the list of texture blocks
  130469. * @returns an array of texture blocks
  130470. */
  130471. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130472. /**
  130473. * Specifies if the material uses a texture
  130474. * @param texture defines the texture to check against the material
  130475. * @returns a boolean specifying if the material uses the texture
  130476. */
  130477. hasTexture(texture: BaseTexture): boolean;
  130478. /**
  130479. * Disposes the material
  130480. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130481. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130482. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130483. */
  130484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130485. /** Creates the node editor window. */
  130486. private _createNodeEditor;
  130487. /**
  130488. * Launch the node material editor
  130489. * @param config Define the configuration of the editor
  130490. * @return a promise fulfilled when the node editor is visible
  130491. */
  130492. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130493. /**
  130494. * Clear the current material
  130495. */
  130496. clear(): void;
  130497. /**
  130498. * Clear the current material and set it to a default state
  130499. */
  130500. setToDefault(): void;
  130501. /**
  130502. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130503. * @param url defines the url to load from
  130504. * @returns a promise that will fullfil when the material is fully loaded
  130505. */
  130506. loadAsync(url: string): Promise<void>;
  130507. private _gatherBlocks;
  130508. /**
  130509. * Generate a string containing the code declaration required to create an equivalent of this material
  130510. * @returns a string
  130511. */
  130512. generateCode(): string;
  130513. /**
  130514. * Serializes this material in a JSON representation
  130515. * @returns the serialized material object
  130516. */
  130517. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130518. private _restoreConnections;
  130519. /**
  130520. * Clear the current graph and load a new one from a serialization object
  130521. * @param source defines the JSON representation of the material
  130522. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130523. */
  130524. loadFromSerialization(source: any, rootUrl?: string): void;
  130525. /**
  130526. * Creates a node material from parsed material data
  130527. * @param source defines the JSON representation of the material
  130528. * @param scene defines the hosting scene
  130529. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130530. * @returns a new node material
  130531. */
  130532. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130533. /**
  130534. * Creates a node material from a snippet saved in a remote file
  130535. * @param name defines the name of the material to create
  130536. * @param url defines the url to load from
  130537. * @param scene defines the hosting scene
  130538. * @returns a promise that will resolve to the new node material
  130539. */
  130540. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130541. /**
  130542. * Creates a node material from a snippet saved by the node material editor
  130543. * @param snippetId defines the snippet to load
  130544. * @param scene defines the hosting scene
  130545. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130546. * @returns a promise that will resolve to the new node material
  130547. */
  130548. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130549. /**
  130550. * Creates a new node material set to default basic configuration
  130551. * @param name defines the name of the material
  130552. * @param scene defines the hosting scene
  130553. * @returns a new NodeMaterial
  130554. */
  130555. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130556. }
  130557. }
  130558. declare module BABYLON {
  130559. /**
  130560. * Block used to read a texture from a sampler
  130561. */
  130562. export class TextureBlock extends NodeMaterialBlock {
  130563. private _defineName;
  130564. private _linearDefineName;
  130565. private _tempTextureRead;
  130566. private _samplerName;
  130567. private _transformedUVName;
  130568. private _textureTransformName;
  130569. private _textureInfoName;
  130570. private _mainUVName;
  130571. private _mainUVDefineName;
  130572. /**
  130573. * Gets or sets the texture associated with the node
  130574. */
  130575. texture: Nullable<Texture>;
  130576. /**
  130577. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130578. */
  130579. convertToGammaSpace: boolean;
  130580. /**
  130581. * Create a new TextureBlock
  130582. * @param name defines the block name
  130583. */
  130584. constructor(name: string);
  130585. /**
  130586. * Gets the current class name
  130587. * @returns the class name
  130588. */
  130589. getClassName(): string;
  130590. /**
  130591. * Gets the uv input component
  130592. */
  130593. get uv(): NodeMaterialConnectionPoint;
  130594. /**
  130595. * Gets the rgba output component
  130596. */
  130597. get rgba(): NodeMaterialConnectionPoint;
  130598. /**
  130599. * Gets the rgb output component
  130600. */
  130601. get rgb(): NodeMaterialConnectionPoint;
  130602. /**
  130603. * Gets the r output component
  130604. */
  130605. get r(): NodeMaterialConnectionPoint;
  130606. /**
  130607. * Gets the g output component
  130608. */
  130609. get g(): NodeMaterialConnectionPoint;
  130610. /**
  130611. * Gets the b output component
  130612. */
  130613. get b(): NodeMaterialConnectionPoint;
  130614. /**
  130615. * Gets the a output component
  130616. */
  130617. get a(): NodeMaterialConnectionPoint;
  130618. get target(): NodeMaterialBlockTargets;
  130619. autoConfigure(material: NodeMaterial): void;
  130620. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130622. isReady(): boolean;
  130623. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130624. private get _isMixed();
  130625. private _injectVertexCode;
  130626. private _writeTextureRead;
  130627. private _writeOutput;
  130628. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130629. protected _dumpPropertiesCode(): string;
  130630. serialize(): any;
  130631. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130632. }
  130633. }
  130634. declare module BABYLON {
  130635. /**
  130636. * Class used to store shared data between 2 NodeMaterialBuildState
  130637. */
  130638. export class NodeMaterialBuildStateSharedData {
  130639. /**
  130640. * Gets the list of emitted varyings
  130641. */
  130642. temps: string[];
  130643. /**
  130644. * Gets the list of emitted varyings
  130645. */
  130646. varyings: string[];
  130647. /**
  130648. * Gets the varying declaration string
  130649. */
  130650. varyingDeclaration: string;
  130651. /**
  130652. * Input blocks
  130653. */
  130654. inputBlocks: InputBlock[];
  130655. /**
  130656. * Input blocks
  130657. */
  130658. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130659. /**
  130660. * Bindable blocks (Blocks that need to set data to the effect)
  130661. */
  130662. bindableBlocks: NodeMaterialBlock[];
  130663. /**
  130664. * List of blocks that can provide a compilation fallback
  130665. */
  130666. blocksWithFallbacks: NodeMaterialBlock[];
  130667. /**
  130668. * List of blocks that can provide a define update
  130669. */
  130670. blocksWithDefines: NodeMaterialBlock[];
  130671. /**
  130672. * List of blocks that can provide a repeatable content
  130673. */
  130674. repeatableContentBlocks: NodeMaterialBlock[];
  130675. /**
  130676. * List of blocks that can provide a dynamic list of uniforms
  130677. */
  130678. dynamicUniformBlocks: NodeMaterialBlock[];
  130679. /**
  130680. * List of blocks that can block the isReady function for the material
  130681. */
  130682. blockingBlocks: NodeMaterialBlock[];
  130683. /**
  130684. * Gets the list of animated inputs
  130685. */
  130686. animatedInputs: InputBlock[];
  130687. /**
  130688. * Build Id used to avoid multiple recompilations
  130689. */
  130690. buildId: number;
  130691. /** List of emitted variables */
  130692. variableNames: {
  130693. [key: string]: number;
  130694. };
  130695. /** List of emitted defines */
  130696. defineNames: {
  130697. [key: string]: number;
  130698. };
  130699. /** Should emit comments? */
  130700. emitComments: boolean;
  130701. /** Emit build activity */
  130702. verbose: boolean;
  130703. /** Gets or sets the hosting scene */
  130704. scene: Scene;
  130705. /**
  130706. * Gets the compilation hints emitted at compilation time
  130707. */
  130708. hints: {
  130709. needWorldViewMatrix: boolean;
  130710. needWorldViewProjectionMatrix: boolean;
  130711. needAlphaBlending: boolean;
  130712. needAlphaTesting: boolean;
  130713. };
  130714. /**
  130715. * List of compilation checks
  130716. */
  130717. checks: {
  130718. emitVertex: boolean;
  130719. emitFragment: boolean;
  130720. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130721. };
  130722. /** Creates a new shared data */
  130723. constructor();
  130724. /**
  130725. * Emits console errors and exceptions if there is a failing check
  130726. */
  130727. emitErrors(): void;
  130728. }
  130729. }
  130730. declare module BABYLON {
  130731. /**
  130732. * Class used to store node based material build state
  130733. */
  130734. export class NodeMaterialBuildState {
  130735. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130736. supportUniformBuffers: boolean;
  130737. /**
  130738. * Gets the list of emitted attributes
  130739. */
  130740. attributes: string[];
  130741. /**
  130742. * Gets the list of emitted uniforms
  130743. */
  130744. uniforms: string[];
  130745. /**
  130746. * Gets the list of emitted constants
  130747. */
  130748. constants: string[];
  130749. /**
  130750. * Gets the list of emitted samplers
  130751. */
  130752. samplers: string[];
  130753. /**
  130754. * Gets the list of emitted functions
  130755. */
  130756. functions: {
  130757. [key: string]: string;
  130758. };
  130759. /**
  130760. * Gets the list of emitted extensions
  130761. */
  130762. extensions: {
  130763. [key: string]: string;
  130764. };
  130765. /**
  130766. * Gets the target of the compilation state
  130767. */
  130768. target: NodeMaterialBlockTargets;
  130769. /**
  130770. * Gets the list of emitted counters
  130771. */
  130772. counters: {
  130773. [key: string]: number;
  130774. };
  130775. /**
  130776. * Shared data between multiple NodeMaterialBuildState instances
  130777. */
  130778. sharedData: NodeMaterialBuildStateSharedData;
  130779. /** @hidden */
  130780. _vertexState: NodeMaterialBuildState;
  130781. /** @hidden */
  130782. _attributeDeclaration: string;
  130783. /** @hidden */
  130784. _uniformDeclaration: string;
  130785. /** @hidden */
  130786. _constantDeclaration: string;
  130787. /** @hidden */
  130788. _samplerDeclaration: string;
  130789. /** @hidden */
  130790. _varyingTransfer: string;
  130791. private _repeatableContentAnchorIndex;
  130792. /** @hidden */
  130793. _builtCompilationString: string;
  130794. /**
  130795. * Gets the emitted compilation strings
  130796. */
  130797. compilationString: string;
  130798. /**
  130799. * Finalize the compilation strings
  130800. * @param state defines the current compilation state
  130801. */
  130802. finalize(state: NodeMaterialBuildState): void;
  130803. /** @hidden */
  130804. get _repeatableContentAnchor(): string;
  130805. /** @hidden */
  130806. _getFreeVariableName(prefix: string): string;
  130807. /** @hidden */
  130808. _getFreeDefineName(prefix: string): string;
  130809. /** @hidden */
  130810. _excludeVariableName(name: string): void;
  130811. /** @hidden */
  130812. _emit2DSampler(name: string): void;
  130813. /** @hidden */
  130814. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130815. /** @hidden */
  130816. _emitExtension(name: string, extension: string): void;
  130817. /** @hidden */
  130818. _emitFunction(name: string, code: string, comments: string): void;
  130819. /** @hidden */
  130820. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130821. replaceStrings?: {
  130822. search: RegExp;
  130823. replace: string;
  130824. }[];
  130825. repeatKey?: string;
  130826. }): string;
  130827. /** @hidden */
  130828. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130829. repeatKey?: string;
  130830. removeAttributes?: boolean;
  130831. removeUniforms?: boolean;
  130832. removeVaryings?: boolean;
  130833. removeIfDef?: boolean;
  130834. replaceStrings?: {
  130835. search: RegExp;
  130836. replace: string;
  130837. }[];
  130838. }, storeKey?: string): void;
  130839. /** @hidden */
  130840. _registerTempVariable(name: string): boolean;
  130841. /** @hidden */
  130842. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130843. /** @hidden */
  130844. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130845. /** @hidden */
  130846. _emitFloat(value: number): string;
  130847. }
  130848. }
  130849. declare module BABYLON {
  130850. /**
  130851. * Defines a block that can be used inside a node based material
  130852. */
  130853. export class NodeMaterialBlock {
  130854. private _buildId;
  130855. private _buildTarget;
  130856. private _target;
  130857. private _isFinalMerger;
  130858. private _isInput;
  130859. protected _isUnique: boolean;
  130860. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130861. inputsAreExclusive: boolean;
  130862. /** @hidden */
  130863. _codeVariableName: string;
  130864. /** @hidden */
  130865. _inputs: NodeMaterialConnectionPoint[];
  130866. /** @hidden */
  130867. _outputs: NodeMaterialConnectionPoint[];
  130868. /** @hidden */
  130869. _preparationId: number;
  130870. /**
  130871. * Gets or sets the name of the block
  130872. */
  130873. name: string;
  130874. /**
  130875. * Gets or sets the unique id of the node
  130876. */
  130877. uniqueId: number;
  130878. /**
  130879. * Gets or sets the comments associated with this block
  130880. */
  130881. comments: string;
  130882. /**
  130883. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130884. */
  130885. get isUnique(): boolean;
  130886. /**
  130887. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130888. */
  130889. get isFinalMerger(): boolean;
  130890. /**
  130891. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130892. */
  130893. get isInput(): boolean;
  130894. /**
  130895. * Gets or sets the build Id
  130896. */
  130897. get buildId(): number;
  130898. set buildId(value: number);
  130899. /**
  130900. * Gets or sets the target of the block
  130901. */
  130902. get target(): NodeMaterialBlockTargets;
  130903. set target(value: NodeMaterialBlockTargets);
  130904. /**
  130905. * Gets the list of input points
  130906. */
  130907. get inputs(): NodeMaterialConnectionPoint[];
  130908. /** Gets the list of output points */
  130909. get outputs(): NodeMaterialConnectionPoint[];
  130910. /**
  130911. * Find an input by its name
  130912. * @param name defines the name of the input to look for
  130913. * @returns the input or null if not found
  130914. */
  130915. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130916. /**
  130917. * Find an output by its name
  130918. * @param name defines the name of the outputto look for
  130919. * @returns the output or null if not found
  130920. */
  130921. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130922. /**
  130923. * Creates a new NodeMaterialBlock
  130924. * @param name defines the block name
  130925. * @param target defines the target of that block (Vertex by default)
  130926. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130927. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130928. */
  130929. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130930. /**
  130931. * Initialize the block and prepare the context for build
  130932. * @param state defines the state that will be used for the build
  130933. */
  130934. initialize(state: NodeMaterialBuildState): void;
  130935. /**
  130936. * Bind data to effect. Will only be called for blocks with isBindable === true
  130937. * @param effect defines the effect to bind data to
  130938. * @param nodeMaterial defines the hosting NodeMaterial
  130939. * @param mesh defines the mesh that will be rendered
  130940. */
  130941. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130942. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130943. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130944. protected _writeFloat(value: number): string;
  130945. /**
  130946. * Gets the current class name e.g. "NodeMaterialBlock"
  130947. * @returns the class name
  130948. */
  130949. getClassName(): string;
  130950. /**
  130951. * Register a new input. Must be called inside a block constructor
  130952. * @param name defines the connection point name
  130953. * @param type defines the connection point type
  130954. * @param isOptional defines a boolean indicating that this input can be omitted
  130955. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130956. * @returns the current block
  130957. */
  130958. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130959. /**
  130960. * Register a new output. Must be called inside a block constructor
  130961. * @param name defines the connection point name
  130962. * @param type defines the connection point type
  130963. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130964. * @returns the current block
  130965. */
  130966. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130967. /**
  130968. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130969. * @param forOutput defines an optional connection point to check compatibility with
  130970. * @returns the first available input or null
  130971. */
  130972. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130973. /**
  130974. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130975. * @param forBlock defines an optional block to check compatibility with
  130976. * @returns the first available input or null
  130977. */
  130978. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130979. /**
  130980. * Gets the sibling of the given output
  130981. * @param current defines the current output
  130982. * @returns the next output in the list or null
  130983. */
  130984. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130985. /**
  130986. * Connect current block with another block
  130987. * @param other defines the block to connect with
  130988. * @param options define the various options to help pick the right connections
  130989. * @returns the current block
  130990. */
  130991. connectTo(other: NodeMaterialBlock, options?: {
  130992. input?: string;
  130993. output?: string;
  130994. outputSwizzle?: string;
  130995. }): this | undefined;
  130996. protected _buildBlock(state: NodeMaterialBuildState): void;
  130997. /**
  130998. * Add uniforms, samplers and uniform buffers at compilation time
  130999. * @param state defines the state to update
  131000. * @param nodeMaterial defines the node material requesting the update
  131001. * @param defines defines the material defines to update
  131002. * @param uniformBuffers defines the list of uniform buffer names
  131003. */
  131004. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131005. /**
  131006. * Add potential fallbacks if shader compilation fails
  131007. * @param mesh defines the mesh to be rendered
  131008. * @param fallbacks defines the current prioritized list of fallbacks
  131009. */
  131010. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131011. /**
  131012. * Initialize defines for shader compilation
  131013. * @param mesh defines the mesh to be rendered
  131014. * @param nodeMaterial defines the node material requesting the update
  131015. * @param defines defines the material defines to update
  131016. * @param useInstances specifies that instances should be used
  131017. */
  131018. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131019. /**
  131020. * Update defines for shader compilation
  131021. * @param mesh defines the mesh to be rendered
  131022. * @param nodeMaterial defines the node material requesting the update
  131023. * @param defines defines the material defines to update
  131024. * @param useInstances specifies that instances should be used
  131025. */
  131026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131027. /**
  131028. * Lets the block try to connect some inputs automatically
  131029. * @param material defines the hosting NodeMaterial
  131030. */
  131031. autoConfigure(material: NodeMaterial): void;
  131032. /**
  131033. * Function called when a block is declared as repeatable content generator
  131034. * @param vertexShaderState defines the current compilation state for the vertex shader
  131035. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131036. * @param mesh defines the mesh to be rendered
  131037. * @param defines defines the material defines to update
  131038. */
  131039. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131040. /**
  131041. * Checks if the block is ready
  131042. * @param mesh defines the mesh to be rendered
  131043. * @param nodeMaterial defines the node material requesting the update
  131044. * @param defines defines the material defines to update
  131045. * @param useInstances specifies that instances should be used
  131046. * @returns true if the block is ready
  131047. */
  131048. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131049. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131050. private _processBuild;
  131051. /**
  131052. * Compile the current node and generate the shader code
  131053. * @param state defines the current compilation state (uniforms, samplers, current string)
  131054. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131055. * @returns true if already built
  131056. */
  131057. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131058. protected _inputRename(name: string): string;
  131059. protected _outputRename(name: string): string;
  131060. protected _dumpPropertiesCode(): string;
  131061. /** @hidden */
  131062. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131063. /** @hidden */
  131064. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131065. /**
  131066. * Clone the current block to a new identical block
  131067. * @param scene defines the hosting scene
  131068. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131069. * @returns a copy of the current block
  131070. */
  131071. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131072. /**
  131073. * Serializes this block in a JSON representation
  131074. * @returns the serialized block object
  131075. */
  131076. serialize(): any;
  131077. /** @hidden */
  131078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131079. /**
  131080. * Release resources
  131081. */
  131082. dispose(): void;
  131083. }
  131084. }
  131085. declare module BABYLON {
  131086. /**
  131087. * Enum defining the type of animations supported by InputBlock
  131088. */
  131089. export enum AnimatedInputBlockTypes {
  131090. /** No animation */
  131091. None = 0,
  131092. /** Time based animation. Will only work for floats */
  131093. Time = 1
  131094. }
  131095. }
  131096. declare module BABYLON {
  131097. /**
  131098. * Block used to expose an input value
  131099. */
  131100. export class InputBlock extends NodeMaterialBlock {
  131101. private _mode;
  131102. private _associatedVariableName;
  131103. private _storedValue;
  131104. private _valueCallback;
  131105. private _type;
  131106. private _animationType;
  131107. /** Gets or set a value used to limit the range of float values */
  131108. min: number;
  131109. /** Gets or set a value used to limit the range of float values */
  131110. max: number;
  131111. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131112. isBoolean: boolean;
  131113. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131114. matrixMode: number;
  131115. /** @hidden */
  131116. _systemValue: Nullable<NodeMaterialSystemValues>;
  131117. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131118. visibleInInspector: boolean;
  131119. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131120. isConstant: boolean;
  131121. /** Gets or sets the group to use to display this block in the Inspector */
  131122. groupInInspector: string;
  131123. /** Gets an observable raised when the value is changed */
  131124. onValueChangedObservable: Observable<InputBlock>;
  131125. /**
  131126. * Gets or sets the connection point type (default is float)
  131127. */
  131128. get type(): NodeMaterialBlockConnectionPointTypes;
  131129. /**
  131130. * Creates a new InputBlock
  131131. * @param name defines the block name
  131132. * @param target defines the target of that block (Vertex by default)
  131133. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131134. */
  131135. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131136. /**
  131137. * Gets the output component
  131138. */
  131139. get output(): NodeMaterialConnectionPoint;
  131140. /**
  131141. * Set the source of this connection point to a vertex attribute
  131142. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131143. * @returns the current connection point
  131144. */
  131145. setAsAttribute(attributeName?: string): InputBlock;
  131146. /**
  131147. * Set the source of this connection point to a system value
  131148. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131149. * @returns the current connection point
  131150. */
  131151. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131152. /**
  131153. * Gets or sets the value of that point.
  131154. * Please note that this value will be ignored if valueCallback is defined
  131155. */
  131156. get value(): any;
  131157. set value(value: any);
  131158. /**
  131159. * Gets or sets a callback used to get the value of that point.
  131160. * Please note that setting this value will force the connection point to ignore the value property
  131161. */
  131162. get valueCallback(): () => any;
  131163. set valueCallback(value: () => any);
  131164. /**
  131165. * Gets or sets the associated variable name in the shader
  131166. */
  131167. get associatedVariableName(): string;
  131168. set associatedVariableName(value: string);
  131169. /** Gets or sets the type of animation applied to the input */
  131170. get animationType(): AnimatedInputBlockTypes;
  131171. set animationType(value: AnimatedInputBlockTypes);
  131172. /**
  131173. * Gets a boolean indicating that this connection point not defined yet
  131174. */
  131175. get isUndefined(): boolean;
  131176. /**
  131177. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131178. * In this case the connection point name must be the name of the uniform to use.
  131179. * Can only be set on inputs
  131180. */
  131181. get isUniform(): boolean;
  131182. set isUniform(value: boolean);
  131183. /**
  131184. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131185. * In this case the connection point name must be the name of the attribute to use
  131186. * Can only be set on inputs
  131187. */
  131188. get isAttribute(): boolean;
  131189. set isAttribute(value: boolean);
  131190. /**
  131191. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131192. * Can only be set on exit points
  131193. */
  131194. get isVarying(): boolean;
  131195. set isVarying(value: boolean);
  131196. /**
  131197. * Gets a boolean indicating that the current connection point is a system value
  131198. */
  131199. get isSystemValue(): boolean;
  131200. /**
  131201. * Gets or sets the current well known value or null if not defined as a system value
  131202. */
  131203. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131204. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131205. /**
  131206. * Gets the current class name
  131207. * @returns the class name
  131208. */
  131209. getClassName(): string;
  131210. /**
  131211. * Animate the input if animationType !== None
  131212. * @param scene defines the rendering scene
  131213. */
  131214. animate(scene: Scene): void;
  131215. private _emitDefine;
  131216. initialize(state: NodeMaterialBuildState): void;
  131217. /**
  131218. * Set the input block to its default value (based on its type)
  131219. */
  131220. setDefaultValue(): void;
  131221. private _emitConstant;
  131222. private _emit;
  131223. /** @hidden */
  131224. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131225. /** @hidden */
  131226. _transmit(effect: Effect, scene: Scene): void;
  131227. protected _buildBlock(state: NodeMaterialBuildState): void;
  131228. protected _dumpPropertiesCode(): string;
  131229. dispose(): void;
  131230. serialize(): any;
  131231. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131232. }
  131233. }
  131234. declare module BABYLON {
  131235. /**
  131236. * Enum used to define the compatibility state between two connection points
  131237. */
  131238. export enum NodeMaterialConnectionPointCompatibilityStates {
  131239. /** Points are compatibles */
  131240. Compatible = 0,
  131241. /** Points are incompatible because of their types */
  131242. TypeIncompatible = 1,
  131243. /** Points are incompatible because of their targets (vertex vs fragment) */
  131244. TargetIncompatible = 2
  131245. }
  131246. /**
  131247. * Defines the direction of a connection point
  131248. */
  131249. export enum NodeMaterialConnectionPointDirection {
  131250. /** Input */
  131251. Input = 0,
  131252. /** Output */
  131253. Output = 1
  131254. }
  131255. /**
  131256. * Defines a connection point for a block
  131257. */
  131258. export class NodeMaterialConnectionPoint {
  131259. /** @hidden */
  131260. _ownerBlock: NodeMaterialBlock;
  131261. /** @hidden */
  131262. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131263. private _endpoints;
  131264. private _associatedVariableName;
  131265. private _direction;
  131266. /** @hidden */
  131267. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131268. /** @hidden */
  131269. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131270. private _type;
  131271. /** @hidden */
  131272. _enforceAssociatedVariableName: boolean;
  131273. /** Gets the direction of the point */
  131274. get direction(): NodeMaterialConnectionPointDirection;
  131275. /**
  131276. * Gets or sets the additional types supported by this connection point
  131277. */
  131278. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131279. /**
  131280. * Gets or sets the additional types excluded by this connection point
  131281. */
  131282. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131283. /**
  131284. * Observable triggered when this point is connected
  131285. */
  131286. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131287. /**
  131288. * Gets or sets the associated variable name in the shader
  131289. */
  131290. get associatedVariableName(): string;
  131291. set associatedVariableName(value: string);
  131292. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131293. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131294. /**
  131295. * Gets or sets the connection point type (default is float)
  131296. */
  131297. get type(): NodeMaterialBlockConnectionPointTypes;
  131298. set type(value: NodeMaterialBlockConnectionPointTypes);
  131299. /**
  131300. * Gets or sets the connection point name
  131301. */
  131302. name: string;
  131303. /**
  131304. * Gets or sets a boolean indicating that this connection point can be omitted
  131305. */
  131306. isOptional: boolean;
  131307. /**
  131308. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131309. */
  131310. define: string;
  131311. /** @hidden */
  131312. _prioritizeVertex: boolean;
  131313. private _target;
  131314. /** Gets or sets the target of that connection point */
  131315. get target(): NodeMaterialBlockTargets;
  131316. set target(value: NodeMaterialBlockTargets);
  131317. /**
  131318. * Gets a boolean indicating that the current point is connected
  131319. */
  131320. get isConnected(): boolean;
  131321. /**
  131322. * Gets a boolean indicating that the current point is connected to an input block
  131323. */
  131324. get isConnectedToInputBlock(): boolean;
  131325. /**
  131326. * Gets a the connected input block (if any)
  131327. */
  131328. get connectInputBlock(): Nullable<InputBlock>;
  131329. /** Get the other side of the connection (if any) */
  131330. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131331. /** Get the block that owns this connection point */
  131332. get ownerBlock(): NodeMaterialBlock;
  131333. /** Get the block connected on the other side of this connection (if any) */
  131334. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131335. /** Get the block connected on the endpoints of this connection (if any) */
  131336. get connectedBlocks(): Array<NodeMaterialBlock>;
  131337. /** Gets the list of connected endpoints */
  131338. get endpoints(): NodeMaterialConnectionPoint[];
  131339. /** Gets a boolean indicating if that output point is connected to at least one input */
  131340. get hasEndpoints(): boolean;
  131341. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131342. get isConnectedInVertexShader(): boolean;
  131343. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131344. get isConnectedInFragmentShader(): boolean;
  131345. /**
  131346. * Creates a new connection point
  131347. * @param name defines the connection point name
  131348. * @param ownerBlock defines the block hosting this connection point
  131349. * @param direction defines the direction of the connection point
  131350. */
  131351. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131352. /**
  131353. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131354. * @returns the class name
  131355. */
  131356. getClassName(): string;
  131357. /**
  131358. * Gets a boolean indicating if the current point can be connected to another point
  131359. * @param connectionPoint defines the other connection point
  131360. * @returns a boolean
  131361. */
  131362. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131363. /**
  131364. * Gets a number indicating if the current point can be connected to another point
  131365. * @param connectionPoint defines the other connection point
  131366. * @returns a number defining the compatibility state
  131367. */
  131368. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131369. /**
  131370. * Connect this point to another connection point
  131371. * @param connectionPoint defines the other connection point
  131372. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131373. * @returns the current connection point
  131374. */
  131375. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131376. /**
  131377. * Disconnect this point from one of his endpoint
  131378. * @param endpoint defines the other connection point
  131379. * @returns the current connection point
  131380. */
  131381. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131382. /**
  131383. * Serializes this point in a JSON representation
  131384. * @returns the serialized point object
  131385. */
  131386. serialize(): any;
  131387. /**
  131388. * Release resources
  131389. */
  131390. dispose(): void;
  131391. }
  131392. }
  131393. declare module BABYLON {
  131394. /**
  131395. * Block used to add support for vertex skinning (bones)
  131396. */
  131397. export class BonesBlock extends NodeMaterialBlock {
  131398. /**
  131399. * Creates a new BonesBlock
  131400. * @param name defines the block name
  131401. */
  131402. constructor(name: string);
  131403. /**
  131404. * Initialize the block and prepare the context for build
  131405. * @param state defines the state that will be used for the build
  131406. */
  131407. initialize(state: NodeMaterialBuildState): void;
  131408. /**
  131409. * Gets the current class name
  131410. * @returns the class name
  131411. */
  131412. getClassName(): string;
  131413. /**
  131414. * Gets the matrix indices input component
  131415. */
  131416. get matricesIndices(): NodeMaterialConnectionPoint;
  131417. /**
  131418. * Gets the matrix weights input component
  131419. */
  131420. get matricesWeights(): NodeMaterialConnectionPoint;
  131421. /**
  131422. * Gets the extra matrix indices input component
  131423. */
  131424. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131425. /**
  131426. * Gets the extra matrix weights input component
  131427. */
  131428. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131429. /**
  131430. * Gets the world input component
  131431. */
  131432. get world(): NodeMaterialConnectionPoint;
  131433. /**
  131434. * Gets the output component
  131435. */
  131436. get output(): NodeMaterialConnectionPoint;
  131437. autoConfigure(material: NodeMaterial): void;
  131438. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131439. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131440. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131441. protected _buildBlock(state: NodeMaterialBuildState): this;
  131442. }
  131443. }
  131444. declare module BABYLON {
  131445. /**
  131446. * Block used to add support for instances
  131447. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131448. */
  131449. export class InstancesBlock extends NodeMaterialBlock {
  131450. /**
  131451. * Creates a new InstancesBlock
  131452. * @param name defines the block name
  131453. */
  131454. constructor(name: string);
  131455. /**
  131456. * Gets the current class name
  131457. * @returns the class name
  131458. */
  131459. getClassName(): string;
  131460. /**
  131461. * Gets the first world row input component
  131462. */
  131463. get world0(): NodeMaterialConnectionPoint;
  131464. /**
  131465. * Gets the second world row input component
  131466. */
  131467. get world1(): NodeMaterialConnectionPoint;
  131468. /**
  131469. * Gets the third world row input component
  131470. */
  131471. get world2(): NodeMaterialConnectionPoint;
  131472. /**
  131473. * Gets the forth world row input component
  131474. */
  131475. get world3(): NodeMaterialConnectionPoint;
  131476. /**
  131477. * Gets the world input component
  131478. */
  131479. get world(): NodeMaterialConnectionPoint;
  131480. /**
  131481. * Gets the output component
  131482. */
  131483. get output(): NodeMaterialConnectionPoint;
  131484. /**
  131485. * Gets the isntanceID component
  131486. */
  131487. get instanceID(): NodeMaterialConnectionPoint;
  131488. autoConfigure(material: NodeMaterial): void;
  131489. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131490. protected _buildBlock(state: NodeMaterialBuildState): this;
  131491. }
  131492. }
  131493. declare module BABYLON {
  131494. /**
  131495. * Block used to add morph targets support to vertex shader
  131496. */
  131497. export class MorphTargetsBlock extends NodeMaterialBlock {
  131498. private _repeatableContentAnchor;
  131499. /**
  131500. * Create a new MorphTargetsBlock
  131501. * @param name defines the block name
  131502. */
  131503. constructor(name: string);
  131504. /**
  131505. * Gets the current class name
  131506. * @returns the class name
  131507. */
  131508. getClassName(): string;
  131509. /**
  131510. * Gets the position input component
  131511. */
  131512. get position(): NodeMaterialConnectionPoint;
  131513. /**
  131514. * Gets the normal input component
  131515. */
  131516. get normal(): NodeMaterialConnectionPoint;
  131517. /**
  131518. * Gets the tangent input component
  131519. */
  131520. get tangent(): NodeMaterialConnectionPoint;
  131521. /**
  131522. * Gets the tangent input component
  131523. */
  131524. get uv(): NodeMaterialConnectionPoint;
  131525. /**
  131526. * Gets the position output component
  131527. */
  131528. get positionOutput(): NodeMaterialConnectionPoint;
  131529. /**
  131530. * Gets the normal output component
  131531. */
  131532. get normalOutput(): NodeMaterialConnectionPoint;
  131533. /**
  131534. * Gets the tangent output component
  131535. */
  131536. get tangentOutput(): NodeMaterialConnectionPoint;
  131537. /**
  131538. * Gets the tangent output component
  131539. */
  131540. get uvOutput(): NodeMaterialConnectionPoint;
  131541. initialize(state: NodeMaterialBuildState): void;
  131542. autoConfigure(material: NodeMaterial): void;
  131543. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131544. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131545. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131546. protected _buildBlock(state: NodeMaterialBuildState): this;
  131547. }
  131548. }
  131549. declare module BABYLON {
  131550. /**
  131551. * Block used to get data information from a light
  131552. */
  131553. export class LightInformationBlock extends NodeMaterialBlock {
  131554. private _lightDataUniformName;
  131555. private _lightColorUniformName;
  131556. private _lightTypeDefineName;
  131557. /**
  131558. * Gets or sets the light associated with this block
  131559. */
  131560. light: Nullable<Light>;
  131561. /**
  131562. * Creates a new LightInformationBlock
  131563. * @param name defines the block name
  131564. */
  131565. constructor(name: string);
  131566. /**
  131567. * Gets the current class name
  131568. * @returns the class name
  131569. */
  131570. getClassName(): string;
  131571. /**
  131572. * Gets the world position input component
  131573. */
  131574. get worldPosition(): NodeMaterialConnectionPoint;
  131575. /**
  131576. * Gets the direction output component
  131577. */
  131578. get direction(): NodeMaterialConnectionPoint;
  131579. /**
  131580. * Gets the direction output component
  131581. */
  131582. get color(): NodeMaterialConnectionPoint;
  131583. /**
  131584. * Gets the direction output component
  131585. */
  131586. get intensity(): NodeMaterialConnectionPoint;
  131587. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131588. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131589. protected _buildBlock(state: NodeMaterialBuildState): this;
  131590. serialize(): any;
  131591. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131592. }
  131593. }
  131594. declare module BABYLON {
  131595. /**
  131596. * Block used to add image processing support to fragment shader
  131597. */
  131598. export class ImageProcessingBlock extends NodeMaterialBlock {
  131599. /**
  131600. * Create a new ImageProcessingBlock
  131601. * @param name defines the block name
  131602. */
  131603. constructor(name: string);
  131604. /**
  131605. * Gets the current class name
  131606. * @returns the class name
  131607. */
  131608. getClassName(): string;
  131609. /**
  131610. * Gets the color input component
  131611. */
  131612. get color(): NodeMaterialConnectionPoint;
  131613. /**
  131614. * Gets the output component
  131615. */
  131616. get output(): NodeMaterialConnectionPoint;
  131617. /**
  131618. * Initialize the block and prepare the context for build
  131619. * @param state defines the state that will be used for the build
  131620. */
  131621. initialize(state: NodeMaterialBuildState): void;
  131622. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131623. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131624. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131625. protected _buildBlock(state: NodeMaterialBuildState): this;
  131626. }
  131627. }
  131628. declare module BABYLON {
  131629. /**
  131630. * Block used to pertub normals based on a normal map
  131631. */
  131632. export class PerturbNormalBlock extends NodeMaterialBlock {
  131633. private _tangentSpaceParameterName;
  131634. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131635. invertX: boolean;
  131636. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131637. invertY: boolean;
  131638. /**
  131639. * Create a new PerturbNormalBlock
  131640. * @param name defines the block name
  131641. */
  131642. constructor(name: string);
  131643. /**
  131644. * Gets the current class name
  131645. * @returns the class name
  131646. */
  131647. getClassName(): string;
  131648. /**
  131649. * Gets the world position input component
  131650. */
  131651. get worldPosition(): NodeMaterialConnectionPoint;
  131652. /**
  131653. * Gets the world normal input component
  131654. */
  131655. get worldNormal(): NodeMaterialConnectionPoint;
  131656. /**
  131657. * Gets the world tangent input component
  131658. */
  131659. get worldTangent(): NodeMaterialConnectionPoint;
  131660. /**
  131661. * Gets the uv input component
  131662. */
  131663. get uv(): NodeMaterialConnectionPoint;
  131664. /**
  131665. * Gets the normal map color input component
  131666. */
  131667. get normalMapColor(): NodeMaterialConnectionPoint;
  131668. /**
  131669. * Gets the strength input component
  131670. */
  131671. get strength(): NodeMaterialConnectionPoint;
  131672. /**
  131673. * Gets the output component
  131674. */
  131675. get output(): NodeMaterialConnectionPoint;
  131676. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131677. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131678. autoConfigure(material: NodeMaterial): void;
  131679. protected _buildBlock(state: NodeMaterialBuildState): this;
  131680. protected _dumpPropertiesCode(): string;
  131681. serialize(): any;
  131682. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131683. }
  131684. }
  131685. declare module BABYLON {
  131686. /**
  131687. * Block used to discard a pixel if a value is smaller than a cutoff
  131688. */
  131689. export class DiscardBlock extends NodeMaterialBlock {
  131690. /**
  131691. * Create a new DiscardBlock
  131692. * @param name defines the block name
  131693. */
  131694. constructor(name: string);
  131695. /**
  131696. * Gets the current class name
  131697. * @returns the class name
  131698. */
  131699. getClassName(): string;
  131700. /**
  131701. * Gets the color input component
  131702. */
  131703. get value(): NodeMaterialConnectionPoint;
  131704. /**
  131705. * Gets the cutoff input component
  131706. */
  131707. get cutoff(): NodeMaterialConnectionPoint;
  131708. protected _buildBlock(state: NodeMaterialBuildState): this;
  131709. }
  131710. }
  131711. declare module BABYLON {
  131712. /**
  131713. * Block used to test if the fragment shader is front facing
  131714. */
  131715. export class FrontFacingBlock extends NodeMaterialBlock {
  131716. /**
  131717. * Creates a new FrontFacingBlock
  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 output component
  131728. */
  131729. get output(): NodeMaterialConnectionPoint;
  131730. protected _buildBlock(state: NodeMaterialBuildState): this;
  131731. }
  131732. }
  131733. declare module BABYLON {
  131734. /**
  131735. * Block used to get the derivative value on x and y of a given input
  131736. */
  131737. export class DerivativeBlock extends NodeMaterialBlock {
  131738. /**
  131739. * Create a new DerivativeBlock
  131740. * @param name defines the block name
  131741. */
  131742. constructor(name: string);
  131743. /**
  131744. * Gets the current class name
  131745. * @returns the class name
  131746. */
  131747. getClassName(): string;
  131748. /**
  131749. * Gets the input component
  131750. */
  131751. get input(): NodeMaterialConnectionPoint;
  131752. /**
  131753. * Gets the derivative output on x
  131754. */
  131755. get dx(): NodeMaterialConnectionPoint;
  131756. /**
  131757. * Gets the derivative output on y
  131758. */
  131759. get dy(): NodeMaterialConnectionPoint;
  131760. protected _buildBlock(state: NodeMaterialBuildState): this;
  131761. }
  131762. }
  131763. declare module BABYLON {
  131764. /**
  131765. * Block used to add support for scene fog
  131766. */
  131767. export class FogBlock extends NodeMaterialBlock {
  131768. private _fogDistanceName;
  131769. private _fogParameters;
  131770. /**
  131771. * Create a new FogBlock
  131772. * @param name defines the block name
  131773. */
  131774. constructor(name: string);
  131775. /**
  131776. * Gets the current class name
  131777. * @returns the class name
  131778. */
  131779. getClassName(): string;
  131780. /**
  131781. * Gets the world position input component
  131782. */
  131783. get worldPosition(): NodeMaterialConnectionPoint;
  131784. /**
  131785. * Gets the view input component
  131786. */
  131787. get view(): NodeMaterialConnectionPoint;
  131788. /**
  131789. * Gets the color input component
  131790. */
  131791. get input(): NodeMaterialConnectionPoint;
  131792. /**
  131793. * Gets the fog color input component
  131794. */
  131795. get fogColor(): NodeMaterialConnectionPoint;
  131796. /**
  131797. * Gets the output component
  131798. */
  131799. get output(): NodeMaterialConnectionPoint;
  131800. autoConfigure(material: NodeMaterial): void;
  131801. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131802. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131803. protected _buildBlock(state: NodeMaterialBuildState): this;
  131804. }
  131805. }
  131806. declare module BABYLON {
  131807. /**
  131808. * Block used to add light in the fragment shader
  131809. */
  131810. export class LightBlock extends NodeMaterialBlock {
  131811. private _lightId;
  131812. /**
  131813. * Gets or sets the light associated with this block
  131814. */
  131815. light: Nullable<Light>;
  131816. /**
  131817. * Create a new LightBlock
  131818. * @param name defines the block name
  131819. */
  131820. constructor(name: string);
  131821. /**
  131822. * Gets the current class name
  131823. * @returns the class name
  131824. */
  131825. getClassName(): string;
  131826. /**
  131827. * Gets the world position input component
  131828. */
  131829. get worldPosition(): NodeMaterialConnectionPoint;
  131830. /**
  131831. * Gets the world normal input component
  131832. */
  131833. get worldNormal(): NodeMaterialConnectionPoint;
  131834. /**
  131835. * Gets the camera (or eye) position component
  131836. */
  131837. get cameraPosition(): NodeMaterialConnectionPoint;
  131838. /**
  131839. * Gets the glossiness component
  131840. */
  131841. get glossiness(): NodeMaterialConnectionPoint;
  131842. /**
  131843. * Gets the glossinness power component
  131844. */
  131845. get glossPower(): NodeMaterialConnectionPoint;
  131846. /**
  131847. * Gets the diffuse color component
  131848. */
  131849. get diffuseColor(): NodeMaterialConnectionPoint;
  131850. /**
  131851. * Gets the specular color component
  131852. */
  131853. get specularColor(): NodeMaterialConnectionPoint;
  131854. /**
  131855. * Gets the diffuse output component
  131856. */
  131857. get diffuseOutput(): NodeMaterialConnectionPoint;
  131858. /**
  131859. * Gets the specular output component
  131860. */
  131861. get specularOutput(): NodeMaterialConnectionPoint;
  131862. /**
  131863. * Gets the shadow output component
  131864. */
  131865. get shadow(): NodeMaterialConnectionPoint;
  131866. autoConfigure(material: NodeMaterial): void;
  131867. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131868. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131869. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131870. private _injectVertexCode;
  131871. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131872. serialize(): any;
  131873. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131874. }
  131875. }
  131876. declare module BABYLON {
  131877. /**
  131878. * Block used to multiply 2 values
  131879. */
  131880. export class MultiplyBlock extends NodeMaterialBlock {
  131881. /**
  131882. * Creates a new MultiplyBlock
  131883. * @param name defines the block name
  131884. */
  131885. constructor(name: string);
  131886. /**
  131887. * Gets the current class name
  131888. * @returns the class name
  131889. */
  131890. getClassName(): string;
  131891. /**
  131892. * Gets the left operand input component
  131893. */
  131894. get left(): NodeMaterialConnectionPoint;
  131895. /**
  131896. * Gets the right operand input component
  131897. */
  131898. get right(): NodeMaterialConnectionPoint;
  131899. /**
  131900. * Gets the output component
  131901. */
  131902. get output(): NodeMaterialConnectionPoint;
  131903. protected _buildBlock(state: NodeMaterialBuildState): this;
  131904. }
  131905. }
  131906. declare module BABYLON {
  131907. /**
  131908. * Block used to add 2 vectors
  131909. */
  131910. export class AddBlock extends NodeMaterialBlock {
  131911. /**
  131912. * Creates a new AddBlock
  131913. * @param name defines the block name
  131914. */
  131915. constructor(name: string);
  131916. /**
  131917. * Gets the current class name
  131918. * @returns the class name
  131919. */
  131920. getClassName(): string;
  131921. /**
  131922. * Gets the left operand input component
  131923. */
  131924. get left(): NodeMaterialConnectionPoint;
  131925. /**
  131926. * Gets the right operand input component
  131927. */
  131928. get right(): NodeMaterialConnectionPoint;
  131929. /**
  131930. * Gets the output component
  131931. */
  131932. get output(): NodeMaterialConnectionPoint;
  131933. protected _buildBlock(state: NodeMaterialBuildState): this;
  131934. }
  131935. }
  131936. declare module BABYLON {
  131937. /**
  131938. * Block used to scale a vector by a float
  131939. */
  131940. export class ScaleBlock extends NodeMaterialBlock {
  131941. /**
  131942. * Creates a new ScaleBlock
  131943. * @param name defines the block name
  131944. */
  131945. constructor(name: string);
  131946. /**
  131947. * Gets the current class name
  131948. * @returns the class name
  131949. */
  131950. getClassName(): string;
  131951. /**
  131952. * Gets the input component
  131953. */
  131954. get input(): NodeMaterialConnectionPoint;
  131955. /**
  131956. * Gets the factor input component
  131957. */
  131958. get factor(): NodeMaterialConnectionPoint;
  131959. /**
  131960. * Gets the output component
  131961. */
  131962. get output(): NodeMaterialConnectionPoint;
  131963. protected _buildBlock(state: NodeMaterialBuildState): this;
  131964. }
  131965. }
  131966. declare module BABYLON {
  131967. /**
  131968. * Block used to clamp a float
  131969. */
  131970. export class ClampBlock extends NodeMaterialBlock {
  131971. /** Gets or sets the minimum range */
  131972. minimum: number;
  131973. /** Gets or sets the maximum range */
  131974. maximum: number;
  131975. /**
  131976. * Creates a new ClampBlock
  131977. * @param name defines the block name
  131978. */
  131979. constructor(name: string);
  131980. /**
  131981. * Gets the current class name
  131982. * @returns the class name
  131983. */
  131984. getClassName(): string;
  131985. /**
  131986. * Gets the value input component
  131987. */
  131988. get value(): NodeMaterialConnectionPoint;
  131989. /**
  131990. * Gets the output component
  131991. */
  131992. get output(): NodeMaterialConnectionPoint;
  131993. protected _buildBlock(state: NodeMaterialBuildState): this;
  131994. protected _dumpPropertiesCode(): string;
  131995. serialize(): any;
  131996. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131997. }
  131998. }
  131999. declare module BABYLON {
  132000. /**
  132001. * Block used to apply a cross product between 2 vectors
  132002. */
  132003. export class CrossBlock extends NodeMaterialBlock {
  132004. /**
  132005. * Creates a new CrossBlock
  132006. * @param name defines the block name
  132007. */
  132008. constructor(name: string);
  132009. /**
  132010. * Gets the current class name
  132011. * @returns the class name
  132012. */
  132013. getClassName(): string;
  132014. /**
  132015. * Gets the left operand input component
  132016. */
  132017. get left(): NodeMaterialConnectionPoint;
  132018. /**
  132019. * Gets the right operand input component
  132020. */
  132021. get right(): NodeMaterialConnectionPoint;
  132022. /**
  132023. * Gets the output component
  132024. */
  132025. get output(): NodeMaterialConnectionPoint;
  132026. protected _buildBlock(state: NodeMaterialBuildState): this;
  132027. }
  132028. }
  132029. declare module BABYLON {
  132030. /**
  132031. * Block used to apply a dot product between 2 vectors
  132032. */
  132033. export class DotBlock extends NodeMaterialBlock {
  132034. /**
  132035. * Creates a new DotBlock
  132036. * @param name defines the block name
  132037. */
  132038. constructor(name: string);
  132039. /**
  132040. * Gets the current class name
  132041. * @returns the class name
  132042. */
  132043. getClassName(): string;
  132044. /**
  132045. * Gets the left operand input component
  132046. */
  132047. get left(): NodeMaterialConnectionPoint;
  132048. /**
  132049. * Gets the right operand input component
  132050. */
  132051. get right(): NodeMaterialConnectionPoint;
  132052. /**
  132053. * Gets the output component
  132054. */
  132055. get output(): NodeMaterialConnectionPoint;
  132056. protected _buildBlock(state: NodeMaterialBuildState): this;
  132057. }
  132058. }
  132059. declare module BABYLON {
  132060. /**
  132061. * Block used to remap a float from a range to a new one
  132062. */
  132063. export class RemapBlock extends NodeMaterialBlock {
  132064. /**
  132065. * Gets or sets the source range
  132066. */
  132067. sourceRange: Vector2;
  132068. /**
  132069. * Gets or sets the target range
  132070. */
  132071. targetRange: Vector2;
  132072. /**
  132073. * Creates a new RemapBlock
  132074. * @param name defines the block name
  132075. */
  132076. constructor(name: string);
  132077. /**
  132078. * Gets the current class name
  132079. * @returns the class name
  132080. */
  132081. getClassName(): string;
  132082. /**
  132083. * Gets the input component
  132084. */
  132085. get input(): NodeMaterialConnectionPoint;
  132086. /**
  132087. * Gets the source min input component
  132088. */
  132089. get sourceMin(): NodeMaterialConnectionPoint;
  132090. /**
  132091. * Gets the source max input component
  132092. */
  132093. get sourceMax(): NodeMaterialConnectionPoint;
  132094. /**
  132095. * Gets the target min input component
  132096. */
  132097. get targetMin(): NodeMaterialConnectionPoint;
  132098. /**
  132099. * Gets the target max input component
  132100. */
  132101. get targetMax(): NodeMaterialConnectionPoint;
  132102. /**
  132103. * Gets the output component
  132104. */
  132105. get output(): NodeMaterialConnectionPoint;
  132106. protected _buildBlock(state: NodeMaterialBuildState): this;
  132107. protected _dumpPropertiesCode(): string;
  132108. serialize(): any;
  132109. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132110. }
  132111. }
  132112. declare module BABYLON {
  132113. /**
  132114. * Block used to normalize a vector
  132115. */
  132116. export class NormalizeBlock extends NodeMaterialBlock {
  132117. /**
  132118. * Creates a new NormalizeBlock
  132119. * @param name defines the block name
  132120. */
  132121. constructor(name: string);
  132122. /**
  132123. * Gets the current class name
  132124. * @returns the class name
  132125. */
  132126. getClassName(): string;
  132127. /**
  132128. * Gets the input component
  132129. */
  132130. get input(): NodeMaterialConnectionPoint;
  132131. /**
  132132. * Gets the output component
  132133. */
  132134. get output(): NodeMaterialConnectionPoint;
  132135. protected _buildBlock(state: NodeMaterialBuildState): this;
  132136. }
  132137. }
  132138. declare module BABYLON {
  132139. /**
  132140. * Operations supported by the Trigonometry block
  132141. */
  132142. export enum TrigonometryBlockOperations {
  132143. /** Cos */
  132144. Cos = 0,
  132145. /** Sin */
  132146. Sin = 1,
  132147. /** Abs */
  132148. Abs = 2,
  132149. /** Exp */
  132150. Exp = 3,
  132151. /** Exp2 */
  132152. Exp2 = 4,
  132153. /** Round */
  132154. Round = 5,
  132155. /** Floor */
  132156. Floor = 6,
  132157. /** Ceiling */
  132158. Ceiling = 7,
  132159. /** Square root */
  132160. Sqrt = 8,
  132161. /** Log */
  132162. Log = 9,
  132163. /** Tangent */
  132164. Tan = 10,
  132165. /** Arc tangent */
  132166. ArcTan = 11,
  132167. /** Arc cosinus */
  132168. ArcCos = 12,
  132169. /** Arc sinus */
  132170. ArcSin = 13,
  132171. /** Fraction */
  132172. Fract = 14,
  132173. /** Sign */
  132174. Sign = 15,
  132175. /** To radians (from degrees) */
  132176. Radians = 16,
  132177. /** To degrees (from radians) */
  132178. Degrees = 17
  132179. }
  132180. /**
  132181. * Block used to apply trigonometry operation to floats
  132182. */
  132183. export class TrigonometryBlock extends NodeMaterialBlock {
  132184. /**
  132185. * Gets or sets the operation applied by the block
  132186. */
  132187. operation: TrigonometryBlockOperations;
  132188. /**
  132189. * Creates a new TrigonometryBlock
  132190. * @param name defines the block name
  132191. */
  132192. constructor(name: string);
  132193. /**
  132194. * Gets the current class name
  132195. * @returns the class name
  132196. */
  132197. getClassName(): string;
  132198. /**
  132199. * Gets the input component
  132200. */
  132201. get input(): NodeMaterialConnectionPoint;
  132202. /**
  132203. * Gets the output component
  132204. */
  132205. get output(): NodeMaterialConnectionPoint;
  132206. protected _buildBlock(state: NodeMaterialBuildState): this;
  132207. serialize(): any;
  132208. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132209. protected _dumpPropertiesCode(): string;
  132210. }
  132211. }
  132212. declare module BABYLON {
  132213. /**
  132214. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132215. */
  132216. export class ColorMergerBlock extends NodeMaterialBlock {
  132217. /**
  132218. * Create a new ColorMergerBlock
  132219. * @param name defines the block name
  132220. */
  132221. constructor(name: string);
  132222. /**
  132223. * Gets the current class name
  132224. * @returns the class name
  132225. */
  132226. getClassName(): string;
  132227. /**
  132228. * Gets the rgb component (input)
  132229. */
  132230. get rgbIn(): NodeMaterialConnectionPoint;
  132231. /**
  132232. * Gets the r component (input)
  132233. */
  132234. get r(): NodeMaterialConnectionPoint;
  132235. /**
  132236. * Gets the g component (input)
  132237. */
  132238. get g(): NodeMaterialConnectionPoint;
  132239. /**
  132240. * Gets the b component (input)
  132241. */
  132242. get b(): NodeMaterialConnectionPoint;
  132243. /**
  132244. * Gets the a component (input)
  132245. */
  132246. get a(): NodeMaterialConnectionPoint;
  132247. /**
  132248. * Gets the rgba component (output)
  132249. */
  132250. get rgba(): NodeMaterialConnectionPoint;
  132251. /**
  132252. * Gets the rgb component (output)
  132253. */
  132254. get rgbOut(): NodeMaterialConnectionPoint;
  132255. /**
  132256. * Gets the rgb component (output)
  132257. * @deprecated Please use rgbOut instead.
  132258. */
  132259. get rgb(): NodeMaterialConnectionPoint;
  132260. protected _buildBlock(state: NodeMaterialBuildState): this;
  132261. }
  132262. }
  132263. declare module BABYLON {
  132264. /**
  132265. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132266. */
  132267. export class VectorMergerBlock extends NodeMaterialBlock {
  132268. /**
  132269. * Create a new VectorMergerBlock
  132270. * @param name defines the block name
  132271. */
  132272. constructor(name: string);
  132273. /**
  132274. * Gets the current class name
  132275. * @returns the class name
  132276. */
  132277. getClassName(): string;
  132278. /**
  132279. * Gets the xyz component (input)
  132280. */
  132281. get xyzIn(): NodeMaterialConnectionPoint;
  132282. /**
  132283. * Gets the xy component (input)
  132284. */
  132285. get xyIn(): NodeMaterialConnectionPoint;
  132286. /**
  132287. * Gets the x component (input)
  132288. */
  132289. get x(): NodeMaterialConnectionPoint;
  132290. /**
  132291. * Gets the y component (input)
  132292. */
  132293. get y(): NodeMaterialConnectionPoint;
  132294. /**
  132295. * Gets the z component (input)
  132296. */
  132297. get z(): NodeMaterialConnectionPoint;
  132298. /**
  132299. * Gets the w component (input)
  132300. */
  132301. get w(): NodeMaterialConnectionPoint;
  132302. /**
  132303. * Gets the xyzw component (output)
  132304. */
  132305. get xyzw(): NodeMaterialConnectionPoint;
  132306. /**
  132307. * Gets the xyz component (output)
  132308. */
  132309. get xyzOut(): NodeMaterialConnectionPoint;
  132310. /**
  132311. * Gets the xy component (output)
  132312. */
  132313. get xyOut(): NodeMaterialConnectionPoint;
  132314. /**
  132315. * Gets the xy component (output)
  132316. * @deprecated Please use xyOut instead.
  132317. */
  132318. get xy(): NodeMaterialConnectionPoint;
  132319. /**
  132320. * Gets the xyz component (output)
  132321. * @deprecated Please use xyzOut instead.
  132322. */
  132323. get xyz(): NodeMaterialConnectionPoint;
  132324. protected _buildBlock(state: NodeMaterialBuildState): this;
  132325. }
  132326. }
  132327. declare module BABYLON {
  132328. /**
  132329. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132330. */
  132331. export class ColorSplitterBlock extends NodeMaterialBlock {
  132332. /**
  132333. * Create a new ColorSplitterBlock
  132334. * @param name defines the block name
  132335. */
  132336. constructor(name: string);
  132337. /**
  132338. * Gets the current class name
  132339. * @returns the class name
  132340. */
  132341. getClassName(): string;
  132342. /**
  132343. * Gets the rgba component (input)
  132344. */
  132345. get rgba(): NodeMaterialConnectionPoint;
  132346. /**
  132347. * Gets the rgb component (input)
  132348. */
  132349. get rgbIn(): NodeMaterialConnectionPoint;
  132350. /**
  132351. * Gets the rgb component (output)
  132352. */
  132353. get rgbOut(): NodeMaterialConnectionPoint;
  132354. /**
  132355. * Gets the r component (output)
  132356. */
  132357. get r(): NodeMaterialConnectionPoint;
  132358. /**
  132359. * Gets the g component (output)
  132360. */
  132361. get g(): NodeMaterialConnectionPoint;
  132362. /**
  132363. * Gets the b component (output)
  132364. */
  132365. get b(): NodeMaterialConnectionPoint;
  132366. /**
  132367. * Gets the a component (output)
  132368. */
  132369. get a(): NodeMaterialConnectionPoint;
  132370. protected _inputRename(name: string): string;
  132371. protected _outputRename(name: string): string;
  132372. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132373. }
  132374. }
  132375. declare module BABYLON {
  132376. /**
  132377. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132378. */
  132379. export class VectorSplitterBlock extends NodeMaterialBlock {
  132380. /**
  132381. * Create a new VectorSplitterBlock
  132382. * @param name defines the block name
  132383. */
  132384. constructor(name: string);
  132385. /**
  132386. * Gets the current class name
  132387. * @returns the class name
  132388. */
  132389. getClassName(): string;
  132390. /**
  132391. * Gets the xyzw component (input)
  132392. */
  132393. get xyzw(): NodeMaterialConnectionPoint;
  132394. /**
  132395. * Gets the xyz component (input)
  132396. */
  132397. get xyzIn(): NodeMaterialConnectionPoint;
  132398. /**
  132399. * Gets the xy component (input)
  132400. */
  132401. get xyIn(): NodeMaterialConnectionPoint;
  132402. /**
  132403. * Gets the xyz component (output)
  132404. */
  132405. get xyzOut(): NodeMaterialConnectionPoint;
  132406. /**
  132407. * Gets the xy component (output)
  132408. */
  132409. get xyOut(): NodeMaterialConnectionPoint;
  132410. /**
  132411. * Gets the x component (output)
  132412. */
  132413. get x(): NodeMaterialConnectionPoint;
  132414. /**
  132415. * Gets the y component (output)
  132416. */
  132417. get y(): NodeMaterialConnectionPoint;
  132418. /**
  132419. * Gets the z component (output)
  132420. */
  132421. get z(): NodeMaterialConnectionPoint;
  132422. /**
  132423. * Gets the w component (output)
  132424. */
  132425. get w(): NodeMaterialConnectionPoint;
  132426. protected _inputRename(name: string): string;
  132427. protected _outputRename(name: string): string;
  132428. protected _buildBlock(state: NodeMaterialBuildState): this;
  132429. }
  132430. }
  132431. declare module BABYLON {
  132432. /**
  132433. * Block used to lerp between 2 values
  132434. */
  132435. export class LerpBlock extends NodeMaterialBlock {
  132436. /**
  132437. * Creates a new LerpBlock
  132438. * @param name defines the block name
  132439. */
  132440. constructor(name: string);
  132441. /**
  132442. * Gets the current class name
  132443. * @returns the class name
  132444. */
  132445. getClassName(): string;
  132446. /**
  132447. * Gets the left operand input component
  132448. */
  132449. get left(): NodeMaterialConnectionPoint;
  132450. /**
  132451. * Gets the right operand input component
  132452. */
  132453. get right(): NodeMaterialConnectionPoint;
  132454. /**
  132455. * Gets the gradient operand input component
  132456. */
  132457. get gradient(): NodeMaterialConnectionPoint;
  132458. /**
  132459. * Gets the output component
  132460. */
  132461. get output(): NodeMaterialConnectionPoint;
  132462. protected _buildBlock(state: NodeMaterialBuildState): this;
  132463. }
  132464. }
  132465. declare module BABYLON {
  132466. /**
  132467. * Block used to divide 2 vectors
  132468. */
  132469. export class DivideBlock extends NodeMaterialBlock {
  132470. /**
  132471. * Creates a new DivideBlock
  132472. * @param name defines the block name
  132473. */
  132474. constructor(name: string);
  132475. /**
  132476. * Gets the current class name
  132477. * @returns the class name
  132478. */
  132479. getClassName(): string;
  132480. /**
  132481. * Gets the left operand input component
  132482. */
  132483. get left(): NodeMaterialConnectionPoint;
  132484. /**
  132485. * Gets the right operand input component
  132486. */
  132487. get right(): NodeMaterialConnectionPoint;
  132488. /**
  132489. * Gets the output component
  132490. */
  132491. get output(): NodeMaterialConnectionPoint;
  132492. protected _buildBlock(state: NodeMaterialBuildState): this;
  132493. }
  132494. }
  132495. declare module BABYLON {
  132496. /**
  132497. * Block used to subtract 2 vectors
  132498. */
  132499. export class SubtractBlock extends NodeMaterialBlock {
  132500. /**
  132501. * Creates a new SubtractBlock
  132502. * @param name defines the block name
  132503. */
  132504. constructor(name: string);
  132505. /**
  132506. * Gets the current class name
  132507. * @returns the class name
  132508. */
  132509. getClassName(): string;
  132510. /**
  132511. * Gets the left operand input component
  132512. */
  132513. get left(): NodeMaterialConnectionPoint;
  132514. /**
  132515. * Gets the right operand input component
  132516. */
  132517. get right(): NodeMaterialConnectionPoint;
  132518. /**
  132519. * Gets the output component
  132520. */
  132521. get output(): NodeMaterialConnectionPoint;
  132522. protected _buildBlock(state: NodeMaterialBuildState): this;
  132523. }
  132524. }
  132525. declare module BABYLON {
  132526. /**
  132527. * Block used to step a value
  132528. */
  132529. export class StepBlock extends NodeMaterialBlock {
  132530. /**
  132531. * Creates a new StepBlock
  132532. * @param name defines the block name
  132533. */
  132534. constructor(name: string);
  132535. /**
  132536. * Gets the current class name
  132537. * @returns the class name
  132538. */
  132539. getClassName(): string;
  132540. /**
  132541. * Gets the value operand input component
  132542. */
  132543. get value(): NodeMaterialConnectionPoint;
  132544. /**
  132545. * Gets the edge operand input component
  132546. */
  132547. get edge(): NodeMaterialConnectionPoint;
  132548. /**
  132549. * Gets the output component
  132550. */
  132551. get output(): NodeMaterialConnectionPoint;
  132552. protected _buildBlock(state: NodeMaterialBuildState): this;
  132553. }
  132554. }
  132555. declare module BABYLON {
  132556. /**
  132557. * Block used to get the opposite (1 - x) of a value
  132558. */
  132559. export class OneMinusBlock extends NodeMaterialBlock {
  132560. /**
  132561. * Creates a new OneMinusBlock
  132562. * @param name defines the block name
  132563. */
  132564. constructor(name: string);
  132565. /**
  132566. * Gets the current class name
  132567. * @returns the class name
  132568. */
  132569. getClassName(): string;
  132570. /**
  132571. * Gets the input component
  132572. */
  132573. get input(): NodeMaterialConnectionPoint;
  132574. /**
  132575. * Gets the output component
  132576. */
  132577. get output(): NodeMaterialConnectionPoint;
  132578. protected _buildBlock(state: NodeMaterialBuildState): this;
  132579. }
  132580. }
  132581. declare module BABYLON {
  132582. /**
  132583. * Block used to get the view direction
  132584. */
  132585. export class ViewDirectionBlock extends NodeMaterialBlock {
  132586. /**
  132587. * Creates a new ViewDirectionBlock
  132588. * @param name defines the block name
  132589. */
  132590. constructor(name: string);
  132591. /**
  132592. * Gets the current class name
  132593. * @returns the class name
  132594. */
  132595. getClassName(): string;
  132596. /**
  132597. * Gets the world position component
  132598. */
  132599. get worldPosition(): NodeMaterialConnectionPoint;
  132600. /**
  132601. * Gets the camera position component
  132602. */
  132603. get cameraPosition(): NodeMaterialConnectionPoint;
  132604. /**
  132605. * Gets the output component
  132606. */
  132607. get output(): NodeMaterialConnectionPoint;
  132608. autoConfigure(material: NodeMaterial): void;
  132609. protected _buildBlock(state: NodeMaterialBuildState): this;
  132610. }
  132611. }
  132612. declare module BABYLON {
  132613. /**
  132614. * Block used to compute fresnel value
  132615. */
  132616. export class FresnelBlock extends NodeMaterialBlock {
  132617. /**
  132618. * Create a new FresnelBlock
  132619. * @param name defines the block name
  132620. */
  132621. constructor(name: string);
  132622. /**
  132623. * Gets the current class name
  132624. * @returns the class name
  132625. */
  132626. getClassName(): string;
  132627. /**
  132628. * Gets the world normal input component
  132629. */
  132630. get worldNormal(): NodeMaterialConnectionPoint;
  132631. /**
  132632. * Gets the view direction input component
  132633. */
  132634. get viewDirection(): NodeMaterialConnectionPoint;
  132635. /**
  132636. * Gets the bias input component
  132637. */
  132638. get bias(): NodeMaterialConnectionPoint;
  132639. /**
  132640. * Gets the camera (or eye) position component
  132641. */
  132642. get power(): NodeMaterialConnectionPoint;
  132643. /**
  132644. * Gets the fresnel output component
  132645. */
  132646. get fresnel(): NodeMaterialConnectionPoint;
  132647. autoConfigure(material: NodeMaterial): void;
  132648. protected _buildBlock(state: NodeMaterialBuildState): this;
  132649. }
  132650. }
  132651. declare module BABYLON {
  132652. /**
  132653. * Block used to get the max of 2 values
  132654. */
  132655. export class MaxBlock extends NodeMaterialBlock {
  132656. /**
  132657. * Creates a new MaxBlock
  132658. * @param name defines the block name
  132659. */
  132660. constructor(name: string);
  132661. /**
  132662. * Gets the current class name
  132663. * @returns the class name
  132664. */
  132665. getClassName(): string;
  132666. /**
  132667. * Gets the left operand input component
  132668. */
  132669. get left(): NodeMaterialConnectionPoint;
  132670. /**
  132671. * Gets the right operand input component
  132672. */
  132673. get right(): NodeMaterialConnectionPoint;
  132674. /**
  132675. * Gets the output component
  132676. */
  132677. get output(): NodeMaterialConnectionPoint;
  132678. protected _buildBlock(state: NodeMaterialBuildState): this;
  132679. }
  132680. }
  132681. declare module BABYLON {
  132682. /**
  132683. * Block used to get the min of 2 values
  132684. */
  132685. export class MinBlock extends NodeMaterialBlock {
  132686. /**
  132687. * Creates a new MinBlock
  132688. * @param name defines the block name
  132689. */
  132690. constructor(name: string);
  132691. /**
  132692. * Gets the current class name
  132693. * @returns the class name
  132694. */
  132695. getClassName(): string;
  132696. /**
  132697. * Gets the left operand input component
  132698. */
  132699. get left(): NodeMaterialConnectionPoint;
  132700. /**
  132701. * Gets the right operand input component
  132702. */
  132703. get right(): NodeMaterialConnectionPoint;
  132704. /**
  132705. * Gets the output component
  132706. */
  132707. get output(): NodeMaterialConnectionPoint;
  132708. protected _buildBlock(state: NodeMaterialBuildState): this;
  132709. }
  132710. }
  132711. declare module BABYLON {
  132712. /**
  132713. * Block used to get the distance between 2 values
  132714. */
  132715. export class DistanceBlock extends NodeMaterialBlock {
  132716. /**
  132717. * Creates a new DistanceBlock
  132718. * @param name defines the block name
  132719. */
  132720. constructor(name: string);
  132721. /**
  132722. * Gets the current class name
  132723. * @returns the class name
  132724. */
  132725. getClassName(): string;
  132726. /**
  132727. * Gets the left operand input component
  132728. */
  132729. get left(): NodeMaterialConnectionPoint;
  132730. /**
  132731. * Gets the right operand input component
  132732. */
  132733. get right(): NodeMaterialConnectionPoint;
  132734. /**
  132735. * Gets the output component
  132736. */
  132737. get output(): NodeMaterialConnectionPoint;
  132738. protected _buildBlock(state: NodeMaterialBuildState): this;
  132739. }
  132740. }
  132741. declare module BABYLON {
  132742. /**
  132743. * Block used to get the length of a vector
  132744. */
  132745. export class LengthBlock extends NodeMaterialBlock {
  132746. /**
  132747. * Creates a new LengthBlock
  132748. * @param name defines the block name
  132749. */
  132750. constructor(name: string);
  132751. /**
  132752. * Gets the current class name
  132753. * @returns the class name
  132754. */
  132755. getClassName(): string;
  132756. /**
  132757. * Gets the value input component
  132758. */
  132759. get value(): NodeMaterialConnectionPoint;
  132760. /**
  132761. * Gets the output component
  132762. */
  132763. get output(): NodeMaterialConnectionPoint;
  132764. protected _buildBlock(state: NodeMaterialBuildState): this;
  132765. }
  132766. }
  132767. declare module BABYLON {
  132768. /**
  132769. * Block used to get negative version of a value (i.e. x * -1)
  132770. */
  132771. export class NegateBlock extends NodeMaterialBlock {
  132772. /**
  132773. * Creates a new NegateBlock
  132774. * @param name defines the block name
  132775. */
  132776. constructor(name: string);
  132777. /**
  132778. * Gets the current class name
  132779. * @returns the class name
  132780. */
  132781. getClassName(): string;
  132782. /**
  132783. * Gets the value input component
  132784. */
  132785. get value(): NodeMaterialConnectionPoint;
  132786. /**
  132787. * Gets the output component
  132788. */
  132789. get output(): NodeMaterialConnectionPoint;
  132790. protected _buildBlock(state: NodeMaterialBuildState): this;
  132791. }
  132792. }
  132793. declare module BABYLON {
  132794. /**
  132795. * Block used to get the value of the first parameter raised to the power of the second
  132796. */
  132797. export class PowBlock extends NodeMaterialBlock {
  132798. /**
  132799. * Creates a new PowBlock
  132800. * @param name defines the block name
  132801. */
  132802. constructor(name: string);
  132803. /**
  132804. * Gets the current class name
  132805. * @returns the class name
  132806. */
  132807. getClassName(): string;
  132808. /**
  132809. * Gets the value operand input component
  132810. */
  132811. get value(): NodeMaterialConnectionPoint;
  132812. /**
  132813. * Gets the power operand input component
  132814. */
  132815. get power(): NodeMaterialConnectionPoint;
  132816. /**
  132817. * Gets the output component
  132818. */
  132819. get output(): NodeMaterialConnectionPoint;
  132820. protected _buildBlock(state: NodeMaterialBuildState): this;
  132821. }
  132822. }
  132823. declare module BABYLON {
  132824. /**
  132825. * Block used to get a random number
  132826. */
  132827. export class RandomNumberBlock extends NodeMaterialBlock {
  132828. /**
  132829. * Creates a new RandomNumberBlock
  132830. * @param name defines the block name
  132831. */
  132832. constructor(name: string);
  132833. /**
  132834. * Gets the current class name
  132835. * @returns the class name
  132836. */
  132837. getClassName(): string;
  132838. /**
  132839. * Gets the seed input component
  132840. */
  132841. get seed(): NodeMaterialConnectionPoint;
  132842. /**
  132843. * Gets the output component
  132844. */
  132845. get output(): NodeMaterialConnectionPoint;
  132846. protected _buildBlock(state: NodeMaterialBuildState): this;
  132847. }
  132848. }
  132849. declare module BABYLON {
  132850. /**
  132851. * Block used to compute arc tangent of 2 values
  132852. */
  132853. export class ArcTan2Block extends NodeMaterialBlock {
  132854. /**
  132855. * Creates a new ArcTan2Block
  132856. * @param name defines the block name
  132857. */
  132858. constructor(name: string);
  132859. /**
  132860. * Gets the current class name
  132861. * @returns the class name
  132862. */
  132863. getClassName(): string;
  132864. /**
  132865. * Gets the x operand input component
  132866. */
  132867. get x(): NodeMaterialConnectionPoint;
  132868. /**
  132869. * Gets the y operand input component
  132870. */
  132871. get y(): NodeMaterialConnectionPoint;
  132872. /**
  132873. * Gets the output component
  132874. */
  132875. get output(): NodeMaterialConnectionPoint;
  132876. protected _buildBlock(state: NodeMaterialBuildState): this;
  132877. }
  132878. }
  132879. declare module BABYLON {
  132880. /**
  132881. * Block used to smooth step a value
  132882. */
  132883. export class SmoothStepBlock extends NodeMaterialBlock {
  132884. /**
  132885. * Creates a new SmoothStepBlock
  132886. * @param name defines the block name
  132887. */
  132888. constructor(name: string);
  132889. /**
  132890. * Gets the current class name
  132891. * @returns the class name
  132892. */
  132893. getClassName(): string;
  132894. /**
  132895. * Gets the value operand input component
  132896. */
  132897. get value(): NodeMaterialConnectionPoint;
  132898. /**
  132899. * Gets the first edge operand input component
  132900. */
  132901. get edge0(): NodeMaterialConnectionPoint;
  132902. /**
  132903. * Gets the second edge operand input component
  132904. */
  132905. get edge1(): NodeMaterialConnectionPoint;
  132906. /**
  132907. * Gets the output component
  132908. */
  132909. get output(): NodeMaterialConnectionPoint;
  132910. protected _buildBlock(state: NodeMaterialBuildState): this;
  132911. }
  132912. }
  132913. declare module BABYLON {
  132914. /**
  132915. * Block used to get the reciprocal (1 / x) of a value
  132916. */
  132917. export class ReciprocalBlock extends NodeMaterialBlock {
  132918. /**
  132919. * Creates a new ReciprocalBlock
  132920. * @param name defines the block name
  132921. */
  132922. constructor(name: string);
  132923. /**
  132924. * Gets the current class name
  132925. * @returns the class name
  132926. */
  132927. getClassName(): string;
  132928. /**
  132929. * Gets the input component
  132930. */
  132931. get input(): NodeMaterialConnectionPoint;
  132932. /**
  132933. * Gets the output component
  132934. */
  132935. get output(): NodeMaterialConnectionPoint;
  132936. protected _buildBlock(state: NodeMaterialBuildState): this;
  132937. }
  132938. }
  132939. declare module BABYLON {
  132940. /**
  132941. * Block used to replace a color by another one
  132942. */
  132943. export class ReplaceColorBlock extends NodeMaterialBlock {
  132944. /**
  132945. * Creates a new ReplaceColorBlock
  132946. * @param name defines the block name
  132947. */
  132948. constructor(name: string);
  132949. /**
  132950. * Gets the current class name
  132951. * @returns the class name
  132952. */
  132953. getClassName(): string;
  132954. /**
  132955. * Gets the value input component
  132956. */
  132957. get value(): NodeMaterialConnectionPoint;
  132958. /**
  132959. * Gets the reference input component
  132960. */
  132961. get reference(): NodeMaterialConnectionPoint;
  132962. /**
  132963. * Gets the distance input component
  132964. */
  132965. get distance(): NodeMaterialConnectionPoint;
  132966. /**
  132967. * Gets the replacement input component
  132968. */
  132969. get replacement(): NodeMaterialConnectionPoint;
  132970. /**
  132971. * Gets the output component
  132972. */
  132973. get output(): NodeMaterialConnectionPoint;
  132974. protected _buildBlock(state: NodeMaterialBuildState): this;
  132975. }
  132976. }
  132977. declare module BABYLON {
  132978. /**
  132979. * Block used to posterize a value
  132980. * @see https://en.wikipedia.org/wiki/Posterization
  132981. */
  132982. export class PosterizeBlock extends NodeMaterialBlock {
  132983. /**
  132984. * Creates a new PosterizeBlock
  132985. * @param name defines the block name
  132986. */
  132987. constructor(name: string);
  132988. /**
  132989. * Gets the current class name
  132990. * @returns the class name
  132991. */
  132992. getClassName(): string;
  132993. /**
  132994. * Gets the value input component
  132995. */
  132996. get value(): NodeMaterialConnectionPoint;
  132997. /**
  132998. * Gets the steps input component
  132999. */
  133000. get steps(): NodeMaterialConnectionPoint;
  133001. /**
  133002. * Gets the output component
  133003. */
  133004. get output(): NodeMaterialConnectionPoint;
  133005. protected _buildBlock(state: NodeMaterialBuildState): this;
  133006. }
  133007. }
  133008. declare module BABYLON {
  133009. /**
  133010. * Operations supported by the Wave block
  133011. */
  133012. export enum WaveBlockKind {
  133013. /** SawTooth */
  133014. SawTooth = 0,
  133015. /** Square */
  133016. Square = 1,
  133017. /** Triangle */
  133018. Triangle = 2
  133019. }
  133020. /**
  133021. * Block used to apply wave operation to floats
  133022. */
  133023. export class WaveBlock extends NodeMaterialBlock {
  133024. /**
  133025. * Gets or sets the kibnd of wave to be applied by the block
  133026. */
  133027. kind: WaveBlockKind;
  133028. /**
  133029. * Creates a new WaveBlock
  133030. * @param name defines the block name
  133031. */
  133032. constructor(name: string);
  133033. /**
  133034. * Gets the current class name
  133035. * @returns the class name
  133036. */
  133037. getClassName(): string;
  133038. /**
  133039. * Gets the input component
  133040. */
  133041. get input(): NodeMaterialConnectionPoint;
  133042. /**
  133043. * Gets the output component
  133044. */
  133045. get output(): NodeMaterialConnectionPoint;
  133046. protected _buildBlock(state: NodeMaterialBuildState): this;
  133047. serialize(): any;
  133048. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133049. }
  133050. }
  133051. declare module BABYLON {
  133052. /**
  133053. * Class used to store a color step for the GradientBlock
  133054. */
  133055. export class GradientBlockColorStep {
  133056. /**
  133057. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133058. */
  133059. step: number;
  133060. /**
  133061. * Gets or sets the color associated with this step
  133062. */
  133063. color: Color3;
  133064. /**
  133065. * Creates a new GradientBlockColorStep
  133066. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133067. * @param color defines the color associated with this step
  133068. */
  133069. constructor(
  133070. /**
  133071. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133072. */
  133073. step: number,
  133074. /**
  133075. * Gets or sets the color associated with this step
  133076. */
  133077. color: Color3);
  133078. }
  133079. /**
  133080. * Block used to return a color from a gradient based on an input value between 0 and 1
  133081. */
  133082. export class GradientBlock extends NodeMaterialBlock {
  133083. /**
  133084. * Gets or sets the list of color steps
  133085. */
  133086. colorSteps: GradientBlockColorStep[];
  133087. /**
  133088. * Creates a new GradientBlock
  133089. * @param name defines the block name
  133090. */
  133091. constructor(name: string);
  133092. /**
  133093. * Gets the current class name
  133094. * @returns the class name
  133095. */
  133096. getClassName(): string;
  133097. /**
  133098. * Gets the gradient input component
  133099. */
  133100. get gradient(): NodeMaterialConnectionPoint;
  133101. /**
  133102. * Gets the output component
  133103. */
  133104. get output(): NodeMaterialConnectionPoint;
  133105. private _writeColorConstant;
  133106. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133107. serialize(): any;
  133108. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133109. protected _dumpPropertiesCode(): string;
  133110. }
  133111. }
  133112. declare module BABYLON {
  133113. /**
  133114. * Block used to normalize lerp between 2 values
  133115. */
  133116. export class NLerpBlock extends NodeMaterialBlock {
  133117. /**
  133118. * Creates a new NLerpBlock
  133119. * @param name defines the block name
  133120. */
  133121. constructor(name: string);
  133122. /**
  133123. * Gets the current class name
  133124. * @returns the class name
  133125. */
  133126. getClassName(): string;
  133127. /**
  133128. * Gets the left operand input component
  133129. */
  133130. get left(): NodeMaterialConnectionPoint;
  133131. /**
  133132. * Gets the right operand input component
  133133. */
  133134. get right(): NodeMaterialConnectionPoint;
  133135. /**
  133136. * Gets the gradient operand input component
  133137. */
  133138. get gradient(): NodeMaterialConnectionPoint;
  133139. /**
  133140. * Gets the output component
  133141. */
  133142. get output(): NodeMaterialConnectionPoint;
  133143. protected _buildBlock(state: NodeMaterialBuildState): this;
  133144. }
  133145. }
  133146. declare module BABYLON {
  133147. /**
  133148. * block used to Generate a Worley Noise 3D Noise Pattern
  133149. */
  133150. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133151. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133152. manhattanDistance: boolean;
  133153. /**
  133154. * Creates a new WorleyNoise3DBlock
  133155. * @param name defines the block name
  133156. */
  133157. constructor(name: string);
  133158. /**
  133159. * Gets the current class name
  133160. * @returns the class name
  133161. */
  133162. getClassName(): string;
  133163. /**
  133164. * Gets the seed input component
  133165. */
  133166. get seed(): NodeMaterialConnectionPoint;
  133167. /**
  133168. * Gets the jitter input component
  133169. */
  133170. get jitter(): NodeMaterialConnectionPoint;
  133171. /**
  133172. * Gets the output component
  133173. */
  133174. get output(): NodeMaterialConnectionPoint;
  133175. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133176. /**
  133177. * Exposes the properties to the UI?
  133178. */
  133179. protected _dumpPropertiesCode(): string;
  133180. /**
  133181. * Exposes the properties to the Seralize?
  133182. */
  133183. serialize(): any;
  133184. /**
  133185. * Exposes the properties to the deseralize?
  133186. */
  133187. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133188. }
  133189. }
  133190. declare module BABYLON {
  133191. /**
  133192. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133193. */
  133194. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133195. /**
  133196. * Creates a new SimplexPerlin3DBlock
  133197. * @param name defines the block name
  133198. */
  133199. constructor(name: string);
  133200. /**
  133201. * Gets the current class name
  133202. * @returns the class name
  133203. */
  133204. getClassName(): string;
  133205. /**
  133206. * Gets the seed operand input component
  133207. */
  133208. get seed(): NodeMaterialConnectionPoint;
  133209. /**
  133210. * Gets the output component
  133211. */
  133212. get output(): NodeMaterialConnectionPoint;
  133213. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133214. }
  133215. }
  133216. declare module BABYLON {
  133217. /**
  133218. * Block used to blend normals
  133219. */
  133220. export class NormalBlendBlock extends NodeMaterialBlock {
  133221. /**
  133222. * Creates a new NormalBlendBlock
  133223. * @param name defines the block name
  133224. */
  133225. constructor(name: string);
  133226. /**
  133227. * Gets the current class name
  133228. * @returns the class name
  133229. */
  133230. getClassName(): string;
  133231. /**
  133232. * Gets the first input component
  133233. */
  133234. get normalMap0(): NodeMaterialConnectionPoint;
  133235. /**
  133236. * Gets the second input component
  133237. */
  133238. get normalMap1(): NodeMaterialConnectionPoint;
  133239. /**
  133240. * Gets the output component
  133241. */
  133242. get output(): NodeMaterialConnectionPoint;
  133243. protected _buildBlock(state: NodeMaterialBuildState): this;
  133244. }
  133245. }
  133246. declare module BABYLON {
  133247. /**
  133248. * Block used to rotate a 2d vector by a given angle
  133249. */
  133250. export class Rotate2dBlock extends NodeMaterialBlock {
  133251. /**
  133252. * Creates a new Rotate2dBlock
  133253. * @param name defines the block name
  133254. */
  133255. constructor(name: string);
  133256. /**
  133257. * Gets the current class name
  133258. * @returns the class name
  133259. */
  133260. getClassName(): string;
  133261. /**
  133262. * Gets the input vector
  133263. */
  133264. get input(): NodeMaterialConnectionPoint;
  133265. /**
  133266. * Gets the input angle
  133267. */
  133268. get angle(): NodeMaterialConnectionPoint;
  133269. /**
  133270. * Gets the output component
  133271. */
  133272. get output(): NodeMaterialConnectionPoint;
  133273. autoConfigure(material: NodeMaterial): void;
  133274. protected _buildBlock(state: NodeMaterialBuildState): this;
  133275. }
  133276. }
  133277. declare module BABYLON {
  133278. /**
  133279. * Block used to get the reflected vector from a direction and a normal
  133280. */
  133281. export class ReflectBlock extends NodeMaterialBlock {
  133282. /**
  133283. * Creates a new ReflectBlock
  133284. * @param name defines the block name
  133285. */
  133286. constructor(name: string);
  133287. /**
  133288. * Gets the current class name
  133289. * @returns the class name
  133290. */
  133291. getClassName(): string;
  133292. /**
  133293. * Gets the incident component
  133294. */
  133295. get incident(): NodeMaterialConnectionPoint;
  133296. /**
  133297. * Gets the normal component
  133298. */
  133299. get normal(): NodeMaterialConnectionPoint;
  133300. /**
  133301. * Gets the output component
  133302. */
  133303. get output(): NodeMaterialConnectionPoint;
  133304. protected _buildBlock(state: NodeMaterialBuildState): this;
  133305. }
  133306. }
  133307. declare module BABYLON {
  133308. /**
  133309. * Block used to get the refracted vector from a direction and a normal
  133310. */
  133311. export class RefractBlock extends NodeMaterialBlock {
  133312. /**
  133313. * Creates a new RefractBlock
  133314. * @param name defines the block name
  133315. */
  133316. constructor(name: string);
  133317. /**
  133318. * Gets the current class name
  133319. * @returns the class name
  133320. */
  133321. getClassName(): string;
  133322. /**
  133323. * Gets the incident component
  133324. */
  133325. get incident(): NodeMaterialConnectionPoint;
  133326. /**
  133327. * Gets the normal component
  133328. */
  133329. get normal(): NodeMaterialConnectionPoint;
  133330. /**
  133331. * Gets the index of refraction component
  133332. */
  133333. get ior(): NodeMaterialConnectionPoint;
  133334. /**
  133335. * Gets the output component
  133336. */
  133337. get output(): NodeMaterialConnectionPoint;
  133338. protected _buildBlock(state: NodeMaterialBuildState): this;
  133339. }
  133340. }
  133341. declare module BABYLON {
  133342. /**
  133343. * Block used to desaturate a color
  133344. */
  133345. export class DesaturateBlock extends NodeMaterialBlock {
  133346. /**
  133347. * Creates a new DesaturateBlock
  133348. * @param name defines the block name
  133349. */
  133350. constructor(name: string);
  133351. /**
  133352. * Gets the current class name
  133353. * @returns the class name
  133354. */
  133355. getClassName(): string;
  133356. /**
  133357. * Gets the color operand input component
  133358. */
  133359. get color(): NodeMaterialConnectionPoint;
  133360. /**
  133361. * Gets the level operand input component
  133362. */
  133363. get level(): NodeMaterialConnectionPoint;
  133364. /**
  133365. * Gets the output component
  133366. */
  133367. get output(): NodeMaterialConnectionPoint;
  133368. protected _buildBlock(state: NodeMaterialBuildState): this;
  133369. }
  133370. }
  133371. declare module BABYLON {
  133372. /**
  133373. * Effect Render Options
  133374. */
  133375. export interface IEffectRendererOptions {
  133376. /**
  133377. * Defines the vertices positions.
  133378. */
  133379. positions?: number[];
  133380. /**
  133381. * Defines the indices.
  133382. */
  133383. indices?: number[];
  133384. }
  133385. /**
  133386. * Helper class to render one or more effects
  133387. */
  133388. export class EffectRenderer {
  133389. private engine;
  133390. private static _DefaultOptions;
  133391. private _vertexBuffers;
  133392. private _indexBuffer;
  133393. private _ringBufferIndex;
  133394. private _ringScreenBuffer;
  133395. private _fullscreenViewport;
  133396. private _getNextFrameBuffer;
  133397. /**
  133398. * Creates an effect renderer
  133399. * @param engine the engine to use for rendering
  133400. * @param options defines the options of the effect renderer
  133401. */
  133402. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133403. /**
  133404. * Sets the current viewport in normalized coordinates 0-1
  133405. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133406. */
  133407. setViewport(viewport?: Viewport): void;
  133408. /**
  133409. * Binds the embedded attributes buffer to the effect.
  133410. * @param effect Defines the effect to bind the attributes for
  133411. */
  133412. bindBuffers(effect: Effect): void;
  133413. /**
  133414. * Sets the current effect wrapper to use during draw.
  133415. * The effect needs to be ready before calling this api.
  133416. * This also sets the default full screen position attribute.
  133417. * @param effectWrapper Defines the effect to draw with
  133418. */
  133419. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133420. /**
  133421. * Draws a full screen quad.
  133422. */
  133423. draw(): void;
  133424. /**
  133425. * renders one or more effects to a specified texture
  133426. * @param effectWrappers list of effects to renderer
  133427. * @param outputTexture texture to draw to, if null it will render to the screen
  133428. */
  133429. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133430. /**
  133431. * Disposes of the effect renderer
  133432. */
  133433. dispose(): void;
  133434. }
  133435. /**
  133436. * Options to create an EffectWrapper
  133437. */
  133438. interface EffectWrapperCreationOptions {
  133439. /**
  133440. * Engine to use to create the effect
  133441. */
  133442. engine: ThinEngine;
  133443. /**
  133444. * Fragment shader for the effect
  133445. */
  133446. fragmentShader: string;
  133447. /**
  133448. * Vertex shader for the effect
  133449. */
  133450. vertexShader?: string;
  133451. /**
  133452. * Attributes to use in the shader
  133453. */
  133454. attributeNames?: Array<string>;
  133455. /**
  133456. * Uniforms to use in the shader
  133457. */
  133458. uniformNames?: Array<string>;
  133459. /**
  133460. * Texture sampler names to use in the shader
  133461. */
  133462. samplerNames?: Array<string>;
  133463. /**
  133464. * The friendly name of the effect displayed in Spector.
  133465. */
  133466. name?: string;
  133467. }
  133468. /**
  133469. * Wraps an effect to be used for rendering
  133470. */
  133471. export class EffectWrapper {
  133472. /**
  133473. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133474. */
  133475. onApplyObservable: Observable<{}>;
  133476. /**
  133477. * The underlying effect
  133478. */
  133479. effect: Effect;
  133480. /**
  133481. * Creates an effect to be renderer
  133482. * @param creationOptions options to create the effect
  133483. */
  133484. constructor(creationOptions: EffectWrapperCreationOptions);
  133485. /**
  133486. * Disposes of the effect wrapper
  133487. */
  133488. dispose(): void;
  133489. }
  133490. }
  133491. declare module BABYLON {
  133492. /**
  133493. * Helper class to push actions to a pool of workers.
  133494. */
  133495. export class WorkerPool implements IDisposable {
  133496. private _workerInfos;
  133497. private _pendingActions;
  133498. /**
  133499. * Constructor
  133500. * @param workers Array of workers to use for actions
  133501. */
  133502. constructor(workers: Array<Worker>);
  133503. /**
  133504. * Terminates all workers and clears any pending actions.
  133505. */
  133506. dispose(): void;
  133507. /**
  133508. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133509. * pended until a worker has completed its action.
  133510. * @param action The action to perform. Call onComplete when the action is complete.
  133511. */
  133512. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133513. private _execute;
  133514. }
  133515. }
  133516. declare module BABYLON {
  133517. /**
  133518. * Configuration for Draco compression
  133519. */
  133520. export interface IDracoCompressionConfiguration {
  133521. /**
  133522. * Configuration for the decoder.
  133523. */
  133524. decoder: {
  133525. /**
  133526. * The url to the WebAssembly module.
  133527. */
  133528. wasmUrl?: string;
  133529. /**
  133530. * The url to the WebAssembly binary.
  133531. */
  133532. wasmBinaryUrl?: string;
  133533. /**
  133534. * The url to the fallback JavaScript module.
  133535. */
  133536. fallbackUrl?: string;
  133537. };
  133538. }
  133539. /**
  133540. * Draco compression (https://google.github.io/draco/)
  133541. *
  133542. * This class wraps the Draco module.
  133543. *
  133544. * **Encoder**
  133545. *
  133546. * The encoder is not currently implemented.
  133547. *
  133548. * **Decoder**
  133549. *
  133550. * 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.
  133551. *
  133552. * To update the configuration, use the following code:
  133553. * ```javascript
  133554. * DracoCompression.Configuration = {
  133555. * decoder: {
  133556. * wasmUrl: "<url to the WebAssembly library>",
  133557. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133558. * fallbackUrl: "<url to the fallback JavaScript library>",
  133559. * }
  133560. * };
  133561. * ```
  133562. *
  133563. * 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.
  133564. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133565. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133566. *
  133567. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133568. * ```javascript
  133569. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133570. * ```
  133571. *
  133572. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133573. */
  133574. export class DracoCompression implements IDisposable {
  133575. private _workerPoolPromise?;
  133576. private _decoderModulePromise?;
  133577. /**
  133578. * The configuration. Defaults to the following urls:
  133579. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133580. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133581. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133582. */
  133583. static Configuration: IDracoCompressionConfiguration;
  133584. /**
  133585. * Returns true if the decoder configuration is available.
  133586. */
  133587. static get DecoderAvailable(): boolean;
  133588. /**
  133589. * Default number of workers to create when creating the draco compression object.
  133590. */
  133591. static DefaultNumWorkers: number;
  133592. private static GetDefaultNumWorkers;
  133593. private static _Default;
  133594. /**
  133595. * Default instance for the draco compression object.
  133596. */
  133597. static get Default(): DracoCompression;
  133598. /**
  133599. * Constructor
  133600. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133601. */
  133602. constructor(numWorkers?: number);
  133603. /**
  133604. * Stop all async operations and release resources.
  133605. */
  133606. dispose(): void;
  133607. /**
  133608. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133609. * @returns a promise that resolves when ready
  133610. */
  133611. whenReadyAsync(): Promise<void>;
  133612. /**
  133613. * Decode Draco compressed mesh data to vertex data.
  133614. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133615. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133616. * @returns A promise that resolves with the decoded vertex data
  133617. */
  133618. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133619. [kind: string]: number;
  133620. }): Promise<VertexData>;
  133621. }
  133622. }
  133623. declare module BABYLON {
  133624. /**
  133625. * Class for building Constructive Solid Geometry
  133626. */
  133627. export class CSG {
  133628. private polygons;
  133629. /**
  133630. * The world matrix
  133631. */
  133632. matrix: Matrix;
  133633. /**
  133634. * Stores the position
  133635. */
  133636. position: Vector3;
  133637. /**
  133638. * Stores the rotation
  133639. */
  133640. rotation: Vector3;
  133641. /**
  133642. * Stores the rotation quaternion
  133643. */
  133644. rotationQuaternion: Nullable<Quaternion>;
  133645. /**
  133646. * Stores the scaling vector
  133647. */
  133648. scaling: Vector3;
  133649. /**
  133650. * Convert the Mesh to CSG
  133651. * @param mesh The Mesh to convert to CSG
  133652. * @returns A new CSG from the Mesh
  133653. */
  133654. static FromMesh(mesh: Mesh): CSG;
  133655. /**
  133656. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133657. * @param polygons Polygons used to construct a CSG solid
  133658. */
  133659. private static FromPolygons;
  133660. /**
  133661. * Clones, or makes a deep copy, of the CSG
  133662. * @returns A new CSG
  133663. */
  133664. clone(): CSG;
  133665. /**
  133666. * Unions this CSG with another CSG
  133667. * @param csg The CSG to union against this CSG
  133668. * @returns The unioned CSG
  133669. */
  133670. union(csg: CSG): CSG;
  133671. /**
  133672. * Unions this CSG with another CSG in place
  133673. * @param csg The CSG to union against this CSG
  133674. */
  133675. unionInPlace(csg: CSG): void;
  133676. /**
  133677. * Subtracts this CSG with another CSG
  133678. * @param csg The CSG to subtract against this CSG
  133679. * @returns A new CSG
  133680. */
  133681. subtract(csg: CSG): CSG;
  133682. /**
  133683. * Subtracts this CSG with another CSG in place
  133684. * @param csg The CSG to subtact against this CSG
  133685. */
  133686. subtractInPlace(csg: CSG): void;
  133687. /**
  133688. * Intersect this CSG with another CSG
  133689. * @param csg The CSG to intersect against this CSG
  133690. * @returns A new CSG
  133691. */
  133692. intersect(csg: CSG): CSG;
  133693. /**
  133694. * Intersects this CSG with another CSG in place
  133695. * @param csg The CSG to intersect against this CSG
  133696. */
  133697. intersectInPlace(csg: CSG): void;
  133698. /**
  133699. * Return a new CSG solid with solid and empty space switched. This solid is
  133700. * not modified.
  133701. * @returns A new CSG solid with solid and empty space switched
  133702. */
  133703. inverse(): CSG;
  133704. /**
  133705. * Inverses the CSG in place
  133706. */
  133707. inverseInPlace(): void;
  133708. /**
  133709. * This is used to keep meshes transformations so they can be restored
  133710. * when we build back a Babylon Mesh
  133711. * NB : All CSG operations are performed in world coordinates
  133712. * @param csg The CSG to copy the transform attributes from
  133713. * @returns This CSG
  133714. */
  133715. copyTransformAttributes(csg: CSG): CSG;
  133716. /**
  133717. * Build Raw mesh from CSG
  133718. * Coordinates here are in world space
  133719. * @param name The name of the mesh geometry
  133720. * @param scene The Scene
  133721. * @param keepSubMeshes Specifies if the submeshes should be kept
  133722. * @returns A new Mesh
  133723. */
  133724. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133725. /**
  133726. * Build Mesh from CSG taking material and transforms into account
  133727. * @param name The name of the Mesh
  133728. * @param material The material of the Mesh
  133729. * @param scene The Scene
  133730. * @param keepSubMeshes Specifies if submeshes should be kept
  133731. * @returns The new Mesh
  133732. */
  133733. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133734. }
  133735. }
  133736. declare module BABYLON {
  133737. /**
  133738. * Class used to create a trail following a mesh
  133739. */
  133740. export class TrailMesh extends Mesh {
  133741. private _generator;
  133742. private _autoStart;
  133743. private _running;
  133744. private _diameter;
  133745. private _length;
  133746. private _sectionPolygonPointsCount;
  133747. private _sectionVectors;
  133748. private _sectionNormalVectors;
  133749. private _beforeRenderObserver;
  133750. /**
  133751. * @constructor
  133752. * @param name The value used by scene.getMeshByName() to do a lookup.
  133753. * @param generator The mesh or transform node to generate a trail.
  133754. * @param scene The scene to add this mesh to.
  133755. * @param diameter Diameter of trailing mesh. Default is 1.
  133756. * @param length Length of trailing mesh. Default is 60.
  133757. * @param autoStart Automatically start trailing mesh. Default true.
  133758. */
  133759. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133760. /**
  133761. * "TrailMesh"
  133762. * @returns "TrailMesh"
  133763. */
  133764. getClassName(): string;
  133765. private _createMesh;
  133766. /**
  133767. * Start trailing mesh.
  133768. */
  133769. start(): void;
  133770. /**
  133771. * Stop trailing mesh.
  133772. */
  133773. stop(): void;
  133774. /**
  133775. * Update trailing mesh geometry.
  133776. */
  133777. update(): void;
  133778. /**
  133779. * Returns a new TrailMesh object.
  133780. * @param name is a string, the name given to the new mesh
  133781. * @param newGenerator use new generator object for cloned trail mesh
  133782. * @returns a new mesh
  133783. */
  133784. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133785. /**
  133786. * Serializes this trail mesh
  133787. * @param serializationObject object to write serialization to
  133788. */
  133789. serialize(serializationObject: any): void;
  133790. /**
  133791. * Parses a serialized trail mesh
  133792. * @param parsedMesh the serialized mesh
  133793. * @param scene the scene to create the trail mesh in
  133794. * @returns the created trail mesh
  133795. */
  133796. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133797. }
  133798. }
  133799. declare module BABYLON {
  133800. /**
  133801. * Class containing static functions to help procedurally build meshes
  133802. */
  133803. export class TiledBoxBuilder {
  133804. /**
  133805. * Creates a box mesh
  133806. * 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)
  133807. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133811. * @param name defines the name of the mesh
  133812. * @param options defines the options used to create the mesh
  133813. * @param scene defines the hosting scene
  133814. * @returns the box mesh
  133815. */
  133816. static CreateTiledBox(name: string, options: {
  133817. pattern?: number;
  133818. width?: number;
  133819. height?: number;
  133820. depth?: number;
  133821. tileSize?: number;
  133822. tileWidth?: number;
  133823. tileHeight?: number;
  133824. alignHorizontal?: number;
  133825. alignVertical?: number;
  133826. faceUV?: Vector4[];
  133827. faceColors?: Color4[];
  133828. sideOrientation?: number;
  133829. updatable?: boolean;
  133830. }, scene?: Nullable<Scene>): Mesh;
  133831. }
  133832. }
  133833. declare module BABYLON {
  133834. /**
  133835. * Class containing static functions to help procedurally build meshes
  133836. */
  133837. export class TorusKnotBuilder {
  133838. /**
  133839. * Creates a torus knot mesh
  133840. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133841. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133842. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133843. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133845. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133847. * @param name defines the name of the mesh
  133848. * @param options defines the options used to create the mesh
  133849. * @param scene defines the hosting scene
  133850. * @returns the torus knot mesh
  133851. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133852. */
  133853. static CreateTorusKnot(name: string, options: {
  133854. radius?: number;
  133855. tube?: number;
  133856. radialSegments?: number;
  133857. tubularSegments?: number;
  133858. p?: number;
  133859. q?: number;
  133860. updatable?: boolean;
  133861. sideOrientation?: number;
  133862. frontUVs?: Vector4;
  133863. backUVs?: Vector4;
  133864. }, scene: any): Mesh;
  133865. }
  133866. }
  133867. declare module BABYLON {
  133868. /**
  133869. * Polygon
  133870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133871. */
  133872. export class Polygon {
  133873. /**
  133874. * Creates a rectangle
  133875. * @param xmin bottom X coord
  133876. * @param ymin bottom Y coord
  133877. * @param xmax top X coord
  133878. * @param ymax top Y coord
  133879. * @returns points that make the resulting rectation
  133880. */
  133881. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133882. /**
  133883. * Creates a circle
  133884. * @param radius radius of circle
  133885. * @param cx scale in x
  133886. * @param cy scale in y
  133887. * @param numberOfSides number of sides that make up the circle
  133888. * @returns points that make the resulting circle
  133889. */
  133890. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133891. /**
  133892. * Creates a polygon from input string
  133893. * @param input Input polygon data
  133894. * @returns the parsed points
  133895. */
  133896. static Parse(input: string): Vector2[];
  133897. /**
  133898. * Starts building a polygon from x and y coordinates
  133899. * @param x x coordinate
  133900. * @param y y coordinate
  133901. * @returns the started path2
  133902. */
  133903. static StartingAt(x: number, y: number): Path2;
  133904. }
  133905. /**
  133906. * Builds a polygon
  133907. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133908. */
  133909. export class PolygonMeshBuilder {
  133910. private _points;
  133911. private _outlinepoints;
  133912. private _holes;
  133913. private _name;
  133914. private _scene;
  133915. private _epoints;
  133916. private _eholes;
  133917. private _addToepoint;
  133918. /**
  133919. * Babylon reference to the earcut plugin.
  133920. */
  133921. bjsEarcut: any;
  133922. /**
  133923. * Creates a PolygonMeshBuilder
  133924. * @param name name of the builder
  133925. * @param contours Path of the polygon
  133926. * @param scene scene to add to when creating the mesh
  133927. * @param earcutInjection can be used to inject your own earcut reference
  133928. */
  133929. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133930. /**
  133931. * Adds a whole within the polygon
  133932. * @param hole Array of points defining the hole
  133933. * @returns this
  133934. */
  133935. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133936. /**
  133937. * Creates the polygon
  133938. * @param updatable If the mesh should be updatable
  133939. * @param depth The depth of the mesh created
  133940. * @returns the created mesh
  133941. */
  133942. build(updatable?: boolean, depth?: number): Mesh;
  133943. /**
  133944. * Creates the polygon
  133945. * @param depth The depth of the mesh created
  133946. * @returns the created VertexData
  133947. */
  133948. buildVertexData(depth?: number): VertexData;
  133949. /**
  133950. * Adds a side to the polygon
  133951. * @param positions points that make the polygon
  133952. * @param normals normals of the polygon
  133953. * @param uvs uvs of the polygon
  133954. * @param indices indices of the polygon
  133955. * @param bounds bounds of the polygon
  133956. * @param points points of the polygon
  133957. * @param depth depth of the polygon
  133958. * @param flip flip of the polygon
  133959. */
  133960. private addSide;
  133961. }
  133962. }
  133963. declare module BABYLON {
  133964. /**
  133965. * Class containing static functions to help procedurally build meshes
  133966. */
  133967. export class PolygonBuilder {
  133968. /**
  133969. * Creates a polygon mesh
  133970. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133971. * * 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
  133972. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133975. * * Remember you can only change the shape positions, not their number when updating a polygon
  133976. * @param name defines the name of the mesh
  133977. * @param options defines the options used to create the mesh
  133978. * @param scene defines the hosting scene
  133979. * @param earcutInjection can be used to inject your own earcut reference
  133980. * @returns the polygon mesh
  133981. */
  133982. static CreatePolygon(name: string, options: {
  133983. shape: Vector3[];
  133984. holes?: Vector3[][];
  133985. depth?: number;
  133986. faceUV?: Vector4[];
  133987. faceColors?: Color4[];
  133988. updatable?: boolean;
  133989. sideOrientation?: number;
  133990. frontUVs?: Vector4;
  133991. backUVs?: Vector4;
  133992. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133993. /**
  133994. * Creates an extruded polygon mesh, with depth in the Y direction.
  133995. * * 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)
  133996. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133997. * @param name defines the name of the mesh
  133998. * @param options defines the options used to create the mesh
  133999. * @param scene defines the hosting scene
  134000. * @param earcutInjection can be used to inject your own earcut reference
  134001. * @returns the polygon mesh
  134002. */
  134003. static ExtrudePolygon(name: string, options: {
  134004. shape: Vector3[];
  134005. holes?: Vector3[][];
  134006. depth?: number;
  134007. faceUV?: Vector4[];
  134008. faceColors?: Color4[];
  134009. updatable?: boolean;
  134010. sideOrientation?: number;
  134011. frontUVs?: Vector4;
  134012. backUVs?: Vector4;
  134013. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134014. }
  134015. }
  134016. declare module BABYLON {
  134017. /**
  134018. * Class containing static functions to help procedurally build meshes
  134019. */
  134020. export class LatheBuilder {
  134021. /**
  134022. * Creates lathe mesh.
  134023. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134024. * * 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
  134025. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134026. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134027. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134028. * * 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
  134029. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134030. * * 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
  134031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134033. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134035. * @param name defines the name of the mesh
  134036. * @param options defines the options used to create the mesh
  134037. * @param scene defines the hosting scene
  134038. * @returns the lathe mesh
  134039. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134040. */
  134041. static CreateLathe(name: string, options: {
  134042. shape: Vector3[];
  134043. radius?: number;
  134044. tessellation?: number;
  134045. clip?: number;
  134046. arc?: number;
  134047. closed?: boolean;
  134048. updatable?: boolean;
  134049. sideOrientation?: number;
  134050. frontUVs?: Vector4;
  134051. backUVs?: Vector4;
  134052. cap?: number;
  134053. invertUV?: boolean;
  134054. }, scene?: Nullable<Scene>): Mesh;
  134055. }
  134056. }
  134057. declare module BABYLON {
  134058. /**
  134059. * Class containing static functions to help procedurally build meshes
  134060. */
  134061. export class TiledPlaneBuilder {
  134062. /**
  134063. * Creates a tiled plane mesh
  134064. * * The parameter `pattern` will, depending on value, do nothing or
  134065. * * * flip (reflect about central vertical) alternate tiles across and up
  134066. * * * flip every tile on alternate rows
  134067. * * * rotate (180 degs) alternate tiles across and up
  134068. * * * rotate every tile on alternate rows
  134069. * * * flip and rotate alternate tiles across and up
  134070. * * * flip and rotate every tile on alternate rows
  134071. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134072. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134074. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134075. * * 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)
  134076. * * 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)
  134077. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134078. * @param name defines the name of the mesh
  134079. * @param options defines the options used to create the mesh
  134080. * @param scene defines the hosting scene
  134081. * @returns the box mesh
  134082. */
  134083. static CreateTiledPlane(name: string, options: {
  134084. pattern?: number;
  134085. tileSize?: number;
  134086. tileWidth?: number;
  134087. tileHeight?: number;
  134088. size?: number;
  134089. width?: number;
  134090. height?: number;
  134091. alignHorizontal?: number;
  134092. alignVertical?: number;
  134093. sideOrientation?: number;
  134094. frontUVs?: Vector4;
  134095. backUVs?: Vector4;
  134096. updatable?: boolean;
  134097. }, scene?: Nullable<Scene>): Mesh;
  134098. }
  134099. }
  134100. declare module BABYLON {
  134101. /**
  134102. * Class containing static functions to help procedurally build meshes
  134103. */
  134104. export class TubeBuilder {
  134105. /**
  134106. * Creates a tube mesh.
  134107. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134108. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134109. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134110. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134111. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134112. * * 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)
  134113. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134114. * * 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
  134115. * * 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
  134116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134118. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134120. * @param name defines the name of the mesh
  134121. * @param options defines the options used to create the mesh
  134122. * @param scene defines the hosting scene
  134123. * @returns the tube mesh
  134124. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134125. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134126. */
  134127. static CreateTube(name: string, options: {
  134128. path: Vector3[];
  134129. radius?: number;
  134130. tessellation?: number;
  134131. radiusFunction?: {
  134132. (i: number, distance: number): number;
  134133. };
  134134. cap?: number;
  134135. arc?: number;
  134136. updatable?: boolean;
  134137. sideOrientation?: number;
  134138. frontUVs?: Vector4;
  134139. backUVs?: Vector4;
  134140. instance?: Mesh;
  134141. invertUV?: boolean;
  134142. }, scene?: Nullable<Scene>): Mesh;
  134143. }
  134144. }
  134145. declare module BABYLON {
  134146. /**
  134147. * Class containing static functions to help procedurally build meshes
  134148. */
  134149. export class IcoSphereBuilder {
  134150. /**
  134151. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134152. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134153. * * 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`)
  134154. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134155. * * 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
  134156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134159. * @param name defines the name of the mesh
  134160. * @param options defines the options used to create the mesh
  134161. * @param scene defines the hosting scene
  134162. * @returns the icosahedron mesh
  134163. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134164. */
  134165. static CreateIcoSphere(name: string, options: {
  134166. radius?: number;
  134167. radiusX?: number;
  134168. radiusY?: number;
  134169. radiusZ?: number;
  134170. flat?: boolean;
  134171. subdivisions?: number;
  134172. sideOrientation?: number;
  134173. frontUVs?: Vector4;
  134174. backUVs?: Vector4;
  134175. updatable?: boolean;
  134176. }, scene?: Nullable<Scene>): Mesh;
  134177. }
  134178. }
  134179. declare module BABYLON {
  134180. /**
  134181. * Class containing static functions to help procedurally build meshes
  134182. */
  134183. export class DecalBuilder {
  134184. /**
  134185. * Creates a decal mesh.
  134186. * 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
  134187. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134188. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134189. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134190. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134191. * @param name defines the name of the mesh
  134192. * @param sourceMesh defines the mesh where the decal must be applied
  134193. * @param options defines the options used to create the mesh
  134194. * @param scene defines the hosting scene
  134195. * @returns the decal mesh
  134196. * @see https://doc.babylonjs.com/how_to/decals
  134197. */
  134198. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134199. position?: Vector3;
  134200. normal?: Vector3;
  134201. size?: Vector3;
  134202. angle?: number;
  134203. }): Mesh;
  134204. }
  134205. }
  134206. declare module BABYLON {
  134207. /**
  134208. * Class containing static functions to help procedurally build meshes
  134209. */
  134210. export class MeshBuilder {
  134211. /**
  134212. * Creates a box mesh
  134213. * * The parameter `size` sets the size (float) of each box side (default 1)
  134214. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134215. * * 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)
  134216. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134221. * @param name defines the name of the mesh
  134222. * @param options defines the options used to create the mesh
  134223. * @param scene defines the hosting scene
  134224. * @returns the box mesh
  134225. */
  134226. static CreateBox(name: string, options: {
  134227. size?: number;
  134228. width?: number;
  134229. height?: number;
  134230. depth?: number;
  134231. faceUV?: Vector4[];
  134232. faceColors?: Color4[];
  134233. sideOrientation?: number;
  134234. frontUVs?: Vector4;
  134235. backUVs?: Vector4;
  134236. updatable?: boolean;
  134237. }, scene?: Nullable<Scene>): Mesh;
  134238. /**
  134239. * Creates a tiled box mesh
  134240. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134242. * @param name defines the name of the mesh
  134243. * @param options defines the options used to create the mesh
  134244. * @param scene defines the hosting scene
  134245. * @returns the tiled box mesh
  134246. */
  134247. static CreateTiledBox(name: string, options: {
  134248. pattern?: number;
  134249. size?: number;
  134250. width?: number;
  134251. height?: number;
  134252. depth: number;
  134253. tileSize?: number;
  134254. tileWidth?: number;
  134255. tileHeight?: number;
  134256. faceUV?: Vector4[];
  134257. faceColors?: Color4[];
  134258. alignHorizontal?: number;
  134259. alignVertical?: number;
  134260. sideOrientation?: number;
  134261. updatable?: boolean;
  134262. }, scene?: Nullable<Scene>): Mesh;
  134263. /**
  134264. * Creates a sphere mesh
  134265. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134266. * * 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`)
  134267. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134268. * * 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
  134269. * * 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)
  134270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134273. * @param name defines the name of the mesh
  134274. * @param options defines the options used to create the mesh
  134275. * @param scene defines the hosting scene
  134276. * @returns the sphere mesh
  134277. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134278. */
  134279. static CreateSphere(name: string, options: {
  134280. segments?: number;
  134281. diameter?: number;
  134282. diameterX?: number;
  134283. diameterY?: number;
  134284. diameterZ?: number;
  134285. arc?: number;
  134286. slice?: number;
  134287. sideOrientation?: number;
  134288. frontUVs?: Vector4;
  134289. backUVs?: Vector4;
  134290. updatable?: boolean;
  134291. }, scene?: Nullable<Scene>): Mesh;
  134292. /**
  134293. * Creates a plane polygonal mesh. By default, this is a disc
  134294. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134295. * * 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
  134296. * * 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
  134297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134300. * @param name defines the name of the mesh
  134301. * @param options defines the options used to create the mesh
  134302. * @param scene defines the hosting scene
  134303. * @returns the plane polygonal mesh
  134304. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134305. */
  134306. static CreateDisc(name: string, options: {
  134307. radius?: number;
  134308. tessellation?: number;
  134309. arc?: number;
  134310. updatable?: boolean;
  134311. sideOrientation?: number;
  134312. frontUVs?: Vector4;
  134313. backUVs?: Vector4;
  134314. }, scene?: Nullable<Scene>): Mesh;
  134315. /**
  134316. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134317. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134318. * * 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`)
  134319. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134320. * * 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
  134321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134324. * @param name defines the name of the mesh
  134325. * @param options defines the options used to create the mesh
  134326. * @param scene defines the hosting scene
  134327. * @returns the icosahedron mesh
  134328. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134329. */
  134330. static CreateIcoSphere(name: string, options: {
  134331. radius?: number;
  134332. radiusX?: number;
  134333. radiusY?: number;
  134334. radiusZ?: number;
  134335. flat?: boolean;
  134336. subdivisions?: number;
  134337. sideOrientation?: number;
  134338. frontUVs?: Vector4;
  134339. backUVs?: Vector4;
  134340. updatable?: boolean;
  134341. }, scene?: Nullable<Scene>): Mesh;
  134342. /**
  134343. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134344. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134345. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134346. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134347. * * 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
  134348. * * 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
  134349. * * 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
  134350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134352. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134353. * * 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
  134354. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134355. * * 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
  134356. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134358. * @param name defines the name of the mesh
  134359. * @param options defines the options used to create the mesh
  134360. * @param scene defines the hosting scene
  134361. * @returns the ribbon mesh
  134362. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134363. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134364. */
  134365. static CreateRibbon(name: string, options: {
  134366. pathArray: Vector3[][];
  134367. closeArray?: boolean;
  134368. closePath?: boolean;
  134369. offset?: number;
  134370. updatable?: boolean;
  134371. sideOrientation?: number;
  134372. frontUVs?: Vector4;
  134373. backUVs?: Vector4;
  134374. instance?: Mesh;
  134375. invertUV?: boolean;
  134376. uvs?: Vector2[];
  134377. colors?: Color4[];
  134378. }, scene?: Nullable<Scene>): Mesh;
  134379. /**
  134380. * Creates a cylinder or a cone mesh
  134381. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134382. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134383. * * 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.
  134384. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134385. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134386. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134387. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134388. * * 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).
  134389. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134390. * * 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).
  134391. * * 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
  134392. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134393. * * 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
  134394. * * 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.
  134395. * * If `enclose` is false, a ring surface is one element.
  134396. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134397. * * 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
  134398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134401. * @param name defines the name of the mesh
  134402. * @param options defines the options used to create the mesh
  134403. * @param scene defines the hosting scene
  134404. * @returns the cylinder mesh
  134405. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134406. */
  134407. static CreateCylinder(name: string, options: {
  134408. height?: number;
  134409. diameterTop?: number;
  134410. diameterBottom?: number;
  134411. diameter?: number;
  134412. tessellation?: number;
  134413. subdivisions?: number;
  134414. arc?: number;
  134415. faceColors?: Color4[];
  134416. faceUV?: Vector4[];
  134417. updatable?: boolean;
  134418. hasRings?: boolean;
  134419. enclose?: boolean;
  134420. cap?: number;
  134421. sideOrientation?: number;
  134422. frontUVs?: Vector4;
  134423. backUVs?: Vector4;
  134424. }, scene?: Nullable<Scene>): Mesh;
  134425. /**
  134426. * Creates a torus mesh
  134427. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134428. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134429. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134433. * @param name defines the name of the mesh
  134434. * @param options defines the options used to create the mesh
  134435. * @param scene defines the hosting scene
  134436. * @returns the torus mesh
  134437. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134438. */
  134439. static CreateTorus(name: string, options: {
  134440. diameter?: number;
  134441. thickness?: number;
  134442. tessellation?: number;
  134443. updatable?: boolean;
  134444. sideOrientation?: number;
  134445. frontUVs?: Vector4;
  134446. backUVs?: Vector4;
  134447. }, scene?: Nullable<Scene>): Mesh;
  134448. /**
  134449. * Creates a torus knot mesh
  134450. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134451. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134452. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134453. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134457. * @param name defines the name of the mesh
  134458. * @param options defines the options used to create the mesh
  134459. * @param scene defines the hosting scene
  134460. * @returns the torus knot mesh
  134461. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134462. */
  134463. static CreateTorusKnot(name: string, options: {
  134464. radius?: number;
  134465. tube?: number;
  134466. radialSegments?: number;
  134467. tubularSegments?: number;
  134468. p?: number;
  134469. q?: number;
  134470. updatable?: boolean;
  134471. sideOrientation?: number;
  134472. frontUVs?: Vector4;
  134473. backUVs?: Vector4;
  134474. }, scene?: Nullable<Scene>): Mesh;
  134475. /**
  134476. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134477. * * 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
  134478. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134479. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134480. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134481. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134482. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134483. * * 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
  134484. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134487. * @param name defines the name of the new line system
  134488. * @param options defines the options used to create the line system
  134489. * @param scene defines the hosting scene
  134490. * @returns a new line system mesh
  134491. */
  134492. static CreateLineSystem(name: string, options: {
  134493. lines: Vector3[][];
  134494. updatable?: boolean;
  134495. instance?: Nullable<LinesMesh>;
  134496. colors?: Nullable<Color4[][]>;
  134497. useVertexAlpha?: boolean;
  134498. }, scene: Nullable<Scene>): LinesMesh;
  134499. /**
  134500. * Creates a line mesh
  134501. * 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
  134502. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134503. * * The parameter `points` is an array successive Vector3
  134504. * * 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
  134505. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134506. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134507. * * When updating an instance, remember that only point positions can change, not the number of points
  134508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134510. * @param name defines the name of the new line system
  134511. * @param options defines the options used to create the line system
  134512. * @param scene defines the hosting scene
  134513. * @returns a new line mesh
  134514. */
  134515. static CreateLines(name: string, options: {
  134516. points: Vector3[];
  134517. updatable?: boolean;
  134518. instance?: Nullable<LinesMesh>;
  134519. colors?: Color4[];
  134520. useVertexAlpha?: boolean;
  134521. }, scene?: Nullable<Scene>): LinesMesh;
  134522. /**
  134523. * Creates a dashed line mesh
  134524. * * 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
  134525. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134526. * * The parameter `points` is an array successive Vector3
  134527. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134528. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134529. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134530. * * 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
  134531. * * When updating an instance, remember that only point positions can change, not the number of points
  134532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134533. * @param name defines the name of the mesh
  134534. * @param options defines the options used to create the mesh
  134535. * @param scene defines the hosting scene
  134536. * @returns the dashed line mesh
  134537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134538. */
  134539. static CreateDashedLines(name: string, options: {
  134540. points: Vector3[];
  134541. dashSize?: number;
  134542. gapSize?: number;
  134543. dashNb?: number;
  134544. updatable?: boolean;
  134545. instance?: LinesMesh;
  134546. }, scene?: Nullable<Scene>): LinesMesh;
  134547. /**
  134548. * 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.
  134549. * * 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.
  134550. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134551. * * 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.
  134552. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134553. * * 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
  134554. * * 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
  134555. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134558. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134560. * @param name defines the name of the mesh
  134561. * @param options defines the options used to create the mesh
  134562. * @param scene defines the hosting scene
  134563. * @returns the extruded shape mesh
  134564. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134566. */
  134567. static ExtrudeShape(name: string, options: {
  134568. shape: Vector3[];
  134569. path: Vector3[];
  134570. scale?: number;
  134571. rotation?: number;
  134572. cap?: number;
  134573. updatable?: boolean;
  134574. sideOrientation?: number;
  134575. frontUVs?: Vector4;
  134576. backUVs?: Vector4;
  134577. instance?: Mesh;
  134578. invertUV?: boolean;
  134579. }, scene?: Nullable<Scene>): Mesh;
  134580. /**
  134581. * Creates an custom extruded shape mesh.
  134582. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134583. * * 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.
  134584. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134585. * * 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
  134586. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134587. * * 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
  134588. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134589. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134590. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134591. * * 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
  134592. * * 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
  134593. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134595. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134596. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134598. * @param name defines the name of the mesh
  134599. * @param options defines the options used to create the mesh
  134600. * @param scene defines the hosting scene
  134601. * @returns the custom extruded shape mesh
  134602. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134603. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134605. */
  134606. static ExtrudeShapeCustom(name: string, options: {
  134607. shape: Vector3[];
  134608. path: Vector3[];
  134609. scaleFunction?: any;
  134610. rotationFunction?: any;
  134611. ribbonCloseArray?: boolean;
  134612. ribbonClosePath?: boolean;
  134613. cap?: number;
  134614. updatable?: boolean;
  134615. sideOrientation?: number;
  134616. frontUVs?: Vector4;
  134617. backUVs?: Vector4;
  134618. instance?: Mesh;
  134619. invertUV?: boolean;
  134620. }, scene?: Nullable<Scene>): Mesh;
  134621. /**
  134622. * Creates lathe mesh.
  134623. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134624. * * 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
  134625. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134626. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134627. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134628. * * 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
  134629. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134630. * * 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
  134631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134633. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134635. * @param name defines the name of the mesh
  134636. * @param options defines the options used to create the mesh
  134637. * @param scene defines the hosting scene
  134638. * @returns the lathe mesh
  134639. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134640. */
  134641. static CreateLathe(name: string, options: {
  134642. shape: Vector3[];
  134643. radius?: number;
  134644. tessellation?: number;
  134645. clip?: number;
  134646. arc?: number;
  134647. closed?: boolean;
  134648. updatable?: boolean;
  134649. sideOrientation?: number;
  134650. frontUVs?: Vector4;
  134651. backUVs?: Vector4;
  134652. cap?: number;
  134653. invertUV?: boolean;
  134654. }, scene?: Nullable<Scene>): Mesh;
  134655. /**
  134656. * Creates a tiled plane mesh
  134657. * * You can set a limited pattern arrangement with the tiles
  134658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134661. * @param name defines the name of the mesh
  134662. * @param options defines the options used to create the mesh
  134663. * @param scene defines the hosting scene
  134664. * @returns the plane mesh
  134665. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134666. */
  134667. static CreateTiledPlane(name: string, options: {
  134668. pattern?: number;
  134669. tileSize?: number;
  134670. tileWidth?: number;
  134671. tileHeight?: number;
  134672. size?: number;
  134673. width?: number;
  134674. height?: number;
  134675. alignHorizontal?: number;
  134676. alignVertical?: number;
  134677. sideOrientation?: number;
  134678. frontUVs?: Vector4;
  134679. backUVs?: Vector4;
  134680. updatable?: boolean;
  134681. }, scene?: Nullable<Scene>): Mesh;
  134682. /**
  134683. * Creates a plane mesh
  134684. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134685. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134686. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134690. * @param name defines the name of the mesh
  134691. * @param options defines the options used to create the mesh
  134692. * @param scene defines the hosting scene
  134693. * @returns the plane mesh
  134694. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134695. */
  134696. static CreatePlane(name: string, options: {
  134697. size?: number;
  134698. width?: number;
  134699. height?: number;
  134700. sideOrientation?: number;
  134701. frontUVs?: Vector4;
  134702. backUVs?: Vector4;
  134703. updatable?: boolean;
  134704. sourcePlane?: Plane;
  134705. }, scene?: Nullable<Scene>): Mesh;
  134706. /**
  134707. * Creates a ground mesh
  134708. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134709. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134711. * @param name defines the name of the mesh
  134712. * @param options defines the options used to create the mesh
  134713. * @param scene defines the hosting scene
  134714. * @returns the ground mesh
  134715. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134716. */
  134717. static CreateGround(name: string, options: {
  134718. width?: number;
  134719. height?: number;
  134720. subdivisions?: number;
  134721. subdivisionsX?: number;
  134722. subdivisionsY?: number;
  134723. updatable?: boolean;
  134724. }, scene?: Nullable<Scene>): Mesh;
  134725. /**
  134726. * Creates a tiled ground mesh
  134727. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134728. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134729. * * 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
  134730. * * 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
  134731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134732. * @param name defines the name of the mesh
  134733. * @param options defines the options used to create the mesh
  134734. * @param scene defines the hosting scene
  134735. * @returns the tiled ground mesh
  134736. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134737. */
  134738. static CreateTiledGround(name: string, options: {
  134739. xmin: number;
  134740. zmin: number;
  134741. xmax: number;
  134742. zmax: number;
  134743. subdivisions?: {
  134744. w: number;
  134745. h: number;
  134746. };
  134747. precision?: {
  134748. w: number;
  134749. h: number;
  134750. };
  134751. updatable?: boolean;
  134752. }, scene?: Nullable<Scene>): Mesh;
  134753. /**
  134754. * Creates a ground mesh from a height map
  134755. * * The parameter `url` sets the URL of the height map image resource.
  134756. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134757. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134758. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134759. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134760. * * 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.
  134761. * * 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).
  134762. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134764. * @param name defines the name of the mesh
  134765. * @param url defines the url to the height map
  134766. * @param options defines the options used to create the mesh
  134767. * @param scene defines the hosting scene
  134768. * @returns the ground mesh
  134769. * @see https://doc.babylonjs.com/babylon101/height_map
  134770. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134771. */
  134772. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134773. width?: number;
  134774. height?: number;
  134775. subdivisions?: number;
  134776. minHeight?: number;
  134777. maxHeight?: number;
  134778. colorFilter?: Color3;
  134779. alphaFilter?: number;
  134780. updatable?: boolean;
  134781. onReady?: (mesh: GroundMesh) => void;
  134782. }, scene?: Nullable<Scene>): GroundMesh;
  134783. /**
  134784. * Creates a polygon mesh
  134785. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134786. * * 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
  134787. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134790. * * Remember you can only change the shape positions, not their number when updating a polygon
  134791. * @param name defines the name of the mesh
  134792. * @param options defines the options used to create the mesh
  134793. * @param scene defines the hosting scene
  134794. * @param earcutInjection can be used to inject your own earcut reference
  134795. * @returns the polygon mesh
  134796. */
  134797. static CreatePolygon(name: string, options: {
  134798. shape: Vector3[];
  134799. holes?: Vector3[][];
  134800. depth?: number;
  134801. faceUV?: Vector4[];
  134802. faceColors?: Color4[];
  134803. updatable?: boolean;
  134804. sideOrientation?: number;
  134805. frontUVs?: Vector4;
  134806. backUVs?: Vector4;
  134807. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134808. /**
  134809. * Creates an extruded polygon mesh, with depth in the Y direction.
  134810. * * 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)
  134811. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134812. * @param name defines the name of the mesh
  134813. * @param options defines the options used to create the mesh
  134814. * @param scene defines the hosting scene
  134815. * @param earcutInjection can be used to inject your own earcut reference
  134816. * @returns the polygon mesh
  134817. */
  134818. static ExtrudePolygon(name: string, options: {
  134819. shape: Vector3[];
  134820. holes?: Vector3[][];
  134821. depth?: number;
  134822. faceUV?: Vector4[];
  134823. faceColors?: Color4[];
  134824. updatable?: boolean;
  134825. sideOrientation?: number;
  134826. frontUVs?: Vector4;
  134827. backUVs?: Vector4;
  134828. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134829. /**
  134830. * Creates a tube mesh.
  134831. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134832. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134833. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134834. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134835. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134836. * * 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)
  134837. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134838. * * 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
  134839. * * 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
  134840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134842. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134844. * @param name defines the name of the mesh
  134845. * @param options defines the options used to create the mesh
  134846. * @param scene defines the hosting scene
  134847. * @returns the tube mesh
  134848. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134849. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134850. */
  134851. static CreateTube(name: string, options: {
  134852. path: Vector3[];
  134853. radius?: number;
  134854. tessellation?: number;
  134855. radiusFunction?: {
  134856. (i: number, distance: number): number;
  134857. };
  134858. cap?: number;
  134859. arc?: number;
  134860. updatable?: boolean;
  134861. sideOrientation?: number;
  134862. frontUVs?: Vector4;
  134863. backUVs?: Vector4;
  134864. instance?: Mesh;
  134865. invertUV?: boolean;
  134866. }, scene?: Nullable<Scene>): Mesh;
  134867. /**
  134868. * Creates a polyhedron mesh
  134869. * * 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
  134870. * * The parameter `size` (positive float, default 1) sets the polygon size
  134871. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134872. * * 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`
  134873. * * 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
  134874. * * 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)`)
  134875. * * 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
  134876. * * 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
  134877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134880. * @param name defines the name of the mesh
  134881. * @param options defines the options used to create the mesh
  134882. * @param scene defines the hosting scene
  134883. * @returns the polyhedron mesh
  134884. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134885. */
  134886. static CreatePolyhedron(name: string, options: {
  134887. type?: number;
  134888. size?: number;
  134889. sizeX?: number;
  134890. sizeY?: number;
  134891. sizeZ?: number;
  134892. custom?: any;
  134893. faceUV?: Vector4[];
  134894. faceColors?: Color4[];
  134895. flat?: boolean;
  134896. updatable?: boolean;
  134897. sideOrientation?: number;
  134898. frontUVs?: Vector4;
  134899. backUVs?: Vector4;
  134900. }, scene?: Nullable<Scene>): Mesh;
  134901. /**
  134902. * Creates a decal mesh.
  134903. * 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
  134904. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134905. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134906. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134907. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134908. * @param name defines the name of the mesh
  134909. * @param sourceMesh defines the mesh where the decal must be applied
  134910. * @param options defines the options used to create the mesh
  134911. * @param scene defines the hosting scene
  134912. * @returns the decal mesh
  134913. * @see https://doc.babylonjs.com/how_to/decals
  134914. */
  134915. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134916. position?: Vector3;
  134917. normal?: Vector3;
  134918. size?: Vector3;
  134919. angle?: number;
  134920. }): Mesh;
  134921. }
  134922. }
  134923. declare module BABYLON {
  134924. /**
  134925. * A simplifier interface for future simplification implementations
  134926. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134927. */
  134928. export interface ISimplifier {
  134929. /**
  134930. * Simplification of a given mesh according to the given settings.
  134931. * Since this requires computation, it is assumed that the function runs async.
  134932. * @param settings The settings of the simplification, including quality and distance
  134933. * @param successCallback A callback that will be called after the mesh was simplified.
  134934. * @param errorCallback in case of an error, this callback will be called. optional.
  134935. */
  134936. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134937. }
  134938. /**
  134939. * Expected simplification settings.
  134940. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134941. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134942. */
  134943. export interface ISimplificationSettings {
  134944. /**
  134945. * Gets or sets the expected quality
  134946. */
  134947. quality: number;
  134948. /**
  134949. * Gets or sets the distance when this optimized version should be used
  134950. */
  134951. distance: number;
  134952. /**
  134953. * Gets an already optimized mesh
  134954. */
  134955. optimizeMesh?: boolean;
  134956. }
  134957. /**
  134958. * Class used to specify simplification options
  134959. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134960. */
  134961. export class SimplificationSettings implements ISimplificationSettings {
  134962. /** expected quality */
  134963. quality: number;
  134964. /** distance when this optimized version should be used */
  134965. distance: number;
  134966. /** already optimized mesh */
  134967. optimizeMesh?: boolean | undefined;
  134968. /**
  134969. * Creates a SimplificationSettings
  134970. * @param quality expected quality
  134971. * @param distance distance when this optimized version should be used
  134972. * @param optimizeMesh already optimized mesh
  134973. */
  134974. constructor(
  134975. /** expected quality */
  134976. quality: number,
  134977. /** distance when this optimized version should be used */
  134978. distance: number,
  134979. /** already optimized mesh */
  134980. optimizeMesh?: boolean | undefined);
  134981. }
  134982. /**
  134983. * Interface used to define a simplification task
  134984. */
  134985. export interface ISimplificationTask {
  134986. /**
  134987. * Array of settings
  134988. */
  134989. settings: Array<ISimplificationSettings>;
  134990. /**
  134991. * Simplification type
  134992. */
  134993. simplificationType: SimplificationType;
  134994. /**
  134995. * Mesh to simplify
  134996. */
  134997. mesh: Mesh;
  134998. /**
  134999. * Callback called on success
  135000. */
  135001. successCallback?: () => void;
  135002. /**
  135003. * Defines if parallel processing can be used
  135004. */
  135005. parallelProcessing: boolean;
  135006. }
  135007. /**
  135008. * Queue used to order the simplification tasks
  135009. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135010. */
  135011. export class SimplificationQueue {
  135012. private _simplificationArray;
  135013. /**
  135014. * Gets a boolean indicating that the process is still running
  135015. */
  135016. running: boolean;
  135017. /**
  135018. * Creates a new queue
  135019. */
  135020. constructor();
  135021. /**
  135022. * Adds a new simplification task
  135023. * @param task defines a task to add
  135024. */
  135025. addTask(task: ISimplificationTask): void;
  135026. /**
  135027. * Execute next task
  135028. */
  135029. executeNext(): void;
  135030. /**
  135031. * Execute a simplification task
  135032. * @param task defines the task to run
  135033. */
  135034. runSimplification(task: ISimplificationTask): void;
  135035. private getSimplifier;
  135036. }
  135037. /**
  135038. * The implemented types of simplification
  135039. * At the moment only Quadratic Error Decimation is implemented
  135040. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135041. */
  135042. export enum SimplificationType {
  135043. /** Quadratic error decimation */
  135044. QUADRATIC = 0
  135045. }
  135046. }
  135047. declare module BABYLON {
  135048. interface Scene {
  135049. /** @hidden (Backing field) */
  135050. _simplificationQueue: SimplificationQueue;
  135051. /**
  135052. * Gets or sets the simplification queue attached to the scene
  135053. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135054. */
  135055. simplificationQueue: SimplificationQueue;
  135056. }
  135057. interface Mesh {
  135058. /**
  135059. * Simplify the mesh according to the given array of settings.
  135060. * Function will return immediately and will simplify async
  135061. * @param settings a collection of simplification settings
  135062. * @param parallelProcessing should all levels calculate parallel or one after the other
  135063. * @param simplificationType the type of simplification to run
  135064. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135065. * @returns the current mesh
  135066. */
  135067. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135068. }
  135069. /**
  135070. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135071. * created in a scene
  135072. */
  135073. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135074. /**
  135075. * The component name helpfull to identify the component in the list of scene components.
  135076. */
  135077. readonly name: string;
  135078. /**
  135079. * The scene the component belongs to.
  135080. */
  135081. scene: Scene;
  135082. /**
  135083. * Creates a new instance of the component for the given scene
  135084. * @param scene Defines the scene to register the component in
  135085. */
  135086. constructor(scene: Scene);
  135087. /**
  135088. * Registers the component in a given scene
  135089. */
  135090. register(): void;
  135091. /**
  135092. * Rebuilds the elements related to this component in case of
  135093. * context lost for instance.
  135094. */
  135095. rebuild(): void;
  135096. /**
  135097. * Disposes the component and the associated ressources
  135098. */
  135099. dispose(): void;
  135100. private _beforeCameraUpdate;
  135101. }
  135102. }
  135103. declare module BABYLON {
  135104. /**
  135105. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135106. */
  135107. export interface INavigationEnginePlugin {
  135108. /**
  135109. * plugin name
  135110. */
  135111. name: string;
  135112. /**
  135113. * Creates a navigation mesh
  135114. * @param meshes array of all the geometry used to compute the navigatio mesh
  135115. * @param parameters bunch of parameters used to filter geometry
  135116. */
  135117. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135118. /**
  135119. * Create a navigation mesh debug mesh
  135120. * @param scene is where the mesh will be added
  135121. * @returns debug display mesh
  135122. */
  135123. createDebugNavMesh(scene: Scene): Mesh;
  135124. /**
  135125. * Get a navigation mesh constrained position, closest to the parameter position
  135126. * @param position world position
  135127. * @returns the closest point to position constrained by the navigation mesh
  135128. */
  135129. getClosestPoint(position: Vector3): Vector3;
  135130. /**
  135131. * Get a navigation mesh constrained position, within a particular radius
  135132. * @param position world position
  135133. * @param maxRadius the maximum distance to the constrained world position
  135134. * @returns the closest point to position constrained by the navigation mesh
  135135. */
  135136. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135137. /**
  135138. * Compute the final position from a segment made of destination-position
  135139. * @param position world position
  135140. * @param destination world position
  135141. * @returns the resulting point along the navmesh
  135142. */
  135143. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135144. /**
  135145. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135146. * @param start world position
  135147. * @param end world position
  135148. * @returns array containing world position composing the path
  135149. */
  135150. computePath(start: Vector3, end: Vector3): Vector3[];
  135151. /**
  135152. * If this plugin is supported
  135153. * @returns true if plugin is supported
  135154. */
  135155. isSupported(): boolean;
  135156. /**
  135157. * Create a new Crowd so you can add agents
  135158. * @param maxAgents the maximum agent count in the crowd
  135159. * @param maxAgentRadius the maximum radius an agent can have
  135160. * @param scene to attach the crowd to
  135161. * @returns the crowd you can add agents to
  135162. */
  135163. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135164. /**
  135165. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135166. * The queries will try to find a solution within those bounds
  135167. * default is (1,1,1)
  135168. * @param extent x,y,z value that define the extent around the queries point of reference
  135169. */
  135170. setDefaultQueryExtent(extent: Vector3): void;
  135171. /**
  135172. * Get the Bounding box extent specified by setDefaultQueryExtent
  135173. * @returns the box extent values
  135174. */
  135175. getDefaultQueryExtent(): Vector3;
  135176. /**
  135177. * Release all resources
  135178. */
  135179. dispose(): void;
  135180. }
  135181. /**
  135182. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135183. */
  135184. export interface ICrowd {
  135185. /**
  135186. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135187. * You can attach anything to that node. The node position is updated in the scene update tick.
  135188. * @param pos world position that will be constrained by the navigation mesh
  135189. * @param parameters agent parameters
  135190. * @param transform hooked to the agent that will be update by the scene
  135191. * @returns agent index
  135192. */
  135193. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135194. /**
  135195. * Returns the agent position in world space
  135196. * @param index agent index returned by addAgent
  135197. * @returns world space position
  135198. */
  135199. getAgentPosition(index: number): Vector3;
  135200. /**
  135201. * Gets the agent velocity in world space
  135202. * @param index agent index returned by addAgent
  135203. * @returns world space velocity
  135204. */
  135205. getAgentVelocity(index: number): Vector3;
  135206. /**
  135207. * remove a particular agent previously created
  135208. * @param index agent index returned by addAgent
  135209. */
  135210. removeAgent(index: number): void;
  135211. /**
  135212. * get the list of all agents attached to this crowd
  135213. * @returns list of agent indices
  135214. */
  135215. getAgents(): number[];
  135216. /**
  135217. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135218. * @param deltaTime in seconds
  135219. */
  135220. update(deltaTime: number): void;
  135221. /**
  135222. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135223. * @param index agent index returned by addAgent
  135224. * @param destination targeted world position
  135225. */
  135226. agentGoto(index: number, destination: Vector3): void;
  135227. /**
  135228. * Teleport the agent to a new position
  135229. * @param index agent index returned by addAgent
  135230. * @param destination targeted world position
  135231. */
  135232. agentTeleport(index: number, destination: Vector3): void;
  135233. /**
  135234. * Update agent parameters
  135235. * @param index agent index returned by addAgent
  135236. * @param parameters agent parameters
  135237. */
  135238. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135239. /**
  135240. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135241. * The queries will try to find a solution within those bounds
  135242. * default is (1,1,1)
  135243. * @param extent x,y,z value that define the extent around the queries point of reference
  135244. */
  135245. setDefaultQueryExtent(extent: Vector3): void;
  135246. /**
  135247. * Get the Bounding box extent specified by setDefaultQueryExtent
  135248. * @returns the box extent values
  135249. */
  135250. getDefaultQueryExtent(): Vector3;
  135251. /**
  135252. * Release all resources
  135253. */
  135254. dispose(): void;
  135255. }
  135256. /**
  135257. * Configures an agent
  135258. */
  135259. export interface IAgentParameters {
  135260. /**
  135261. * Agent radius. [Limit: >= 0]
  135262. */
  135263. radius: number;
  135264. /**
  135265. * Agent height. [Limit: > 0]
  135266. */
  135267. height: number;
  135268. /**
  135269. * Maximum allowed acceleration. [Limit: >= 0]
  135270. */
  135271. maxAcceleration: number;
  135272. /**
  135273. * Maximum allowed speed. [Limit: >= 0]
  135274. */
  135275. maxSpeed: number;
  135276. /**
  135277. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135278. */
  135279. collisionQueryRange: number;
  135280. /**
  135281. * The path visibility optimization range. [Limit: > 0]
  135282. */
  135283. pathOptimizationRange: number;
  135284. /**
  135285. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135286. */
  135287. separationWeight: number;
  135288. }
  135289. /**
  135290. * Configures the navigation mesh creation
  135291. */
  135292. export interface INavMeshParameters {
  135293. /**
  135294. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135295. */
  135296. cs: number;
  135297. /**
  135298. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135299. */
  135300. ch: number;
  135301. /**
  135302. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135303. */
  135304. walkableSlopeAngle: number;
  135305. /**
  135306. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135307. * be considered walkable. [Limit: >= 3] [Units: vx]
  135308. */
  135309. walkableHeight: number;
  135310. /**
  135311. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135312. */
  135313. walkableClimb: number;
  135314. /**
  135315. * The distance to erode/shrink the walkable area of the heightfield away from
  135316. * obstructions. [Limit: >=0] [Units: vx]
  135317. */
  135318. walkableRadius: number;
  135319. /**
  135320. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135321. */
  135322. maxEdgeLen: number;
  135323. /**
  135324. * The maximum distance a simplfied contour's border edges should deviate
  135325. * the original raw contour. [Limit: >=0] [Units: vx]
  135326. */
  135327. maxSimplificationError: number;
  135328. /**
  135329. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135330. */
  135331. minRegionArea: number;
  135332. /**
  135333. * Any regions with a span count smaller than this value will, if possible,
  135334. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135335. */
  135336. mergeRegionArea: number;
  135337. /**
  135338. * The maximum number of vertices allowed for polygons generated during the
  135339. * contour to polygon conversion process. [Limit: >= 3]
  135340. */
  135341. maxVertsPerPoly: number;
  135342. /**
  135343. * Sets the sampling distance to use when generating the detail mesh.
  135344. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135345. */
  135346. detailSampleDist: number;
  135347. /**
  135348. * The maximum distance the detail mesh surface should deviate from heightfield
  135349. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135350. */
  135351. detailSampleMaxError: number;
  135352. }
  135353. }
  135354. declare module BABYLON {
  135355. /**
  135356. * RecastJS navigation plugin
  135357. */
  135358. export class RecastJSPlugin implements INavigationEnginePlugin {
  135359. /**
  135360. * Reference to the Recast library
  135361. */
  135362. bjsRECAST: any;
  135363. /**
  135364. * plugin name
  135365. */
  135366. name: string;
  135367. /**
  135368. * the first navmesh created. We might extend this to support multiple navmeshes
  135369. */
  135370. navMesh: any;
  135371. /**
  135372. * Initializes the recastJS plugin
  135373. * @param recastInjection can be used to inject your own recast reference
  135374. */
  135375. constructor(recastInjection?: any);
  135376. /**
  135377. * Creates a navigation mesh
  135378. * @param meshes array of all the geometry used to compute the navigatio mesh
  135379. * @param parameters bunch of parameters used to filter geometry
  135380. */
  135381. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135382. /**
  135383. * Create a navigation mesh debug mesh
  135384. * @param scene is where the mesh will be added
  135385. * @returns debug display mesh
  135386. */
  135387. createDebugNavMesh(scene: Scene): Mesh;
  135388. /**
  135389. * Get a navigation mesh constrained position, closest to the parameter position
  135390. * @param position world position
  135391. * @returns the closest point to position constrained by the navigation mesh
  135392. */
  135393. getClosestPoint(position: Vector3): Vector3;
  135394. /**
  135395. * Get a navigation mesh constrained position, within a particular radius
  135396. * @param position world position
  135397. * @param maxRadius the maximum distance to the constrained world position
  135398. * @returns the closest point to position constrained by the navigation mesh
  135399. */
  135400. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135401. /**
  135402. * Compute the final position from a segment made of destination-position
  135403. * @param position world position
  135404. * @param destination world position
  135405. * @returns the resulting point along the navmesh
  135406. */
  135407. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135408. /**
  135409. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135410. * @param start world position
  135411. * @param end world position
  135412. * @returns array containing world position composing the path
  135413. */
  135414. computePath(start: Vector3, end: Vector3): Vector3[];
  135415. /**
  135416. * Create a new Crowd so you can add agents
  135417. * @param maxAgents the maximum agent count in the crowd
  135418. * @param maxAgentRadius the maximum radius an agent can have
  135419. * @param scene to attach the crowd to
  135420. * @returns the crowd you can add agents to
  135421. */
  135422. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135423. /**
  135424. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135425. * The queries will try to find a solution within those bounds
  135426. * default is (1,1,1)
  135427. * @param extent x,y,z value that define the extent around the queries point of reference
  135428. */
  135429. setDefaultQueryExtent(extent: Vector3): void;
  135430. /**
  135431. * Get the Bounding box extent specified by setDefaultQueryExtent
  135432. * @returns the box extent values
  135433. */
  135434. getDefaultQueryExtent(): Vector3;
  135435. /**
  135436. * Disposes
  135437. */
  135438. dispose(): void;
  135439. /**
  135440. * If this plugin is supported
  135441. * @returns true if plugin is supported
  135442. */
  135443. isSupported(): boolean;
  135444. }
  135445. /**
  135446. * Recast detour crowd implementation
  135447. */
  135448. export class RecastJSCrowd implements ICrowd {
  135449. /**
  135450. * Recast/detour plugin
  135451. */
  135452. bjsRECASTPlugin: RecastJSPlugin;
  135453. /**
  135454. * Link to the detour crowd
  135455. */
  135456. recastCrowd: any;
  135457. /**
  135458. * One transform per agent
  135459. */
  135460. transforms: TransformNode[];
  135461. /**
  135462. * All agents created
  135463. */
  135464. agents: number[];
  135465. /**
  135466. * Link to the scene is kept to unregister the crowd from the scene
  135467. */
  135468. private _scene;
  135469. /**
  135470. * Observer for crowd updates
  135471. */
  135472. private _onBeforeAnimationsObserver;
  135473. /**
  135474. * Constructor
  135475. * @param plugin recastJS plugin
  135476. * @param maxAgents the maximum agent count in the crowd
  135477. * @param maxAgentRadius the maximum radius an agent can have
  135478. * @param scene to attach the crowd to
  135479. * @returns the crowd you can add agents to
  135480. */
  135481. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135482. /**
  135483. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135484. * You can attach anything to that node. The node position is updated in the scene update tick.
  135485. * @param pos world position that will be constrained by the navigation mesh
  135486. * @param parameters agent parameters
  135487. * @param transform hooked to the agent that will be update by the scene
  135488. * @returns agent index
  135489. */
  135490. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135491. /**
  135492. * Returns the agent position in world space
  135493. * @param index agent index returned by addAgent
  135494. * @returns world space position
  135495. */
  135496. getAgentPosition(index: number): Vector3;
  135497. /**
  135498. * Returns the agent velocity in world space
  135499. * @param index agent index returned by addAgent
  135500. * @returns world space velocity
  135501. */
  135502. getAgentVelocity(index: number): Vector3;
  135503. /**
  135504. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135505. * @param index agent index returned by addAgent
  135506. * @param destination targeted world position
  135507. */
  135508. agentGoto(index: number, destination: Vector3): void;
  135509. /**
  135510. * Teleport the agent to a new position
  135511. * @param index agent index returned by addAgent
  135512. * @param destination targeted world position
  135513. */
  135514. agentTeleport(index: number, destination: Vector3): void;
  135515. /**
  135516. * Update agent parameters
  135517. * @param index agent index returned by addAgent
  135518. * @param parameters agent parameters
  135519. */
  135520. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135521. /**
  135522. * remove a particular agent previously created
  135523. * @param index agent index returned by addAgent
  135524. */
  135525. removeAgent(index: number): void;
  135526. /**
  135527. * get the list of all agents attached to this crowd
  135528. * @returns list of agent indices
  135529. */
  135530. getAgents(): number[];
  135531. /**
  135532. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135533. * @param deltaTime in seconds
  135534. */
  135535. update(deltaTime: number): void;
  135536. /**
  135537. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135538. * The queries will try to find a solution within those bounds
  135539. * default is (1,1,1)
  135540. * @param extent x,y,z value that define the extent around the queries point of reference
  135541. */
  135542. setDefaultQueryExtent(extent: Vector3): void;
  135543. /**
  135544. * Get the Bounding box extent specified by setDefaultQueryExtent
  135545. * @returns the box extent values
  135546. */
  135547. getDefaultQueryExtent(): Vector3;
  135548. /**
  135549. * Release all resources
  135550. */
  135551. dispose(): void;
  135552. }
  135553. }
  135554. declare module BABYLON {
  135555. /**
  135556. * Class used to enable access to IndexedDB
  135557. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135558. */
  135559. export class Database implements IOfflineProvider {
  135560. private _callbackManifestChecked;
  135561. private _currentSceneUrl;
  135562. private _db;
  135563. private _enableSceneOffline;
  135564. private _enableTexturesOffline;
  135565. private _manifestVersionFound;
  135566. private _mustUpdateRessources;
  135567. private _hasReachedQuota;
  135568. private _isSupported;
  135569. private _idbFactory;
  135570. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135571. private static IsUASupportingBlobStorage;
  135572. /**
  135573. * Gets a boolean indicating if Database storate is enabled (off by default)
  135574. */
  135575. static IDBStorageEnabled: boolean;
  135576. /**
  135577. * Gets a boolean indicating if scene must be saved in the database
  135578. */
  135579. get enableSceneOffline(): boolean;
  135580. /**
  135581. * Gets a boolean indicating if textures must be saved in the database
  135582. */
  135583. get enableTexturesOffline(): boolean;
  135584. /**
  135585. * Creates a new Database
  135586. * @param urlToScene defines the url to load the scene
  135587. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135588. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135589. */
  135590. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135591. private static _ParseURL;
  135592. private static _ReturnFullUrlLocation;
  135593. private _checkManifestFile;
  135594. /**
  135595. * Open the database and make it available
  135596. * @param successCallback defines the callback to call on success
  135597. * @param errorCallback defines the callback to call on error
  135598. */
  135599. open(successCallback: () => void, errorCallback: () => void): void;
  135600. /**
  135601. * Loads an image from the database
  135602. * @param url defines the url to load from
  135603. * @param image defines the target DOM image
  135604. */
  135605. loadImage(url: string, image: HTMLImageElement): void;
  135606. private _loadImageFromDBAsync;
  135607. private _saveImageIntoDBAsync;
  135608. private _checkVersionFromDB;
  135609. private _loadVersionFromDBAsync;
  135610. private _saveVersionIntoDBAsync;
  135611. /**
  135612. * Loads a file from database
  135613. * @param url defines the URL to load from
  135614. * @param sceneLoaded defines a callback to call on success
  135615. * @param progressCallBack defines a callback to call when progress changed
  135616. * @param errorCallback defines a callback to call on error
  135617. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135618. */
  135619. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135620. private _loadFileAsync;
  135621. private _saveFileAsync;
  135622. /**
  135623. * Validates if xhr data is correct
  135624. * @param xhr defines the request to validate
  135625. * @param dataType defines the expected data type
  135626. * @returns true if data is correct
  135627. */
  135628. private static _ValidateXHRData;
  135629. }
  135630. }
  135631. declare module BABYLON {
  135632. /** @hidden */
  135633. export var gpuUpdateParticlesPixelShader: {
  135634. name: string;
  135635. shader: string;
  135636. };
  135637. }
  135638. declare module BABYLON {
  135639. /** @hidden */
  135640. export var gpuUpdateParticlesVertexShader: {
  135641. name: string;
  135642. shader: string;
  135643. };
  135644. }
  135645. declare module BABYLON {
  135646. /** @hidden */
  135647. export var clipPlaneFragmentDeclaration2: {
  135648. name: string;
  135649. shader: string;
  135650. };
  135651. }
  135652. declare module BABYLON {
  135653. /** @hidden */
  135654. export var gpuRenderParticlesPixelShader: {
  135655. name: string;
  135656. shader: string;
  135657. };
  135658. }
  135659. declare module BABYLON {
  135660. /** @hidden */
  135661. export var clipPlaneVertexDeclaration2: {
  135662. name: string;
  135663. shader: string;
  135664. };
  135665. }
  135666. declare module BABYLON {
  135667. /** @hidden */
  135668. export var gpuRenderParticlesVertexShader: {
  135669. name: string;
  135670. shader: string;
  135671. };
  135672. }
  135673. declare module BABYLON {
  135674. /**
  135675. * This represents a GPU particle system in Babylon
  135676. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135677. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135678. */
  135679. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135680. /**
  135681. * The layer mask we are rendering the particles through.
  135682. */
  135683. layerMask: number;
  135684. private _capacity;
  135685. private _activeCount;
  135686. private _currentActiveCount;
  135687. private _accumulatedCount;
  135688. private _renderEffect;
  135689. private _updateEffect;
  135690. private _buffer0;
  135691. private _buffer1;
  135692. private _spriteBuffer;
  135693. private _updateVAO;
  135694. private _renderVAO;
  135695. private _targetIndex;
  135696. private _sourceBuffer;
  135697. private _targetBuffer;
  135698. private _engine;
  135699. private _currentRenderId;
  135700. private _started;
  135701. private _stopped;
  135702. private _timeDelta;
  135703. private _randomTexture;
  135704. private _randomTexture2;
  135705. private _attributesStrideSize;
  135706. private _updateEffectOptions;
  135707. private _randomTextureSize;
  135708. private _actualFrame;
  135709. private readonly _rawTextureWidth;
  135710. /**
  135711. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135712. */
  135713. static get IsSupported(): boolean;
  135714. /**
  135715. * An event triggered when the system is disposed.
  135716. */
  135717. onDisposeObservable: Observable<GPUParticleSystem>;
  135718. /**
  135719. * Gets the maximum number of particles active at the same time.
  135720. * @returns The max number of active particles.
  135721. */
  135722. getCapacity(): number;
  135723. /**
  135724. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135725. * to override the particles.
  135726. */
  135727. forceDepthWrite: boolean;
  135728. /**
  135729. * Gets or set the number of active particles
  135730. */
  135731. get activeParticleCount(): number;
  135732. set activeParticleCount(value: number);
  135733. private _preWarmDone;
  135734. /**
  135735. * Specifies if the particles are updated in emitter local space or world space.
  135736. * This is always false for GPU particles
  135737. */
  135738. get isLocal(): boolean;
  135739. set isLocal(value: boolean);
  135740. /**
  135741. * Is this system ready to be used/rendered
  135742. * @return true if the system is ready
  135743. */
  135744. isReady(): boolean;
  135745. /**
  135746. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135747. * @returns True if it has been started, otherwise false.
  135748. */
  135749. isStarted(): boolean;
  135750. /**
  135751. * Starts the particle system and begins to emit
  135752. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135753. */
  135754. start(delay?: number): void;
  135755. /**
  135756. * Stops the particle system.
  135757. */
  135758. stop(): void;
  135759. /**
  135760. * Remove all active particles
  135761. */
  135762. reset(): void;
  135763. /**
  135764. * Returns the string "GPUParticleSystem"
  135765. * @returns a string containing the class name
  135766. */
  135767. getClassName(): string;
  135768. private _colorGradientsTexture;
  135769. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135770. /**
  135771. * Adds a new color gradient
  135772. * @param gradient defines the gradient to use (between 0 and 1)
  135773. * @param color1 defines the color to affect to the specified gradient
  135774. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135775. * @returns the current particle system
  135776. */
  135777. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135778. /**
  135779. * Remove a specific color gradient
  135780. * @param gradient defines the gradient to remove
  135781. * @returns the current particle system
  135782. */
  135783. removeColorGradient(gradient: number): GPUParticleSystem;
  135784. private _angularSpeedGradientsTexture;
  135785. private _sizeGradientsTexture;
  135786. private _velocityGradientsTexture;
  135787. private _limitVelocityGradientsTexture;
  135788. private _dragGradientsTexture;
  135789. private _addFactorGradient;
  135790. /**
  135791. * Adds a new size gradient
  135792. * @param gradient defines the gradient to use (between 0 and 1)
  135793. * @param factor defines the size factor to affect to the specified gradient
  135794. * @returns the current particle system
  135795. */
  135796. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135797. /**
  135798. * Remove a specific size gradient
  135799. * @param gradient defines the gradient to remove
  135800. * @returns the current particle system
  135801. */
  135802. removeSizeGradient(gradient: number): GPUParticleSystem;
  135803. /**
  135804. * Adds a new angular speed gradient
  135805. * @param gradient defines the gradient to use (between 0 and 1)
  135806. * @param factor defines the angular speed to affect to the specified gradient
  135807. * @returns the current particle system
  135808. */
  135809. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135810. /**
  135811. * Remove a specific angular speed gradient
  135812. * @param gradient defines the gradient to remove
  135813. * @returns the current particle system
  135814. */
  135815. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135816. /**
  135817. * Adds a new velocity gradient
  135818. * @param gradient defines the gradient to use (between 0 and 1)
  135819. * @param factor defines the velocity to affect to the specified gradient
  135820. * @returns the current particle system
  135821. */
  135822. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135823. /**
  135824. * Remove a specific velocity gradient
  135825. * @param gradient defines the gradient to remove
  135826. * @returns the current particle system
  135827. */
  135828. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135829. /**
  135830. * Adds a new limit velocity gradient
  135831. * @param gradient defines the gradient to use (between 0 and 1)
  135832. * @param factor defines the limit velocity value to affect to the specified gradient
  135833. * @returns the current particle system
  135834. */
  135835. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135836. /**
  135837. * Remove a specific limit velocity gradient
  135838. * @param gradient defines the gradient to remove
  135839. * @returns the current particle system
  135840. */
  135841. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135842. /**
  135843. * Adds a new drag gradient
  135844. * @param gradient defines the gradient to use (between 0 and 1)
  135845. * @param factor defines the drag value to affect to the specified gradient
  135846. * @returns the current particle system
  135847. */
  135848. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135849. /**
  135850. * Remove a specific drag gradient
  135851. * @param gradient defines the gradient to remove
  135852. * @returns the current particle system
  135853. */
  135854. removeDragGradient(gradient: number): GPUParticleSystem;
  135855. /**
  135856. * Not supported by GPUParticleSystem
  135857. * @param gradient defines the gradient to use (between 0 and 1)
  135858. * @param factor defines the emit rate value to affect to the specified gradient
  135859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135860. * @returns the current particle system
  135861. */
  135862. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135863. /**
  135864. * Not supported by GPUParticleSystem
  135865. * @param gradient defines the gradient to remove
  135866. * @returns the current particle system
  135867. */
  135868. removeEmitRateGradient(gradient: number): IParticleSystem;
  135869. /**
  135870. * Not supported by GPUParticleSystem
  135871. * @param gradient defines the gradient to use (between 0 and 1)
  135872. * @param factor defines the start size value to affect to the specified gradient
  135873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135874. * @returns the current particle system
  135875. */
  135876. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135877. /**
  135878. * Not supported by GPUParticleSystem
  135879. * @param gradient defines the gradient to remove
  135880. * @returns the current particle system
  135881. */
  135882. removeStartSizeGradient(gradient: number): IParticleSystem;
  135883. /**
  135884. * Not supported by GPUParticleSystem
  135885. * @param gradient defines the gradient to use (between 0 and 1)
  135886. * @param min defines the color remap minimal range
  135887. * @param max defines the color remap maximal range
  135888. * @returns the current particle system
  135889. */
  135890. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135891. /**
  135892. * Not supported by GPUParticleSystem
  135893. * @param gradient defines the gradient to remove
  135894. * @returns the current particle system
  135895. */
  135896. removeColorRemapGradient(): IParticleSystem;
  135897. /**
  135898. * Not supported by GPUParticleSystem
  135899. * @param gradient defines the gradient to use (between 0 and 1)
  135900. * @param min defines the alpha remap minimal range
  135901. * @param max defines the alpha remap maximal range
  135902. * @returns the current particle system
  135903. */
  135904. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135905. /**
  135906. * Not supported by GPUParticleSystem
  135907. * @param gradient defines the gradient to remove
  135908. * @returns the current particle system
  135909. */
  135910. removeAlphaRemapGradient(): IParticleSystem;
  135911. /**
  135912. * Not supported by GPUParticleSystem
  135913. * @param gradient defines the gradient to use (between 0 and 1)
  135914. * @param color defines the color to affect to the specified gradient
  135915. * @returns the current particle system
  135916. */
  135917. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135918. /**
  135919. * Not supported by GPUParticleSystem
  135920. * @param gradient defines the gradient to remove
  135921. * @returns the current particle system
  135922. */
  135923. removeRampGradient(): IParticleSystem;
  135924. /**
  135925. * Not supported by GPUParticleSystem
  135926. * @returns the list of ramp gradients
  135927. */
  135928. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135929. /**
  135930. * Not supported by GPUParticleSystem
  135931. * Gets or sets a boolean indicating that ramp gradients must be used
  135932. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135933. */
  135934. get useRampGradients(): boolean;
  135935. set useRampGradients(value: boolean);
  135936. /**
  135937. * Not supported by GPUParticleSystem
  135938. * @param gradient defines the gradient to use (between 0 and 1)
  135939. * @param factor defines the life time factor to affect to the specified gradient
  135940. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135941. * @returns the current particle system
  135942. */
  135943. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135944. /**
  135945. * Not supported by GPUParticleSystem
  135946. * @param gradient defines the gradient to remove
  135947. * @returns the current particle system
  135948. */
  135949. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135950. /**
  135951. * Instantiates a GPU particle system.
  135952. * 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.
  135953. * @param name The name of the particle system
  135954. * @param options The options used to create the system
  135955. * @param scene The scene the particle system belongs to
  135956. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135957. */
  135958. constructor(name: string, options: Partial<{
  135959. capacity: number;
  135960. randomTextureSize: number;
  135961. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135962. protected _reset(): void;
  135963. private _createUpdateVAO;
  135964. private _createRenderVAO;
  135965. private _initialize;
  135966. /** @hidden */
  135967. _recreateUpdateEffect(): void;
  135968. /** @hidden */
  135969. _recreateRenderEffect(): void;
  135970. /**
  135971. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135972. * @param preWarm defines if we are in the pre-warmimg phase
  135973. */
  135974. animate(preWarm?: boolean): void;
  135975. private _createFactorGradientTexture;
  135976. private _createSizeGradientTexture;
  135977. private _createAngularSpeedGradientTexture;
  135978. private _createVelocityGradientTexture;
  135979. private _createLimitVelocityGradientTexture;
  135980. private _createDragGradientTexture;
  135981. private _createColorGradientTexture;
  135982. /**
  135983. * Renders the particle system in its current state
  135984. * @param preWarm defines if the system should only update the particles but not render them
  135985. * @returns the current number of particles
  135986. */
  135987. render(preWarm?: boolean): number;
  135988. /**
  135989. * Rebuilds the particle system
  135990. */
  135991. rebuild(): void;
  135992. private _releaseBuffers;
  135993. private _releaseVAOs;
  135994. /**
  135995. * Disposes the particle system and free the associated resources
  135996. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135997. */
  135998. dispose(disposeTexture?: boolean): void;
  135999. /**
  136000. * Clones the particle system.
  136001. * @param name The name of the cloned object
  136002. * @param newEmitter The new emitter to use
  136003. * @returns the cloned particle system
  136004. */
  136005. clone(name: string, newEmitter: any): GPUParticleSystem;
  136006. /**
  136007. * Serializes the particle system to a JSON object.
  136008. * @returns the JSON object
  136009. */
  136010. serialize(): any;
  136011. /**
  136012. * Parses a JSON object to create a GPU particle system.
  136013. * @param parsedParticleSystem The JSON object to parse
  136014. * @param scene The scene to create the particle system in
  136015. * @param rootUrl The root url to use to load external dependencies like texture
  136016. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136017. * @returns the parsed GPU particle system
  136018. */
  136019. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136020. }
  136021. }
  136022. declare module BABYLON {
  136023. /**
  136024. * Represents a set of particle systems working together to create a specific effect
  136025. */
  136026. export class ParticleSystemSet implements IDisposable {
  136027. /**
  136028. * Gets or sets base Assets URL
  136029. */
  136030. static BaseAssetsUrl: string;
  136031. private _emitterCreationOptions;
  136032. private _emitterNode;
  136033. /**
  136034. * Gets the particle system list
  136035. */
  136036. systems: IParticleSystem[];
  136037. /**
  136038. * Gets the emitter node used with this set
  136039. */
  136040. get emitterNode(): Nullable<TransformNode>;
  136041. /**
  136042. * Creates a new emitter mesh as a sphere
  136043. * @param options defines the options used to create the sphere
  136044. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136045. * @param scene defines the hosting scene
  136046. */
  136047. setEmitterAsSphere(options: {
  136048. diameter: number;
  136049. segments: number;
  136050. color: Color3;
  136051. }, renderingGroupId: number, scene: Scene): void;
  136052. /**
  136053. * Starts all particle systems of the set
  136054. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136055. */
  136056. start(emitter?: AbstractMesh): void;
  136057. /**
  136058. * Release all associated resources
  136059. */
  136060. dispose(): void;
  136061. /**
  136062. * Serialize the set into a JSON compatible object
  136063. * @returns a JSON compatible representation of the set
  136064. */
  136065. serialize(): any;
  136066. /**
  136067. * Parse a new ParticleSystemSet from a serialized source
  136068. * @param data defines a JSON compatible representation of the set
  136069. * @param scene defines the hosting scene
  136070. * @param gpu defines if we want GPU particles or CPU particles
  136071. * @returns a new ParticleSystemSet
  136072. */
  136073. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136074. }
  136075. }
  136076. declare module BABYLON {
  136077. /**
  136078. * This class is made for on one-liner static method to help creating particle system set.
  136079. */
  136080. export class ParticleHelper {
  136081. /**
  136082. * Gets or sets base Assets URL
  136083. */
  136084. static BaseAssetsUrl: string;
  136085. /**
  136086. * Create a default particle system that you can tweak
  136087. * @param emitter defines the emitter to use
  136088. * @param capacity defines the system capacity (default is 500 particles)
  136089. * @param scene defines the hosting scene
  136090. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136091. * @returns the new Particle system
  136092. */
  136093. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136094. /**
  136095. * This is the main static method (one-liner) of this helper to create different particle systems
  136096. * @param type This string represents the type to the particle system to create
  136097. * @param scene The scene where the particle system should live
  136098. * @param gpu If the system will use gpu
  136099. * @returns the ParticleSystemSet created
  136100. */
  136101. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136102. /**
  136103. * Static function used to export a particle system to a ParticleSystemSet variable.
  136104. * Please note that the emitter shape is not exported
  136105. * @param systems defines the particle systems to export
  136106. * @returns the created particle system set
  136107. */
  136108. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136109. }
  136110. }
  136111. declare module BABYLON {
  136112. interface Engine {
  136113. /**
  136114. * Create an effect to use with particle systems.
  136115. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136116. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136117. * @param uniformsNames defines a list of attribute names
  136118. * @param samplers defines an array of string used to represent textures
  136119. * @param defines defines the string containing the defines to use to compile the shaders
  136120. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136121. * @param onCompiled defines a function to call when the effect creation is successful
  136122. * @param onError defines a function to call when the effect creation has failed
  136123. * @returns the new Effect
  136124. */
  136125. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136126. }
  136127. interface Mesh {
  136128. /**
  136129. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136130. * @returns an array of IParticleSystem
  136131. */
  136132. getEmittedParticleSystems(): IParticleSystem[];
  136133. /**
  136134. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136135. * @returns an array of IParticleSystem
  136136. */
  136137. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136138. }
  136139. /**
  136140. * @hidden
  136141. */
  136142. export var _IDoNeedToBeInTheBuild: number;
  136143. }
  136144. declare module BABYLON {
  136145. /** Defines the 4 color options */
  136146. export enum PointColor {
  136147. /** color value */
  136148. Color = 2,
  136149. /** uv value */
  136150. UV = 1,
  136151. /** random value */
  136152. Random = 0,
  136153. /** stated value */
  136154. Stated = 3
  136155. }
  136156. /**
  136157. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136158. * 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.
  136159. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136160. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136161. *
  136162. * Full documentation here : TO BE ENTERED
  136163. */
  136164. export class PointsCloudSystem implements IDisposable {
  136165. /**
  136166. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136167. * Example : var p = SPS.particles[i];
  136168. */
  136169. particles: CloudPoint[];
  136170. /**
  136171. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136172. */
  136173. nbParticles: number;
  136174. /**
  136175. * This a counter for your own usage. It's not set by any SPS functions.
  136176. */
  136177. counter: number;
  136178. /**
  136179. * The PCS name. This name is also given to the underlying mesh.
  136180. */
  136181. name: string;
  136182. /**
  136183. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136184. */
  136185. mesh: Mesh;
  136186. /**
  136187. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136188. * Please read :
  136189. */
  136190. vars: any;
  136191. /**
  136192. * @hidden
  136193. */
  136194. _size: number;
  136195. private _scene;
  136196. private _promises;
  136197. private _positions;
  136198. private _indices;
  136199. private _normals;
  136200. private _colors;
  136201. private _uvs;
  136202. private _indices32;
  136203. private _positions32;
  136204. private _colors32;
  136205. private _uvs32;
  136206. private _updatable;
  136207. private _isVisibilityBoxLocked;
  136208. private _alwaysVisible;
  136209. private _groups;
  136210. private _groupCounter;
  136211. private _computeParticleColor;
  136212. private _computeParticleTexture;
  136213. private _computeParticleRotation;
  136214. private _computeBoundingBox;
  136215. private _isReady;
  136216. /**
  136217. * Creates a PCS (Points Cloud System) object
  136218. * @param name (String) is the PCS name, this will be the underlying mesh name
  136219. * @param pointSize (number) is the size for each point
  136220. * @param scene (Scene) is the scene in which the PCS is added
  136221. * @param options defines the options of the PCS e.g.
  136222. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136223. */
  136224. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136225. updatable?: boolean;
  136226. });
  136227. /**
  136228. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136229. * If no points were added to the PCS, the returned mesh is just a single point.
  136230. * @returns a promise for the created mesh
  136231. */
  136232. buildMeshAsync(): Promise<Mesh>;
  136233. /**
  136234. * @hidden
  136235. */
  136236. private _buildMesh;
  136237. private _addParticle;
  136238. private _randomUnitVector;
  136239. private _getColorIndicesForCoord;
  136240. private _setPointsColorOrUV;
  136241. private _colorFromTexture;
  136242. private _calculateDensity;
  136243. /**
  136244. * Adds points to the PCS in random positions within a unit sphere
  136245. * @param nb (positive integer) the number of particles to be created from this model
  136246. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136247. * @returns the number of groups in the system
  136248. */
  136249. addPoints(nb: number, pointFunction?: any): number;
  136250. /**
  136251. * Adds points to the PCS from the surface of the model shape
  136252. * @param mesh is any Mesh object that will be used as a surface model for the points
  136253. * @param nb (positive integer) the number of particles to be created from this model
  136254. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136255. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136256. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136257. * @returns the number of groups in the system
  136258. */
  136259. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136260. /**
  136261. * Adds points to the PCS inside the model shape
  136262. * @param mesh is any Mesh object that will be used as a surface model for the points
  136263. * @param nb (positive integer) the number of particles to be created from this model
  136264. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136265. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136266. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136267. * @returns the number of groups in the system
  136268. */
  136269. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136270. /**
  136271. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136272. * This method calls `updateParticle()` for each particle of the SPS.
  136273. * For an animated SPS, it is usually called within the render loop.
  136274. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136275. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136276. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136277. * @returns the PCS.
  136278. */
  136279. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136280. /**
  136281. * Disposes the PCS.
  136282. */
  136283. dispose(): void;
  136284. /**
  136285. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136286. * doc :
  136287. * @returns the PCS.
  136288. */
  136289. refreshVisibleSize(): PointsCloudSystem;
  136290. /**
  136291. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136292. * @param size the size (float) of the visibility box
  136293. * note : this doesn't lock the PCS mesh bounding box.
  136294. * doc :
  136295. */
  136296. setVisibilityBox(size: number): void;
  136297. /**
  136298. * Gets whether the PCS is always visible or not
  136299. * doc :
  136300. */
  136301. get isAlwaysVisible(): boolean;
  136302. /**
  136303. * Sets the PCS as always visible or not
  136304. * doc :
  136305. */
  136306. set isAlwaysVisible(val: boolean);
  136307. /**
  136308. * Tells to `setParticles()` to compute the particle rotations or not
  136309. * Default value : false. The PCS is faster when it's set to false
  136310. * Note : particle rotations are only applied to parent particles
  136311. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136312. */
  136313. set computeParticleRotation(val: boolean);
  136314. /**
  136315. * Tells to `setParticles()` to compute the particle colors or not.
  136316. * Default value : true. The PCS is faster when it's set to false.
  136317. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136318. */
  136319. set computeParticleColor(val: boolean);
  136320. set computeParticleTexture(val: boolean);
  136321. /**
  136322. * Gets if `setParticles()` computes the particle colors or not.
  136323. * Default value : false. The PCS is faster when it's set to false.
  136324. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136325. */
  136326. get computeParticleColor(): boolean;
  136327. /**
  136328. * Gets if `setParticles()` computes the particle textures or not.
  136329. * Default value : false. The PCS is faster when it's set to false.
  136330. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136331. */
  136332. get computeParticleTexture(): boolean;
  136333. /**
  136334. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136335. */
  136336. set computeBoundingBox(val: boolean);
  136337. /**
  136338. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136339. */
  136340. get computeBoundingBox(): boolean;
  136341. /**
  136342. * This function does nothing. It may be overwritten to set all the particle first values.
  136343. * The PCS doesn't call this function, you may have to call it by your own.
  136344. * doc :
  136345. */
  136346. initParticles(): void;
  136347. /**
  136348. * This function does nothing. It may be overwritten to recycle a particle
  136349. * The PCS doesn't call this function, you can to call it
  136350. * doc :
  136351. * @param particle The particle to recycle
  136352. * @returns the recycled particle
  136353. */
  136354. recycleParticle(particle: CloudPoint): CloudPoint;
  136355. /**
  136356. * Updates a particle : this function should be overwritten by the user.
  136357. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136358. * doc :
  136359. * @example : just set a particle position or velocity and recycle conditions
  136360. * @param particle The particle to update
  136361. * @returns the updated particle
  136362. */
  136363. updateParticle(particle: CloudPoint): CloudPoint;
  136364. /**
  136365. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136366. * This does nothing and may be overwritten by the user.
  136367. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136368. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136369. * @param update the boolean update value actually passed to setParticles()
  136370. */
  136371. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136372. /**
  136373. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136374. * This will be passed three parameters.
  136375. * This does nothing and may be overwritten by the user.
  136376. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136377. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136378. * @param update the boolean update value actually passed to setParticles()
  136379. */
  136380. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136381. }
  136382. }
  136383. declare module BABYLON {
  136384. /**
  136385. * Represents one particle of a points cloud system.
  136386. */
  136387. export class CloudPoint {
  136388. /**
  136389. * particle global index
  136390. */
  136391. idx: number;
  136392. /**
  136393. * The color of the particle
  136394. */
  136395. color: Nullable<Color4>;
  136396. /**
  136397. * The world space position of the particle.
  136398. */
  136399. position: Vector3;
  136400. /**
  136401. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136402. */
  136403. rotation: Vector3;
  136404. /**
  136405. * The world space rotation quaternion of the particle.
  136406. */
  136407. rotationQuaternion: Nullable<Quaternion>;
  136408. /**
  136409. * The uv of the particle.
  136410. */
  136411. uv: Nullable<Vector2>;
  136412. /**
  136413. * The current speed of the particle.
  136414. */
  136415. velocity: Vector3;
  136416. /**
  136417. * The pivot point in the particle local space.
  136418. */
  136419. pivot: Vector3;
  136420. /**
  136421. * Must the particle be translated from its pivot point in its local space ?
  136422. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136423. * Default : false
  136424. */
  136425. translateFromPivot: boolean;
  136426. /**
  136427. * Index of this particle in the global "positions" array (Internal use)
  136428. * @hidden
  136429. */
  136430. _pos: number;
  136431. /**
  136432. * @hidden Index of this particle in the global "indices" array (Internal use)
  136433. */
  136434. _ind: number;
  136435. /**
  136436. * Group this particle belongs to
  136437. */
  136438. _group: PointsGroup;
  136439. /**
  136440. * Group id of this particle
  136441. */
  136442. groupId: number;
  136443. /**
  136444. * Index of the particle in its group id (Internal use)
  136445. */
  136446. idxInGroup: number;
  136447. /**
  136448. * @hidden Particle BoundingInfo object (Internal use)
  136449. */
  136450. _boundingInfo: BoundingInfo;
  136451. /**
  136452. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136453. */
  136454. _pcs: PointsCloudSystem;
  136455. /**
  136456. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136457. */
  136458. _stillInvisible: boolean;
  136459. /**
  136460. * @hidden Last computed particle rotation matrix
  136461. */
  136462. _rotationMatrix: number[];
  136463. /**
  136464. * Parent particle Id, if any.
  136465. * Default null.
  136466. */
  136467. parentId: Nullable<number>;
  136468. /**
  136469. * @hidden Internal global position in the PCS.
  136470. */
  136471. _globalPosition: Vector3;
  136472. /**
  136473. * Creates a Point Cloud object.
  136474. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136475. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136476. * @param group (PointsGroup) is the group the particle belongs to
  136477. * @param groupId (integer) is the group identifier in the PCS.
  136478. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136479. * @param pcs defines the PCS it is associated to
  136480. */
  136481. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136482. /**
  136483. * get point size
  136484. */
  136485. get size(): Vector3;
  136486. /**
  136487. * Set point size
  136488. */
  136489. set size(scale: Vector3);
  136490. /**
  136491. * Legacy support, changed quaternion to rotationQuaternion
  136492. */
  136493. get quaternion(): Nullable<Quaternion>;
  136494. /**
  136495. * Legacy support, changed quaternion to rotationQuaternion
  136496. */
  136497. set quaternion(q: Nullable<Quaternion>);
  136498. /**
  136499. * Returns a boolean. True if the particle intersects a mesh, else false
  136500. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136501. * @param target is the object (point or mesh) what the intersection is computed against
  136502. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136503. * @returns true if it intersects
  136504. */
  136505. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136506. /**
  136507. * get the rotation matrix of the particle
  136508. * @hidden
  136509. */
  136510. getRotationMatrix(m: Matrix): void;
  136511. }
  136512. /**
  136513. * Represents a group of points in a points cloud system
  136514. * * PCS internal tool, don't use it manually.
  136515. */
  136516. export class PointsGroup {
  136517. /**
  136518. * The group id
  136519. * @hidden
  136520. */
  136521. groupID: number;
  136522. /**
  136523. * image data for group (internal use)
  136524. * @hidden
  136525. */
  136526. _groupImageData: Nullable<ArrayBufferView>;
  136527. /**
  136528. * Image Width (internal use)
  136529. * @hidden
  136530. */
  136531. _groupImgWidth: number;
  136532. /**
  136533. * Image Height (internal use)
  136534. * @hidden
  136535. */
  136536. _groupImgHeight: number;
  136537. /**
  136538. * Custom position function (internal use)
  136539. * @hidden
  136540. */
  136541. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136542. /**
  136543. * density per facet for surface points
  136544. * @hidden
  136545. */
  136546. _groupDensity: number[];
  136547. /**
  136548. * Only when points are colored by texture carries pointer to texture list array
  136549. * @hidden
  136550. */
  136551. _textureNb: number;
  136552. /**
  136553. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136554. * PCS internal tool, don't use it manually.
  136555. * @hidden
  136556. */
  136557. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136558. }
  136559. }
  136560. declare module BABYLON {
  136561. interface Scene {
  136562. /** @hidden (Backing field) */
  136563. _physicsEngine: Nullable<IPhysicsEngine>;
  136564. /** @hidden */
  136565. _physicsTimeAccumulator: number;
  136566. /**
  136567. * Gets the current physics engine
  136568. * @returns a IPhysicsEngine or null if none attached
  136569. */
  136570. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136571. /**
  136572. * Enables physics to the current scene
  136573. * @param gravity defines the scene's gravity for the physics engine
  136574. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136575. * @return a boolean indicating if the physics engine was initialized
  136576. */
  136577. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136578. /**
  136579. * Disables and disposes the physics engine associated with the scene
  136580. */
  136581. disablePhysicsEngine(): void;
  136582. /**
  136583. * Gets a boolean indicating if there is an active physics engine
  136584. * @returns a boolean indicating if there is an active physics engine
  136585. */
  136586. isPhysicsEnabled(): boolean;
  136587. /**
  136588. * Deletes a physics compound impostor
  136589. * @param compound defines the compound to delete
  136590. */
  136591. deleteCompoundImpostor(compound: any): void;
  136592. /**
  136593. * An event triggered when physic simulation is about to be run
  136594. */
  136595. onBeforePhysicsObservable: Observable<Scene>;
  136596. /**
  136597. * An event triggered when physic simulation has been done
  136598. */
  136599. onAfterPhysicsObservable: Observable<Scene>;
  136600. }
  136601. interface AbstractMesh {
  136602. /** @hidden */
  136603. _physicsImpostor: Nullable<PhysicsImpostor>;
  136604. /**
  136605. * Gets or sets impostor used for physic simulation
  136606. * @see http://doc.babylonjs.com/features/physics_engine
  136607. */
  136608. physicsImpostor: Nullable<PhysicsImpostor>;
  136609. /**
  136610. * Gets the current physics impostor
  136611. * @see http://doc.babylonjs.com/features/physics_engine
  136612. * @returns a physics impostor or null
  136613. */
  136614. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136615. /** Apply a physic impulse to the mesh
  136616. * @param force defines the force to apply
  136617. * @param contactPoint defines where to apply the force
  136618. * @returns the current mesh
  136619. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136620. */
  136621. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136622. /**
  136623. * Creates a physic joint between two meshes
  136624. * @param otherMesh defines the other mesh to use
  136625. * @param pivot1 defines the pivot to use on this mesh
  136626. * @param pivot2 defines the pivot to use on the other mesh
  136627. * @param options defines additional options (can be plugin dependent)
  136628. * @returns the current mesh
  136629. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136630. */
  136631. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136632. /** @hidden */
  136633. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136634. }
  136635. /**
  136636. * Defines the physics engine scene component responsible to manage a physics engine
  136637. */
  136638. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136639. /**
  136640. * The component name helpful to identify the component in the list of scene components.
  136641. */
  136642. readonly name: string;
  136643. /**
  136644. * The scene the component belongs to.
  136645. */
  136646. scene: Scene;
  136647. /**
  136648. * Creates a new instance of the component for the given scene
  136649. * @param scene Defines the scene to register the component in
  136650. */
  136651. constructor(scene: Scene);
  136652. /**
  136653. * Registers the component in a given scene
  136654. */
  136655. register(): void;
  136656. /**
  136657. * Rebuilds the elements related to this component in case of
  136658. * context lost for instance.
  136659. */
  136660. rebuild(): void;
  136661. /**
  136662. * Disposes the component and the associated ressources
  136663. */
  136664. dispose(): void;
  136665. }
  136666. }
  136667. declare module BABYLON {
  136668. /**
  136669. * A helper for physics simulations
  136670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136671. */
  136672. export class PhysicsHelper {
  136673. private _scene;
  136674. private _physicsEngine;
  136675. /**
  136676. * Initializes the Physics helper
  136677. * @param scene Babylon.js scene
  136678. */
  136679. constructor(scene: Scene);
  136680. /**
  136681. * Applies a radial explosion impulse
  136682. * @param origin the origin of the explosion
  136683. * @param radiusOrEventOptions the radius or the options of radial explosion
  136684. * @param strength the explosion strength
  136685. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136686. * @returns A physics radial explosion event, or null
  136687. */
  136688. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136689. /**
  136690. * Applies a radial explosion force
  136691. * @param origin the origin of the explosion
  136692. * @param radiusOrEventOptions the radius or the options of radial explosion
  136693. * @param strength the explosion strength
  136694. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136695. * @returns A physics radial explosion event, or null
  136696. */
  136697. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136698. /**
  136699. * Creates a gravitational field
  136700. * @param origin the origin of the explosion
  136701. * @param radiusOrEventOptions the radius or the options of radial explosion
  136702. * @param strength the explosion strength
  136703. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136704. * @returns A physics gravitational field event, or null
  136705. */
  136706. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136707. /**
  136708. * Creates a physics updraft event
  136709. * @param origin the origin of the updraft
  136710. * @param radiusOrEventOptions the radius or the options of the updraft
  136711. * @param strength the strength of the updraft
  136712. * @param height the height of the updraft
  136713. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136714. * @returns A physics updraft event, or null
  136715. */
  136716. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136717. /**
  136718. * Creates a physics vortex event
  136719. * @param origin the of the vortex
  136720. * @param radiusOrEventOptions the radius or the options of the vortex
  136721. * @param strength the strength of the vortex
  136722. * @param height the height of the vortex
  136723. * @returns a Physics vortex event, or null
  136724. * A physics vortex event or null
  136725. */
  136726. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136727. }
  136728. /**
  136729. * Represents a physics radial explosion event
  136730. */
  136731. class PhysicsRadialExplosionEvent {
  136732. private _scene;
  136733. private _options;
  136734. private _sphere;
  136735. private _dataFetched;
  136736. /**
  136737. * Initializes a radial explosioin event
  136738. * @param _scene BabylonJS scene
  136739. * @param _options The options for the vortex event
  136740. */
  136741. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136742. /**
  136743. * Returns the data related to the radial explosion event (sphere).
  136744. * @returns The radial explosion event data
  136745. */
  136746. getData(): PhysicsRadialExplosionEventData;
  136747. /**
  136748. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136749. * @param impostor A physics imposter
  136750. * @param origin the origin of the explosion
  136751. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136752. */
  136753. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136754. /**
  136755. * Triggers affecterd impostors callbacks
  136756. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136757. */
  136758. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136759. /**
  136760. * Disposes the sphere.
  136761. * @param force Specifies if the sphere should be disposed by force
  136762. */
  136763. dispose(force?: boolean): void;
  136764. /*** Helpers ***/
  136765. private _prepareSphere;
  136766. private _intersectsWithSphere;
  136767. }
  136768. /**
  136769. * Represents a gravitational field event
  136770. */
  136771. class PhysicsGravitationalFieldEvent {
  136772. private _physicsHelper;
  136773. private _scene;
  136774. private _origin;
  136775. private _options;
  136776. private _tickCallback;
  136777. private _sphere;
  136778. private _dataFetched;
  136779. /**
  136780. * Initializes the physics gravitational field event
  136781. * @param _physicsHelper A physics helper
  136782. * @param _scene BabylonJS scene
  136783. * @param _origin The origin position of the gravitational field event
  136784. * @param _options The options for the vortex event
  136785. */
  136786. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136787. /**
  136788. * Returns the data related to the gravitational field event (sphere).
  136789. * @returns A gravitational field event
  136790. */
  136791. getData(): PhysicsGravitationalFieldEventData;
  136792. /**
  136793. * Enables the gravitational field.
  136794. */
  136795. enable(): void;
  136796. /**
  136797. * Disables the gravitational field.
  136798. */
  136799. disable(): void;
  136800. /**
  136801. * Disposes the sphere.
  136802. * @param force The force to dispose from the gravitational field event
  136803. */
  136804. dispose(force?: boolean): void;
  136805. private _tick;
  136806. }
  136807. /**
  136808. * Represents a physics updraft event
  136809. */
  136810. class PhysicsUpdraftEvent {
  136811. private _scene;
  136812. private _origin;
  136813. private _options;
  136814. private _physicsEngine;
  136815. private _originTop;
  136816. private _originDirection;
  136817. private _tickCallback;
  136818. private _cylinder;
  136819. private _cylinderPosition;
  136820. private _dataFetched;
  136821. /**
  136822. * Initializes the physics updraft event
  136823. * @param _scene BabylonJS scene
  136824. * @param _origin The origin position of the updraft
  136825. * @param _options The options for the updraft event
  136826. */
  136827. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136828. /**
  136829. * Returns the data related to the updraft event (cylinder).
  136830. * @returns A physics updraft event
  136831. */
  136832. getData(): PhysicsUpdraftEventData;
  136833. /**
  136834. * Enables the updraft.
  136835. */
  136836. enable(): void;
  136837. /**
  136838. * Disables the updraft.
  136839. */
  136840. disable(): void;
  136841. /**
  136842. * Disposes the cylinder.
  136843. * @param force Specifies if the updraft should be disposed by force
  136844. */
  136845. dispose(force?: boolean): void;
  136846. private getImpostorHitData;
  136847. private _tick;
  136848. /*** Helpers ***/
  136849. private _prepareCylinder;
  136850. private _intersectsWithCylinder;
  136851. }
  136852. /**
  136853. * Represents a physics vortex event
  136854. */
  136855. class PhysicsVortexEvent {
  136856. private _scene;
  136857. private _origin;
  136858. private _options;
  136859. private _physicsEngine;
  136860. private _originTop;
  136861. private _tickCallback;
  136862. private _cylinder;
  136863. private _cylinderPosition;
  136864. private _dataFetched;
  136865. /**
  136866. * Initializes the physics vortex event
  136867. * @param _scene The BabylonJS scene
  136868. * @param _origin The origin position of the vortex
  136869. * @param _options The options for the vortex event
  136870. */
  136871. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136872. /**
  136873. * Returns the data related to the vortex event (cylinder).
  136874. * @returns The physics vortex event data
  136875. */
  136876. getData(): PhysicsVortexEventData;
  136877. /**
  136878. * Enables the vortex.
  136879. */
  136880. enable(): void;
  136881. /**
  136882. * Disables the cortex.
  136883. */
  136884. disable(): void;
  136885. /**
  136886. * Disposes the sphere.
  136887. * @param force
  136888. */
  136889. dispose(force?: boolean): void;
  136890. private getImpostorHitData;
  136891. private _tick;
  136892. /*** Helpers ***/
  136893. private _prepareCylinder;
  136894. private _intersectsWithCylinder;
  136895. }
  136896. /**
  136897. * Options fot the radial explosion event
  136898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136899. */
  136900. export class PhysicsRadialExplosionEventOptions {
  136901. /**
  136902. * The radius of the sphere for the radial explosion.
  136903. */
  136904. radius: number;
  136905. /**
  136906. * The strenth of the explosion.
  136907. */
  136908. strength: number;
  136909. /**
  136910. * The strenght of the force in correspondence to the distance of the affected object
  136911. */
  136912. falloff: PhysicsRadialImpulseFalloff;
  136913. /**
  136914. * Sphere options for the radial explosion.
  136915. */
  136916. sphere: {
  136917. segments: number;
  136918. diameter: number;
  136919. };
  136920. /**
  136921. * Sphere options for the radial explosion.
  136922. */
  136923. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136924. }
  136925. /**
  136926. * Options fot the updraft event
  136927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136928. */
  136929. export class PhysicsUpdraftEventOptions {
  136930. /**
  136931. * The radius of the cylinder for the vortex
  136932. */
  136933. radius: number;
  136934. /**
  136935. * The strenth of the updraft.
  136936. */
  136937. strength: number;
  136938. /**
  136939. * The height of the cylinder for the updraft.
  136940. */
  136941. height: number;
  136942. /**
  136943. * The mode for the the updraft.
  136944. */
  136945. updraftMode: PhysicsUpdraftMode;
  136946. }
  136947. /**
  136948. * Options fot the vortex event
  136949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136950. */
  136951. export class PhysicsVortexEventOptions {
  136952. /**
  136953. * The radius of the cylinder for the vortex
  136954. */
  136955. radius: number;
  136956. /**
  136957. * The strenth of the vortex.
  136958. */
  136959. strength: number;
  136960. /**
  136961. * The height of the cylinder for the vortex.
  136962. */
  136963. height: number;
  136964. /**
  136965. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136966. */
  136967. centripetalForceThreshold: number;
  136968. /**
  136969. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136970. */
  136971. centripetalForceMultiplier: number;
  136972. /**
  136973. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136974. */
  136975. centrifugalForceMultiplier: number;
  136976. /**
  136977. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136978. */
  136979. updraftForceMultiplier: number;
  136980. }
  136981. /**
  136982. * The strenght of the force in correspondence to the distance of the affected object
  136983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136984. */
  136985. export enum PhysicsRadialImpulseFalloff {
  136986. /** Defines that impulse is constant in strength across it's whole radius */
  136987. Constant = 0,
  136988. /** Defines that impulse gets weaker if it's further from the origin */
  136989. Linear = 1
  136990. }
  136991. /**
  136992. * The strength of the force in correspondence to the distance of the affected object
  136993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136994. */
  136995. export enum PhysicsUpdraftMode {
  136996. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136997. Center = 0,
  136998. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136999. Perpendicular = 1
  137000. }
  137001. /**
  137002. * Interface for a physics hit data
  137003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137004. */
  137005. export interface PhysicsHitData {
  137006. /**
  137007. * The force applied at the contact point
  137008. */
  137009. force: Vector3;
  137010. /**
  137011. * The contact point
  137012. */
  137013. contactPoint: Vector3;
  137014. /**
  137015. * The distance from the origin to the contact point
  137016. */
  137017. distanceFromOrigin: number;
  137018. }
  137019. /**
  137020. * Interface for radial explosion event data
  137021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137022. */
  137023. export interface PhysicsRadialExplosionEventData {
  137024. /**
  137025. * A sphere used for the radial explosion event
  137026. */
  137027. sphere: Mesh;
  137028. }
  137029. /**
  137030. * Interface for gravitational field event data
  137031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137032. */
  137033. export interface PhysicsGravitationalFieldEventData {
  137034. /**
  137035. * A sphere mesh used for the gravitational field event
  137036. */
  137037. sphere: Mesh;
  137038. }
  137039. /**
  137040. * Interface for updraft event data
  137041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137042. */
  137043. export interface PhysicsUpdraftEventData {
  137044. /**
  137045. * A cylinder used for the updraft event
  137046. */
  137047. cylinder: Mesh;
  137048. }
  137049. /**
  137050. * Interface for vortex event data
  137051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137052. */
  137053. export interface PhysicsVortexEventData {
  137054. /**
  137055. * A cylinder used for the vortex event
  137056. */
  137057. cylinder: Mesh;
  137058. }
  137059. /**
  137060. * Interface for an affected physics impostor
  137061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137062. */
  137063. export interface PhysicsAffectedImpostorWithData {
  137064. /**
  137065. * The impostor affected by the effect
  137066. */
  137067. impostor: PhysicsImpostor;
  137068. /**
  137069. * The data about the hit/horce from the explosion
  137070. */
  137071. hitData: PhysicsHitData;
  137072. }
  137073. }
  137074. declare module BABYLON {
  137075. /** @hidden */
  137076. export var blackAndWhitePixelShader: {
  137077. name: string;
  137078. shader: string;
  137079. };
  137080. }
  137081. declare module BABYLON {
  137082. /**
  137083. * Post process used to render in black and white
  137084. */
  137085. export class BlackAndWhitePostProcess extends PostProcess {
  137086. /**
  137087. * Linear about to convert he result to black and white (default: 1)
  137088. */
  137089. degree: number;
  137090. /**
  137091. * Creates a black and white post process
  137092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137093. * @param name The name of the effect.
  137094. * @param options The required width/height ratio to downsize to before computing the render pass.
  137095. * @param camera The camera to apply the render pass to.
  137096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137097. * @param engine The engine which the post process will be applied. (default: current engine)
  137098. * @param reusable If the post process can be reused on the same frame. (default: false)
  137099. */
  137100. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137101. }
  137102. }
  137103. declare module BABYLON {
  137104. /**
  137105. * This represents a set of one or more post processes in Babylon.
  137106. * A post process can be used to apply a shader to a texture after it is rendered.
  137107. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137108. */
  137109. export class PostProcessRenderEffect {
  137110. private _postProcesses;
  137111. private _getPostProcesses;
  137112. private _singleInstance;
  137113. private _cameras;
  137114. private _indicesForCamera;
  137115. /**
  137116. * Name of the effect
  137117. * @hidden
  137118. */
  137119. _name: string;
  137120. /**
  137121. * Instantiates a post process render effect.
  137122. * A post process can be used to apply a shader to a texture after it is rendered.
  137123. * @param engine The engine the effect is tied to
  137124. * @param name The name of the effect
  137125. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137126. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137127. */
  137128. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137129. /**
  137130. * Checks if all the post processes in the effect are supported.
  137131. */
  137132. get isSupported(): boolean;
  137133. /**
  137134. * Updates the current state of the effect
  137135. * @hidden
  137136. */
  137137. _update(): void;
  137138. /**
  137139. * Attaches the effect on cameras
  137140. * @param cameras The camera to attach to.
  137141. * @hidden
  137142. */
  137143. _attachCameras(cameras: Camera): void;
  137144. /**
  137145. * Attaches the effect on cameras
  137146. * @param cameras The camera to attach to.
  137147. * @hidden
  137148. */
  137149. _attachCameras(cameras: Camera[]): void;
  137150. /**
  137151. * Detaches the effect on cameras
  137152. * @param cameras The camera to detatch from.
  137153. * @hidden
  137154. */
  137155. _detachCameras(cameras: Camera): void;
  137156. /**
  137157. * Detatches the effect on cameras
  137158. * @param cameras The camera to detatch from.
  137159. * @hidden
  137160. */
  137161. _detachCameras(cameras: Camera[]): void;
  137162. /**
  137163. * Enables the effect on given cameras
  137164. * @param cameras The camera to enable.
  137165. * @hidden
  137166. */
  137167. _enable(cameras: Camera): void;
  137168. /**
  137169. * Enables the effect on given cameras
  137170. * @param cameras The camera to enable.
  137171. * @hidden
  137172. */
  137173. _enable(cameras: Nullable<Camera[]>): void;
  137174. /**
  137175. * Disables the effect on the given cameras
  137176. * @param cameras The camera to disable.
  137177. * @hidden
  137178. */
  137179. _disable(cameras: Camera): void;
  137180. /**
  137181. * Disables the effect on the given cameras
  137182. * @param cameras The camera to disable.
  137183. * @hidden
  137184. */
  137185. _disable(cameras: Nullable<Camera[]>): void;
  137186. /**
  137187. * Gets a list of the post processes contained in the effect.
  137188. * @param camera The camera to get the post processes on.
  137189. * @returns The list of the post processes in the effect.
  137190. */
  137191. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137192. }
  137193. }
  137194. declare module BABYLON {
  137195. /** @hidden */
  137196. export var extractHighlightsPixelShader: {
  137197. name: string;
  137198. shader: string;
  137199. };
  137200. }
  137201. declare module BABYLON {
  137202. /**
  137203. * 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.
  137204. */
  137205. export class ExtractHighlightsPostProcess extends PostProcess {
  137206. /**
  137207. * The luminance threshold, pixels below this value will be set to black.
  137208. */
  137209. threshold: number;
  137210. /** @hidden */
  137211. _exposure: number;
  137212. /**
  137213. * Post process which has the input texture to be used when performing highlight extraction
  137214. * @hidden
  137215. */
  137216. _inputPostProcess: Nullable<PostProcess>;
  137217. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137218. }
  137219. }
  137220. declare module BABYLON {
  137221. /** @hidden */
  137222. export var bloomMergePixelShader: {
  137223. name: string;
  137224. shader: string;
  137225. };
  137226. }
  137227. declare module BABYLON {
  137228. /**
  137229. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137230. */
  137231. export class BloomMergePostProcess extends PostProcess {
  137232. /** Weight of the bloom to be added to the original input. */
  137233. weight: number;
  137234. /**
  137235. * Creates a new instance of @see BloomMergePostProcess
  137236. * @param name The name of the effect.
  137237. * @param originalFromInput Post process which's input will be used for the merge.
  137238. * @param blurred Blurred highlights post process which's output will be used.
  137239. * @param weight Weight of the bloom to be added to the original input.
  137240. * @param options The required width/height ratio to downsize to before computing the render pass.
  137241. * @param camera The camera to apply the render pass to.
  137242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137243. * @param engine The engine which the post process will be applied. (default: current engine)
  137244. * @param reusable If the post process can be reused on the same frame. (default: false)
  137245. * @param textureType Type of textures used when performing the post process. (default: 0)
  137246. * @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)
  137247. */
  137248. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137249. /** Weight of the bloom to be added to the original input. */
  137250. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137251. }
  137252. }
  137253. declare module BABYLON {
  137254. /**
  137255. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137256. */
  137257. export class BloomEffect extends PostProcessRenderEffect {
  137258. private bloomScale;
  137259. /**
  137260. * @hidden Internal
  137261. */
  137262. _effects: Array<PostProcess>;
  137263. /**
  137264. * @hidden Internal
  137265. */
  137266. _downscale: ExtractHighlightsPostProcess;
  137267. private _blurX;
  137268. private _blurY;
  137269. private _merge;
  137270. /**
  137271. * The luminance threshold to find bright areas of the image to bloom.
  137272. */
  137273. get threshold(): number;
  137274. set threshold(value: number);
  137275. /**
  137276. * The strength of the bloom.
  137277. */
  137278. get weight(): number;
  137279. set weight(value: number);
  137280. /**
  137281. * Specifies the size of the bloom blur kernel, relative to the final output size
  137282. */
  137283. get kernel(): number;
  137284. set kernel(value: number);
  137285. /**
  137286. * Creates a new instance of @see BloomEffect
  137287. * @param scene The scene the effect belongs to.
  137288. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137289. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137290. * @param bloomWeight The the strength of bloom.
  137291. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137292. * @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)
  137293. */
  137294. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137295. /**
  137296. * Disposes each of the internal effects for a given camera.
  137297. * @param camera The camera to dispose the effect on.
  137298. */
  137299. disposeEffects(camera: Camera): void;
  137300. /**
  137301. * @hidden Internal
  137302. */
  137303. _updateEffects(): void;
  137304. /**
  137305. * Internal
  137306. * @returns if all the contained post processes are ready.
  137307. * @hidden
  137308. */
  137309. _isReady(): boolean;
  137310. }
  137311. }
  137312. declare module BABYLON {
  137313. /** @hidden */
  137314. export var chromaticAberrationPixelShader: {
  137315. name: string;
  137316. shader: string;
  137317. };
  137318. }
  137319. declare module BABYLON {
  137320. /**
  137321. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137322. */
  137323. export class ChromaticAberrationPostProcess extends PostProcess {
  137324. /**
  137325. * The amount of seperation of rgb channels (default: 30)
  137326. */
  137327. aberrationAmount: number;
  137328. /**
  137329. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137330. */
  137331. radialIntensity: number;
  137332. /**
  137333. * 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))
  137334. */
  137335. direction: Vector2;
  137336. /**
  137337. * 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))
  137338. */
  137339. centerPosition: Vector2;
  137340. /**
  137341. * Creates a new instance ChromaticAberrationPostProcess
  137342. * @param name The name of the effect.
  137343. * @param screenWidth The width of the screen to apply the effect on.
  137344. * @param screenHeight The height of the screen to apply the effect on.
  137345. * @param options The required width/height ratio to downsize to before computing the render pass.
  137346. * @param camera The camera to apply the render pass to.
  137347. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137348. * @param engine The engine which the post process will be applied. (default: current engine)
  137349. * @param reusable If the post process can be reused on the same frame. (default: false)
  137350. * @param textureType Type of textures used when performing the post process. (default: 0)
  137351. * @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)
  137352. */
  137353. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137354. }
  137355. }
  137356. declare module BABYLON {
  137357. /** @hidden */
  137358. export var circleOfConfusionPixelShader: {
  137359. name: string;
  137360. shader: string;
  137361. };
  137362. }
  137363. declare module BABYLON {
  137364. /**
  137365. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137366. */
  137367. export class CircleOfConfusionPostProcess extends PostProcess {
  137368. /**
  137369. * 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.
  137370. */
  137371. lensSize: number;
  137372. /**
  137373. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137374. */
  137375. fStop: number;
  137376. /**
  137377. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137378. */
  137379. focusDistance: number;
  137380. /**
  137381. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137382. */
  137383. focalLength: number;
  137384. private _depthTexture;
  137385. /**
  137386. * Creates a new instance CircleOfConfusionPostProcess
  137387. * @param name The name of the effect.
  137388. * @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.
  137389. * @param options The required width/height ratio to downsize to before computing the render pass.
  137390. * @param camera The camera to apply the render pass to.
  137391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137392. * @param engine The engine which the post process will be applied. (default: current engine)
  137393. * @param reusable If the post process can be reused on the same frame. (default: false)
  137394. * @param textureType Type of textures used when performing the post process. (default: 0)
  137395. * @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)
  137396. */
  137397. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137398. /**
  137399. * 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.
  137400. */
  137401. set depthTexture(value: RenderTargetTexture);
  137402. }
  137403. }
  137404. declare module BABYLON {
  137405. /** @hidden */
  137406. export var colorCorrectionPixelShader: {
  137407. name: string;
  137408. shader: string;
  137409. };
  137410. }
  137411. declare module BABYLON {
  137412. /**
  137413. *
  137414. * This post-process allows the modification of rendered colors by using
  137415. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137416. *
  137417. * The object needs to be provided an url to a texture containing the color
  137418. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137419. * Use an image editing software to tweak the LUT to match your needs.
  137420. *
  137421. * For an example of a color LUT, see here:
  137422. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137423. * For explanations on color grading, see here:
  137424. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137425. *
  137426. */
  137427. export class ColorCorrectionPostProcess extends PostProcess {
  137428. private _colorTableTexture;
  137429. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137430. }
  137431. }
  137432. declare module BABYLON {
  137433. /** @hidden */
  137434. export var convolutionPixelShader: {
  137435. name: string;
  137436. shader: string;
  137437. };
  137438. }
  137439. declare module BABYLON {
  137440. /**
  137441. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137442. * input texture to perform effects such as edge detection or sharpening
  137443. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137444. */
  137445. export class ConvolutionPostProcess extends PostProcess {
  137446. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137447. kernel: number[];
  137448. /**
  137449. * Creates a new instance ConvolutionPostProcess
  137450. * @param name The name of the effect.
  137451. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137452. * @param options The required width/height ratio to downsize to before computing the render pass.
  137453. * @param camera The camera to apply the render pass to.
  137454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137455. * @param engine The engine which the post process will be applied. (default: current engine)
  137456. * @param reusable If the post process can be reused on the same frame. (default: false)
  137457. * @param textureType Type of textures used when performing the post process. (default: 0)
  137458. */
  137459. constructor(name: string,
  137460. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137461. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137462. /**
  137463. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137464. */
  137465. static EdgeDetect0Kernel: number[];
  137466. /**
  137467. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137468. */
  137469. static EdgeDetect1Kernel: number[];
  137470. /**
  137471. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137472. */
  137473. static EdgeDetect2Kernel: number[];
  137474. /**
  137475. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137476. */
  137477. static SharpenKernel: number[];
  137478. /**
  137479. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137480. */
  137481. static EmbossKernel: number[];
  137482. /**
  137483. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137484. */
  137485. static GaussianKernel: number[];
  137486. }
  137487. }
  137488. declare module BABYLON {
  137489. /**
  137490. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137491. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137492. * based on samples that have a large difference in distance than the center pixel.
  137493. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137494. */
  137495. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137496. direction: Vector2;
  137497. /**
  137498. * Creates a new instance CircleOfConfusionPostProcess
  137499. * @param name The name of the effect.
  137500. * @param scene The scene the effect belongs to.
  137501. * @param direction The direction the blur should be applied.
  137502. * @param kernel The size of the kernel used to blur.
  137503. * @param options The required width/height ratio to downsize to before computing the render pass.
  137504. * @param camera The camera to apply the render pass to.
  137505. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137506. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137508. * @param engine The engine which the post process will be applied. (default: current engine)
  137509. * @param reusable If the post process can be reused on the same frame. (default: false)
  137510. * @param textureType Type of textures used when performing the post process. (default: 0)
  137511. * @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)
  137512. */
  137513. 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);
  137514. }
  137515. }
  137516. declare module BABYLON {
  137517. /** @hidden */
  137518. export var depthOfFieldMergePixelShader: {
  137519. name: string;
  137520. shader: string;
  137521. };
  137522. }
  137523. declare module BABYLON {
  137524. /**
  137525. * Options to be set when merging outputs from the default pipeline.
  137526. */
  137527. export class DepthOfFieldMergePostProcessOptions {
  137528. /**
  137529. * The original image to merge on top of
  137530. */
  137531. originalFromInput: PostProcess;
  137532. /**
  137533. * Parameters to perform the merge of the depth of field effect
  137534. */
  137535. depthOfField?: {
  137536. circleOfConfusion: PostProcess;
  137537. blurSteps: Array<PostProcess>;
  137538. };
  137539. /**
  137540. * Parameters to perform the merge of bloom effect
  137541. */
  137542. bloom?: {
  137543. blurred: PostProcess;
  137544. weight: number;
  137545. };
  137546. }
  137547. /**
  137548. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137549. */
  137550. export class DepthOfFieldMergePostProcess extends PostProcess {
  137551. private blurSteps;
  137552. /**
  137553. * Creates a new instance of DepthOfFieldMergePostProcess
  137554. * @param name The name of the effect.
  137555. * @param originalFromInput Post process which's input will be used for the merge.
  137556. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137557. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137558. * @param options The required width/height ratio to downsize to before computing the render pass.
  137559. * @param camera The camera to apply the render pass to.
  137560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137561. * @param engine The engine which the post process will be applied. (default: current engine)
  137562. * @param reusable If the post process can be reused on the same frame. (default: false)
  137563. * @param textureType Type of textures used when performing the post process. (default: 0)
  137564. * @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)
  137565. */
  137566. 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);
  137567. /**
  137568. * Updates the effect with the current post process compile time values and recompiles the shader.
  137569. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137570. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137571. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137572. * @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
  137573. * @param onCompiled Called when the shader has been compiled.
  137574. * @param onError Called if there is an error when compiling a shader.
  137575. */
  137576. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137577. }
  137578. }
  137579. declare module BABYLON {
  137580. /**
  137581. * Specifies the level of max blur that should be applied when using the depth of field effect
  137582. */
  137583. export enum DepthOfFieldEffectBlurLevel {
  137584. /**
  137585. * Subtle blur
  137586. */
  137587. Low = 0,
  137588. /**
  137589. * Medium blur
  137590. */
  137591. Medium = 1,
  137592. /**
  137593. * Large blur
  137594. */
  137595. High = 2
  137596. }
  137597. /**
  137598. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137599. */
  137600. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137601. private _circleOfConfusion;
  137602. /**
  137603. * @hidden Internal, blurs from high to low
  137604. */
  137605. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137606. private _depthOfFieldBlurY;
  137607. private _dofMerge;
  137608. /**
  137609. * @hidden Internal post processes in depth of field effect
  137610. */
  137611. _effects: Array<PostProcess>;
  137612. /**
  137613. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137614. */
  137615. set focalLength(value: number);
  137616. get focalLength(): number;
  137617. /**
  137618. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137619. */
  137620. set fStop(value: number);
  137621. get fStop(): number;
  137622. /**
  137623. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137624. */
  137625. set focusDistance(value: number);
  137626. get focusDistance(): number;
  137627. /**
  137628. * 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.
  137629. */
  137630. set lensSize(value: number);
  137631. get lensSize(): number;
  137632. /**
  137633. * Creates a new instance DepthOfFieldEffect
  137634. * @param scene The scene the effect belongs to.
  137635. * @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.
  137636. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137637. * @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)
  137638. */
  137639. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137640. /**
  137641. * Get the current class name of the current effet
  137642. * @returns "DepthOfFieldEffect"
  137643. */
  137644. getClassName(): string;
  137645. /**
  137646. * 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.
  137647. */
  137648. set depthTexture(value: RenderTargetTexture);
  137649. /**
  137650. * Disposes each of the internal effects for a given camera.
  137651. * @param camera The camera to dispose the effect on.
  137652. */
  137653. disposeEffects(camera: Camera): void;
  137654. /**
  137655. * @hidden Internal
  137656. */
  137657. _updateEffects(): void;
  137658. /**
  137659. * Internal
  137660. * @returns if all the contained post processes are ready.
  137661. * @hidden
  137662. */
  137663. _isReady(): boolean;
  137664. }
  137665. }
  137666. declare module BABYLON {
  137667. /** @hidden */
  137668. export var displayPassPixelShader: {
  137669. name: string;
  137670. shader: string;
  137671. };
  137672. }
  137673. declare module BABYLON {
  137674. /**
  137675. * DisplayPassPostProcess which produces an output the same as it's input
  137676. */
  137677. export class DisplayPassPostProcess extends PostProcess {
  137678. /**
  137679. * Creates the DisplayPassPostProcess
  137680. * @param name The name of the effect.
  137681. * @param options The required width/height ratio to downsize to before computing the render pass.
  137682. * @param camera The camera to apply the render pass to.
  137683. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137684. * @param engine The engine which the post process will be applied. (default: current engine)
  137685. * @param reusable If the post process can be reused on the same frame. (default: false)
  137686. */
  137687. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137688. }
  137689. }
  137690. declare module BABYLON {
  137691. /** @hidden */
  137692. export var filterPixelShader: {
  137693. name: string;
  137694. shader: string;
  137695. };
  137696. }
  137697. declare module BABYLON {
  137698. /**
  137699. * Applies a kernel filter to the image
  137700. */
  137701. export class FilterPostProcess extends PostProcess {
  137702. /** The matrix to be applied to the image */
  137703. kernelMatrix: Matrix;
  137704. /**
  137705. *
  137706. * @param name The name of the effect.
  137707. * @param kernelMatrix The matrix to be applied to the image
  137708. * @param options The required width/height ratio to downsize to before computing the render pass.
  137709. * @param camera The camera to apply the render pass to.
  137710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137711. * @param engine The engine which the post process will be applied. (default: current engine)
  137712. * @param reusable If the post process can be reused on the same frame. (default: false)
  137713. */
  137714. constructor(name: string,
  137715. /** The matrix to be applied to the image */
  137716. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137717. }
  137718. }
  137719. declare module BABYLON {
  137720. /** @hidden */
  137721. export var fxaaPixelShader: {
  137722. name: string;
  137723. shader: string;
  137724. };
  137725. }
  137726. declare module BABYLON {
  137727. /** @hidden */
  137728. export var fxaaVertexShader: {
  137729. name: string;
  137730. shader: string;
  137731. };
  137732. }
  137733. declare module BABYLON {
  137734. /**
  137735. * Fxaa post process
  137736. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137737. */
  137738. export class FxaaPostProcess extends PostProcess {
  137739. /** @hidden */
  137740. texelWidth: number;
  137741. /** @hidden */
  137742. texelHeight: number;
  137743. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137744. private _getDefines;
  137745. }
  137746. }
  137747. declare module BABYLON {
  137748. /** @hidden */
  137749. export var grainPixelShader: {
  137750. name: string;
  137751. shader: string;
  137752. };
  137753. }
  137754. declare module BABYLON {
  137755. /**
  137756. * The GrainPostProcess adds noise to the image at mid luminance levels
  137757. */
  137758. export class GrainPostProcess extends PostProcess {
  137759. /**
  137760. * The intensity of the grain added (default: 30)
  137761. */
  137762. intensity: number;
  137763. /**
  137764. * If the grain should be randomized on every frame
  137765. */
  137766. animated: boolean;
  137767. /**
  137768. * Creates a new instance of @see GrainPostProcess
  137769. * @param name The name of the effect.
  137770. * @param options The required width/height ratio to downsize to before computing the render pass.
  137771. * @param camera The camera to apply the render pass to.
  137772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137773. * @param engine The engine which the post process will be applied. (default: current engine)
  137774. * @param reusable If the post process can be reused on the same frame. (default: false)
  137775. * @param textureType Type of textures used when performing the post process. (default: 0)
  137776. * @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)
  137777. */
  137778. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137779. }
  137780. }
  137781. declare module BABYLON {
  137782. /** @hidden */
  137783. export var highlightsPixelShader: {
  137784. name: string;
  137785. shader: string;
  137786. };
  137787. }
  137788. declare module BABYLON {
  137789. /**
  137790. * Extracts highlights from the image
  137791. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137792. */
  137793. export class HighlightsPostProcess extends PostProcess {
  137794. /**
  137795. * Extracts highlights from the image
  137796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137797. * @param name The name of the effect.
  137798. * @param options The required width/height ratio to downsize to before computing the render pass.
  137799. * @param camera The camera to apply the render pass to.
  137800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137801. * @param engine The engine which the post process will be applied. (default: current engine)
  137802. * @param reusable If the post process can be reused on the same frame. (default: false)
  137803. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137804. */
  137805. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137806. }
  137807. }
  137808. declare module BABYLON {
  137809. /** @hidden */
  137810. export var mrtFragmentDeclaration: {
  137811. name: string;
  137812. shader: string;
  137813. };
  137814. }
  137815. declare module BABYLON {
  137816. /** @hidden */
  137817. export var geometryPixelShader: {
  137818. name: string;
  137819. shader: string;
  137820. };
  137821. }
  137822. declare module BABYLON {
  137823. /** @hidden */
  137824. export var geometryVertexShader: {
  137825. name: string;
  137826. shader: string;
  137827. };
  137828. }
  137829. declare module BABYLON {
  137830. /** @hidden */
  137831. interface ISavedTransformationMatrix {
  137832. world: Matrix;
  137833. viewProjection: Matrix;
  137834. }
  137835. /**
  137836. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137837. */
  137838. export class GeometryBufferRenderer {
  137839. /**
  137840. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137841. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137842. */
  137843. static readonly POSITION_TEXTURE_TYPE: number;
  137844. /**
  137845. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137846. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137847. */
  137848. static readonly VELOCITY_TEXTURE_TYPE: number;
  137849. /**
  137850. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137851. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137852. */
  137853. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137854. /**
  137855. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137856. * in order to compute objects velocities when enableVelocity is set to "true"
  137857. * @hidden
  137858. */
  137859. _previousTransformationMatrices: {
  137860. [index: number]: ISavedTransformationMatrix;
  137861. };
  137862. /**
  137863. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137864. * in order to compute objects velocities when enableVelocity is set to "true"
  137865. * @hidden
  137866. */
  137867. _previousBonesTransformationMatrices: {
  137868. [index: number]: Float32Array;
  137869. };
  137870. /**
  137871. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137872. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137873. */
  137874. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137875. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137876. renderTransparentMeshes: boolean;
  137877. private _scene;
  137878. private _multiRenderTarget;
  137879. private _ratio;
  137880. private _enablePosition;
  137881. private _enableVelocity;
  137882. private _enableReflectivity;
  137883. private _positionIndex;
  137884. private _velocityIndex;
  137885. private _reflectivityIndex;
  137886. protected _effect: Effect;
  137887. protected _cachedDefines: string;
  137888. /**
  137889. * Set the render list (meshes to be rendered) used in the G buffer.
  137890. */
  137891. set renderList(meshes: Mesh[]);
  137892. /**
  137893. * Gets wether or not G buffer are supported by the running hardware.
  137894. * This requires draw buffer supports
  137895. */
  137896. get isSupported(): boolean;
  137897. /**
  137898. * Returns the index of the given texture type in the G-Buffer textures array
  137899. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137900. * @returns the index of the given texture type in the G-Buffer textures array
  137901. */
  137902. getTextureIndex(textureType: number): number;
  137903. /**
  137904. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137905. */
  137906. get enablePosition(): boolean;
  137907. /**
  137908. * Sets whether or not objects positions are enabled for the G buffer.
  137909. */
  137910. set enablePosition(enable: boolean);
  137911. /**
  137912. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137913. */
  137914. get enableVelocity(): boolean;
  137915. /**
  137916. * Sets wether or not objects velocities are enabled for the G buffer.
  137917. */
  137918. set enableVelocity(enable: boolean);
  137919. /**
  137920. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137921. */
  137922. get enableReflectivity(): boolean;
  137923. /**
  137924. * Sets wether or not objects roughness are enabled for the G buffer.
  137925. */
  137926. set enableReflectivity(enable: boolean);
  137927. /**
  137928. * Gets the scene associated with the buffer.
  137929. */
  137930. get scene(): Scene;
  137931. /**
  137932. * Gets the ratio used by the buffer during its creation.
  137933. * How big is the buffer related to the main canvas.
  137934. */
  137935. get ratio(): number;
  137936. /** @hidden */
  137937. static _SceneComponentInitialization: (scene: Scene) => void;
  137938. /**
  137939. * Creates a new G Buffer for the scene
  137940. * @param scene The scene the buffer belongs to
  137941. * @param ratio How big is the buffer related to the main canvas.
  137942. */
  137943. constructor(scene: Scene, ratio?: number);
  137944. /**
  137945. * Checks wether everything is ready to render a submesh to the G buffer.
  137946. * @param subMesh the submesh to check readiness for
  137947. * @param useInstances is the mesh drawn using instance or not
  137948. * @returns true if ready otherwise false
  137949. */
  137950. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137951. /**
  137952. * Gets the current underlying G Buffer.
  137953. * @returns the buffer
  137954. */
  137955. getGBuffer(): MultiRenderTarget;
  137956. /**
  137957. * Gets the number of samples used to render the buffer (anti aliasing).
  137958. */
  137959. get samples(): number;
  137960. /**
  137961. * Sets the number of samples used to render the buffer (anti aliasing).
  137962. */
  137963. set samples(value: number);
  137964. /**
  137965. * Disposes the renderer and frees up associated resources.
  137966. */
  137967. dispose(): void;
  137968. protected _createRenderTargets(): void;
  137969. private _copyBonesTransformationMatrices;
  137970. }
  137971. }
  137972. declare module BABYLON {
  137973. interface Scene {
  137974. /** @hidden (Backing field) */
  137975. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137976. /**
  137977. * Gets or Sets the current geometry buffer associated to the scene.
  137978. */
  137979. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137980. /**
  137981. * Enables a GeometryBufferRender and associates it with the scene
  137982. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137983. * @returns the GeometryBufferRenderer
  137984. */
  137985. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137986. /**
  137987. * Disables the GeometryBufferRender associated with the scene
  137988. */
  137989. disableGeometryBufferRenderer(): void;
  137990. }
  137991. /**
  137992. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137993. * in several rendering techniques.
  137994. */
  137995. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137996. /**
  137997. * The component name helpful to identify the component in the list of scene components.
  137998. */
  137999. readonly name: string;
  138000. /**
  138001. * The scene the component belongs to.
  138002. */
  138003. scene: Scene;
  138004. /**
  138005. * Creates a new instance of the component for the given scene
  138006. * @param scene Defines the scene to register the component in
  138007. */
  138008. constructor(scene: Scene);
  138009. /**
  138010. * Registers the component in a given scene
  138011. */
  138012. register(): void;
  138013. /**
  138014. * Rebuilds the elements related to this component in case of
  138015. * context lost for instance.
  138016. */
  138017. rebuild(): void;
  138018. /**
  138019. * Disposes the component and the associated ressources
  138020. */
  138021. dispose(): void;
  138022. private _gatherRenderTargets;
  138023. }
  138024. }
  138025. declare module BABYLON {
  138026. /** @hidden */
  138027. export var motionBlurPixelShader: {
  138028. name: string;
  138029. shader: string;
  138030. };
  138031. }
  138032. declare module BABYLON {
  138033. /**
  138034. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138035. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138036. * As an example, all you have to do is to create the post-process:
  138037. * var mb = new BABYLON.MotionBlurPostProcess(
  138038. * 'mb', // The name of the effect.
  138039. * scene, // The scene containing the objects to blur according to their velocity.
  138040. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138041. * camera // The camera to apply the render pass to.
  138042. * );
  138043. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138044. */
  138045. export class MotionBlurPostProcess extends PostProcess {
  138046. /**
  138047. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138048. */
  138049. motionStrength: number;
  138050. /**
  138051. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138052. */
  138053. get motionBlurSamples(): number;
  138054. /**
  138055. * Sets the number of iterations to be used for motion blur quality
  138056. */
  138057. set motionBlurSamples(samples: number);
  138058. private _motionBlurSamples;
  138059. private _geometryBufferRenderer;
  138060. /**
  138061. * Creates a new instance MotionBlurPostProcess
  138062. * @param name The name of the effect.
  138063. * @param scene The scene containing the objects to blur according to their velocity.
  138064. * @param options The required width/height ratio to downsize to before computing the render pass.
  138065. * @param camera The camera to apply the render pass to.
  138066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138067. * @param engine The engine which the post process will be applied. (default: current engine)
  138068. * @param reusable If the post process can be reused on the same frame. (default: false)
  138069. * @param textureType Type of textures used when performing the post process. (default: 0)
  138070. * @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)
  138071. */
  138072. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138073. /**
  138074. * Excludes the given skinned mesh from computing bones velocities.
  138075. * 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.
  138076. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138077. */
  138078. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138079. /**
  138080. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138081. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138082. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138083. */
  138084. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138085. /**
  138086. * Disposes the post process.
  138087. * @param camera The camera to dispose the post process on.
  138088. */
  138089. dispose(camera?: Camera): void;
  138090. }
  138091. }
  138092. declare module BABYLON {
  138093. /** @hidden */
  138094. export var refractionPixelShader: {
  138095. name: string;
  138096. shader: string;
  138097. };
  138098. }
  138099. declare module BABYLON {
  138100. /**
  138101. * Post process which applies a refractin texture
  138102. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138103. */
  138104. export class RefractionPostProcess extends PostProcess {
  138105. /** the base color of the refraction (used to taint the rendering) */
  138106. color: Color3;
  138107. /** simulated refraction depth */
  138108. depth: number;
  138109. /** the coefficient of the base color (0 to remove base color tainting) */
  138110. colorLevel: number;
  138111. private _refTexture;
  138112. private _ownRefractionTexture;
  138113. /**
  138114. * Gets or sets the refraction texture
  138115. * Please note that you are responsible for disposing the texture if you set it manually
  138116. */
  138117. get refractionTexture(): Texture;
  138118. set refractionTexture(value: Texture);
  138119. /**
  138120. * Initializes the RefractionPostProcess
  138121. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138122. * @param name The name of the effect.
  138123. * @param refractionTextureUrl Url of the refraction texture to use
  138124. * @param color the base color of the refraction (used to taint the rendering)
  138125. * @param depth simulated refraction depth
  138126. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138127. * @param camera The camera to apply the render pass to.
  138128. * @param options The required width/height ratio to downsize to before computing the render pass.
  138129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138130. * @param engine The engine which the post process will be applied. (default: current engine)
  138131. * @param reusable If the post process can be reused on the same frame. (default: false)
  138132. */
  138133. constructor(name: string, refractionTextureUrl: string,
  138134. /** the base color of the refraction (used to taint the rendering) */
  138135. color: Color3,
  138136. /** simulated refraction depth */
  138137. depth: number,
  138138. /** the coefficient of the base color (0 to remove base color tainting) */
  138139. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138140. /**
  138141. * Disposes of the post process
  138142. * @param camera Camera to dispose post process on
  138143. */
  138144. dispose(camera: Camera): void;
  138145. }
  138146. }
  138147. declare module BABYLON {
  138148. /** @hidden */
  138149. export var sharpenPixelShader: {
  138150. name: string;
  138151. shader: string;
  138152. };
  138153. }
  138154. declare module BABYLON {
  138155. /**
  138156. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138157. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138158. */
  138159. export class SharpenPostProcess extends PostProcess {
  138160. /**
  138161. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138162. */
  138163. colorAmount: number;
  138164. /**
  138165. * How much sharpness should be applied (default: 0.3)
  138166. */
  138167. edgeAmount: number;
  138168. /**
  138169. * Creates a new instance ConvolutionPostProcess
  138170. * @param name The name of the effect.
  138171. * @param options The required width/height ratio to downsize to before computing the render pass.
  138172. * @param camera The camera to apply the render pass to.
  138173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138174. * @param engine The engine which the post process will be applied. (default: current engine)
  138175. * @param reusable If the post process can be reused on the same frame. (default: false)
  138176. * @param textureType Type of textures used when performing the post process. (default: 0)
  138177. * @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)
  138178. */
  138179. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138180. }
  138181. }
  138182. declare module BABYLON {
  138183. /**
  138184. * PostProcessRenderPipeline
  138185. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138186. */
  138187. export class PostProcessRenderPipeline {
  138188. private engine;
  138189. private _renderEffects;
  138190. private _renderEffectsForIsolatedPass;
  138191. /**
  138192. * List of inspectable custom properties (used by the Inspector)
  138193. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138194. */
  138195. inspectableCustomProperties: IInspectable[];
  138196. /**
  138197. * @hidden
  138198. */
  138199. protected _cameras: Camera[];
  138200. /** @hidden */
  138201. _name: string;
  138202. /**
  138203. * Gets pipeline name
  138204. */
  138205. get name(): string;
  138206. /** Gets the list of attached cameras */
  138207. get cameras(): Camera[];
  138208. /**
  138209. * Initializes a PostProcessRenderPipeline
  138210. * @param engine engine to add the pipeline to
  138211. * @param name name of the pipeline
  138212. */
  138213. constructor(engine: Engine, name: string);
  138214. /**
  138215. * Gets the class name
  138216. * @returns "PostProcessRenderPipeline"
  138217. */
  138218. getClassName(): string;
  138219. /**
  138220. * If all the render effects in the pipeline are supported
  138221. */
  138222. get isSupported(): boolean;
  138223. /**
  138224. * Adds an effect to the pipeline
  138225. * @param renderEffect the effect to add
  138226. */
  138227. addEffect(renderEffect: PostProcessRenderEffect): void;
  138228. /** @hidden */
  138229. _rebuild(): void;
  138230. /** @hidden */
  138231. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138232. /** @hidden */
  138233. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138234. /** @hidden */
  138235. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138236. /** @hidden */
  138237. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138238. /** @hidden */
  138239. _attachCameras(cameras: Camera, unique: boolean): void;
  138240. /** @hidden */
  138241. _attachCameras(cameras: Camera[], unique: boolean): void;
  138242. /** @hidden */
  138243. _detachCameras(cameras: Camera): void;
  138244. /** @hidden */
  138245. _detachCameras(cameras: Nullable<Camera[]>): void;
  138246. /** @hidden */
  138247. _update(): void;
  138248. /** @hidden */
  138249. _reset(): void;
  138250. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138251. /**
  138252. * Disposes of the pipeline
  138253. */
  138254. dispose(): void;
  138255. }
  138256. }
  138257. declare module BABYLON {
  138258. /**
  138259. * PostProcessRenderPipelineManager class
  138260. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138261. */
  138262. export class PostProcessRenderPipelineManager {
  138263. private _renderPipelines;
  138264. /**
  138265. * Initializes a PostProcessRenderPipelineManager
  138266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138267. */
  138268. constructor();
  138269. /**
  138270. * Gets the list of supported render pipelines
  138271. */
  138272. get supportedPipelines(): PostProcessRenderPipeline[];
  138273. /**
  138274. * Adds a pipeline to the manager
  138275. * @param renderPipeline The pipeline to add
  138276. */
  138277. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138278. /**
  138279. * Attaches a camera to the pipeline
  138280. * @param renderPipelineName The name of the pipeline to attach to
  138281. * @param cameras the camera to attach
  138282. * @param unique if the camera can be attached multiple times to the pipeline
  138283. */
  138284. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138285. /**
  138286. * Detaches a camera from the pipeline
  138287. * @param renderPipelineName The name of the pipeline to detach from
  138288. * @param cameras the camera to detach
  138289. */
  138290. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138291. /**
  138292. * Enables an effect by name on a pipeline
  138293. * @param renderPipelineName the name of the pipeline to enable the effect in
  138294. * @param renderEffectName the name of the effect to enable
  138295. * @param cameras the cameras that the effect should be enabled on
  138296. */
  138297. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138298. /**
  138299. * Disables an effect by name on a pipeline
  138300. * @param renderPipelineName the name of the pipeline to disable the effect in
  138301. * @param renderEffectName the name of the effect to disable
  138302. * @param cameras the cameras that the effect should be disabled on
  138303. */
  138304. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138305. /**
  138306. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138307. */
  138308. update(): void;
  138309. /** @hidden */
  138310. _rebuild(): void;
  138311. /**
  138312. * Disposes of the manager and pipelines
  138313. */
  138314. dispose(): void;
  138315. }
  138316. }
  138317. declare module BABYLON {
  138318. interface Scene {
  138319. /** @hidden (Backing field) */
  138320. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138321. /**
  138322. * Gets the postprocess render pipeline manager
  138323. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138324. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138325. */
  138326. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138327. }
  138328. /**
  138329. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138330. */
  138331. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138332. /**
  138333. * The component name helpfull to identify the component in the list of scene components.
  138334. */
  138335. readonly name: string;
  138336. /**
  138337. * The scene the component belongs to.
  138338. */
  138339. scene: Scene;
  138340. /**
  138341. * Creates a new instance of the component for the given scene
  138342. * @param scene Defines the scene to register the component in
  138343. */
  138344. constructor(scene: Scene);
  138345. /**
  138346. * Registers the component in a given scene
  138347. */
  138348. register(): void;
  138349. /**
  138350. * Rebuilds the elements related to this component in case of
  138351. * context lost for instance.
  138352. */
  138353. rebuild(): void;
  138354. /**
  138355. * Disposes the component and the associated ressources
  138356. */
  138357. dispose(): void;
  138358. private _gatherRenderTargets;
  138359. }
  138360. }
  138361. declare module BABYLON {
  138362. /**
  138363. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138364. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138365. */
  138366. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138367. private _scene;
  138368. private _camerasToBeAttached;
  138369. /**
  138370. * ID of the sharpen post process,
  138371. */
  138372. private readonly SharpenPostProcessId;
  138373. /**
  138374. * @ignore
  138375. * ID of the image processing post process;
  138376. */
  138377. readonly ImageProcessingPostProcessId: string;
  138378. /**
  138379. * @ignore
  138380. * ID of the Fast Approximate Anti-Aliasing post process;
  138381. */
  138382. readonly FxaaPostProcessId: string;
  138383. /**
  138384. * ID of the chromatic aberration post process,
  138385. */
  138386. private readonly ChromaticAberrationPostProcessId;
  138387. /**
  138388. * ID of the grain post process
  138389. */
  138390. private readonly GrainPostProcessId;
  138391. /**
  138392. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138393. */
  138394. sharpen: SharpenPostProcess;
  138395. private _sharpenEffect;
  138396. private bloom;
  138397. /**
  138398. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138399. */
  138400. depthOfField: DepthOfFieldEffect;
  138401. /**
  138402. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138403. */
  138404. fxaa: FxaaPostProcess;
  138405. /**
  138406. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138407. */
  138408. imageProcessing: ImageProcessingPostProcess;
  138409. /**
  138410. * Chromatic aberration post process which will shift rgb colors in the image
  138411. */
  138412. chromaticAberration: ChromaticAberrationPostProcess;
  138413. private _chromaticAberrationEffect;
  138414. /**
  138415. * Grain post process which add noise to the image
  138416. */
  138417. grain: GrainPostProcess;
  138418. private _grainEffect;
  138419. /**
  138420. * Glow post process which adds a glow to emissive areas of the image
  138421. */
  138422. private _glowLayer;
  138423. /**
  138424. * Animations which can be used to tweak settings over a period of time
  138425. */
  138426. animations: Animation[];
  138427. private _imageProcessingConfigurationObserver;
  138428. private _sharpenEnabled;
  138429. private _bloomEnabled;
  138430. private _depthOfFieldEnabled;
  138431. private _depthOfFieldBlurLevel;
  138432. private _fxaaEnabled;
  138433. private _imageProcessingEnabled;
  138434. private _defaultPipelineTextureType;
  138435. private _bloomScale;
  138436. private _chromaticAberrationEnabled;
  138437. private _grainEnabled;
  138438. private _buildAllowed;
  138439. /**
  138440. * Gets active scene
  138441. */
  138442. get scene(): Scene;
  138443. /**
  138444. * Enable or disable the sharpen process from the pipeline
  138445. */
  138446. set sharpenEnabled(enabled: boolean);
  138447. get sharpenEnabled(): boolean;
  138448. private _resizeObserver;
  138449. private _hardwareScaleLevel;
  138450. private _bloomKernel;
  138451. /**
  138452. * Specifies the size of the bloom blur kernel, relative to the final output size
  138453. */
  138454. get bloomKernel(): number;
  138455. set bloomKernel(value: number);
  138456. /**
  138457. * Specifies the weight of the bloom in the final rendering
  138458. */
  138459. private _bloomWeight;
  138460. /**
  138461. * Specifies the luma threshold for the area that will be blurred by the bloom
  138462. */
  138463. private _bloomThreshold;
  138464. private _hdr;
  138465. /**
  138466. * The strength of the bloom.
  138467. */
  138468. set bloomWeight(value: number);
  138469. get bloomWeight(): number;
  138470. /**
  138471. * The strength of the bloom.
  138472. */
  138473. set bloomThreshold(value: number);
  138474. get bloomThreshold(): number;
  138475. /**
  138476. * The scale of the bloom, lower value will provide better performance.
  138477. */
  138478. set bloomScale(value: number);
  138479. get bloomScale(): number;
  138480. /**
  138481. * Enable or disable the bloom from the pipeline
  138482. */
  138483. set bloomEnabled(enabled: boolean);
  138484. get bloomEnabled(): boolean;
  138485. private _rebuildBloom;
  138486. /**
  138487. * If the depth of field is enabled.
  138488. */
  138489. get depthOfFieldEnabled(): boolean;
  138490. set depthOfFieldEnabled(enabled: boolean);
  138491. /**
  138492. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138493. */
  138494. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138495. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138496. /**
  138497. * If the anti aliasing is enabled.
  138498. */
  138499. set fxaaEnabled(enabled: boolean);
  138500. get fxaaEnabled(): boolean;
  138501. private _samples;
  138502. /**
  138503. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138504. */
  138505. set samples(sampleCount: number);
  138506. get samples(): number;
  138507. /**
  138508. * If image processing is enabled.
  138509. */
  138510. set imageProcessingEnabled(enabled: boolean);
  138511. get imageProcessingEnabled(): boolean;
  138512. /**
  138513. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138514. */
  138515. set glowLayerEnabled(enabled: boolean);
  138516. get glowLayerEnabled(): boolean;
  138517. /**
  138518. * Gets the glow layer (or null if not defined)
  138519. */
  138520. get glowLayer(): Nullable<GlowLayer>;
  138521. /**
  138522. * Enable or disable the chromaticAberration process from the pipeline
  138523. */
  138524. set chromaticAberrationEnabled(enabled: boolean);
  138525. get chromaticAberrationEnabled(): boolean;
  138526. /**
  138527. * Enable or disable the grain process from the pipeline
  138528. */
  138529. set grainEnabled(enabled: boolean);
  138530. get grainEnabled(): boolean;
  138531. /**
  138532. * @constructor
  138533. * @param name - The rendering pipeline name (default: "")
  138534. * @param hdr - If high dynamic range textures should be used (default: true)
  138535. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138536. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138537. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138538. */
  138539. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138540. /**
  138541. * Get the class name
  138542. * @returns "DefaultRenderingPipeline"
  138543. */
  138544. getClassName(): string;
  138545. /**
  138546. * Force the compilation of the entire pipeline.
  138547. */
  138548. prepare(): void;
  138549. private _hasCleared;
  138550. private _prevPostProcess;
  138551. private _prevPrevPostProcess;
  138552. private _setAutoClearAndTextureSharing;
  138553. private _depthOfFieldSceneObserver;
  138554. private _buildPipeline;
  138555. private _disposePostProcesses;
  138556. /**
  138557. * Adds a camera to the pipeline
  138558. * @param camera the camera to be added
  138559. */
  138560. addCamera(camera: Camera): void;
  138561. /**
  138562. * Removes a camera from the pipeline
  138563. * @param camera the camera to remove
  138564. */
  138565. removeCamera(camera: Camera): void;
  138566. /**
  138567. * Dispose of the pipeline and stop all post processes
  138568. */
  138569. dispose(): void;
  138570. /**
  138571. * Serialize the rendering pipeline (Used when exporting)
  138572. * @returns the serialized object
  138573. */
  138574. serialize(): any;
  138575. /**
  138576. * Parse the serialized pipeline
  138577. * @param source Source pipeline.
  138578. * @param scene The scene to load the pipeline to.
  138579. * @param rootUrl The URL of the serialized pipeline.
  138580. * @returns An instantiated pipeline from the serialized object.
  138581. */
  138582. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138583. }
  138584. }
  138585. declare module BABYLON {
  138586. /** @hidden */
  138587. export var lensHighlightsPixelShader: {
  138588. name: string;
  138589. shader: string;
  138590. };
  138591. }
  138592. declare module BABYLON {
  138593. /** @hidden */
  138594. export var depthOfFieldPixelShader: {
  138595. name: string;
  138596. shader: string;
  138597. };
  138598. }
  138599. declare module BABYLON {
  138600. /**
  138601. * BABYLON.JS Chromatic Aberration GLSL Shader
  138602. * Author: Olivier Guyot
  138603. * Separates very slightly R, G and B colors on the edges of the screen
  138604. * Inspired by Francois Tarlier & Martins Upitis
  138605. */
  138606. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138607. /**
  138608. * @ignore
  138609. * The chromatic aberration PostProcess id in the pipeline
  138610. */
  138611. LensChromaticAberrationEffect: string;
  138612. /**
  138613. * @ignore
  138614. * The highlights enhancing PostProcess id in the pipeline
  138615. */
  138616. HighlightsEnhancingEffect: string;
  138617. /**
  138618. * @ignore
  138619. * The depth-of-field PostProcess id in the pipeline
  138620. */
  138621. LensDepthOfFieldEffect: string;
  138622. private _scene;
  138623. private _depthTexture;
  138624. private _grainTexture;
  138625. private _chromaticAberrationPostProcess;
  138626. private _highlightsPostProcess;
  138627. private _depthOfFieldPostProcess;
  138628. private _edgeBlur;
  138629. private _grainAmount;
  138630. private _chromaticAberration;
  138631. private _distortion;
  138632. private _highlightsGain;
  138633. private _highlightsThreshold;
  138634. private _dofDistance;
  138635. private _dofAperture;
  138636. private _dofDarken;
  138637. private _dofPentagon;
  138638. private _blurNoise;
  138639. /**
  138640. * @constructor
  138641. *
  138642. * Effect parameters are as follow:
  138643. * {
  138644. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138645. * edge_blur: number; // from 0 to x (1 for realism)
  138646. * distortion: number; // from 0 to x (1 for realism)
  138647. * grain_amount: number; // from 0 to 1
  138648. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138649. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138650. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138651. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138652. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138653. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138654. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138655. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138656. * }
  138657. * Note: if an effect parameter is unset, effect is disabled
  138658. *
  138659. * @param name The rendering pipeline name
  138660. * @param parameters - An object containing all parameters (see above)
  138661. * @param scene The scene linked to this pipeline
  138662. * @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)
  138663. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138664. */
  138665. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138666. /**
  138667. * Get the class name
  138668. * @returns "LensRenderingPipeline"
  138669. */
  138670. getClassName(): string;
  138671. /**
  138672. * Gets associated scene
  138673. */
  138674. get scene(): Scene;
  138675. /**
  138676. * Gets or sets the edge blur
  138677. */
  138678. get edgeBlur(): number;
  138679. set edgeBlur(value: number);
  138680. /**
  138681. * Gets or sets the grain amount
  138682. */
  138683. get grainAmount(): number;
  138684. set grainAmount(value: number);
  138685. /**
  138686. * Gets or sets the chromatic aberration amount
  138687. */
  138688. get chromaticAberration(): number;
  138689. set chromaticAberration(value: number);
  138690. /**
  138691. * Gets or sets the depth of field aperture
  138692. */
  138693. get dofAperture(): number;
  138694. set dofAperture(value: number);
  138695. /**
  138696. * Gets or sets the edge distortion
  138697. */
  138698. get edgeDistortion(): number;
  138699. set edgeDistortion(value: number);
  138700. /**
  138701. * Gets or sets the depth of field distortion
  138702. */
  138703. get dofDistortion(): number;
  138704. set dofDistortion(value: number);
  138705. /**
  138706. * Gets or sets the darken out of focus amount
  138707. */
  138708. get darkenOutOfFocus(): number;
  138709. set darkenOutOfFocus(value: number);
  138710. /**
  138711. * Gets or sets a boolean indicating if blur noise is enabled
  138712. */
  138713. get blurNoise(): boolean;
  138714. set blurNoise(value: boolean);
  138715. /**
  138716. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138717. */
  138718. get pentagonBokeh(): boolean;
  138719. set pentagonBokeh(value: boolean);
  138720. /**
  138721. * Gets or sets the highlight grain amount
  138722. */
  138723. get highlightsGain(): number;
  138724. set highlightsGain(value: number);
  138725. /**
  138726. * Gets or sets the highlight threshold
  138727. */
  138728. get highlightsThreshold(): number;
  138729. set highlightsThreshold(value: number);
  138730. /**
  138731. * Sets the amount of blur at the edges
  138732. * @param amount blur amount
  138733. */
  138734. setEdgeBlur(amount: number): void;
  138735. /**
  138736. * Sets edge blur to 0
  138737. */
  138738. disableEdgeBlur(): void;
  138739. /**
  138740. * Sets the amout of grain
  138741. * @param amount Amount of grain
  138742. */
  138743. setGrainAmount(amount: number): void;
  138744. /**
  138745. * Set grain amount to 0
  138746. */
  138747. disableGrain(): void;
  138748. /**
  138749. * Sets the chromatic aberration amount
  138750. * @param amount amount of chromatic aberration
  138751. */
  138752. setChromaticAberration(amount: number): void;
  138753. /**
  138754. * Sets chromatic aberration amount to 0
  138755. */
  138756. disableChromaticAberration(): void;
  138757. /**
  138758. * Sets the EdgeDistortion amount
  138759. * @param amount amount of EdgeDistortion
  138760. */
  138761. setEdgeDistortion(amount: number): void;
  138762. /**
  138763. * Sets edge distortion to 0
  138764. */
  138765. disableEdgeDistortion(): void;
  138766. /**
  138767. * Sets the FocusDistance amount
  138768. * @param amount amount of FocusDistance
  138769. */
  138770. setFocusDistance(amount: number): void;
  138771. /**
  138772. * Disables depth of field
  138773. */
  138774. disableDepthOfField(): void;
  138775. /**
  138776. * Sets the Aperture amount
  138777. * @param amount amount of Aperture
  138778. */
  138779. setAperture(amount: number): void;
  138780. /**
  138781. * Sets the DarkenOutOfFocus amount
  138782. * @param amount amount of DarkenOutOfFocus
  138783. */
  138784. setDarkenOutOfFocus(amount: number): void;
  138785. private _pentagonBokehIsEnabled;
  138786. /**
  138787. * Creates a pentagon bokeh effect
  138788. */
  138789. enablePentagonBokeh(): void;
  138790. /**
  138791. * Disables the pentagon bokeh effect
  138792. */
  138793. disablePentagonBokeh(): void;
  138794. /**
  138795. * Enables noise blur
  138796. */
  138797. enableNoiseBlur(): void;
  138798. /**
  138799. * Disables noise blur
  138800. */
  138801. disableNoiseBlur(): void;
  138802. /**
  138803. * Sets the HighlightsGain amount
  138804. * @param amount amount of HighlightsGain
  138805. */
  138806. setHighlightsGain(amount: number): void;
  138807. /**
  138808. * Sets the HighlightsThreshold amount
  138809. * @param amount amount of HighlightsThreshold
  138810. */
  138811. setHighlightsThreshold(amount: number): void;
  138812. /**
  138813. * Disables highlights
  138814. */
  138815. disableHighlights(): void;
  138816. /**
  138817. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138818. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138819. */
  138820. dispose(disableDepthRender?: boolean): void;
  138821. private _createChromaticAberrationPostProcess;
  138822. private _createHighlightsPostProcess;
  138823. private _createDepthOfFieldPostProcess;
  138824. private _createGrainTexture;
  138825. }
  138826. }
  138827. declare module BABYLON {
  138828. /** @hidden */
  138829. export var ssao2PixelShader: {
  138830. name: string;
  138831. shader: string;
  138832. };
  138833. }
  138834. declare module BABYLON {
  138835. /** @hidden */
  138836. export var ssaoCombinePixelShader: {
  138837. name: string;
  138838. shader: string;
  138839. };
  138840. }
  138841. declare module BABYLON {
  138842. /**
  138843. * Render pipeline to produce ssao effect
  138844. */
  138845. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138846. /**
  138847. * @ignore
  138848. * The PassPostProcess id in the pipeline that contains the original scene color
  138849. */
  138850. SSAOOriginalSceneColorEffect: string;
  138851. /**
  138852. * @ignore
  138853. * The SSAO PostProcess id in the pipeline
  138854. */
  138855. SSAORenderEffect: string;
  138856. /**
  138857. * @ignore
  138858. * The horizontal blur PostProcess id in the pipeline
  138859. */
  138860. SSAOBlurHRenderEffect: string;
  138861. /**
  138862. * @ignore
  138863. * The vertical blur PostProcess id in the pipeline
  138864. */
  138865. SSAOBlurVRenderEffect: string;
  138866. /**
  138867. * @ignore
  138868. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138869. */
  138870. SSAOCombineRenderEffect: string;
  138871. /**
  138872. * The output strength of the SSAO post-process. Default value is 1.0.
  138873. */
  138874. totalStrength: number;
  138875. /**
  138876. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138877. */
  138878. maxZ: number;
  138879. /**
  138880. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138881. */
  138882. minZAspect: number;
  138883. private _samples;
  138884. /**
  138885. * Number of samples used for the SSAO calculations. Default value is 8
  138886. */
  138887. set samples(n: number);
  138888. get samples(): number;
  138889. private _textureSamples;
  138890. /**
  138891. * Number of samples to use for antialiasing
  138892. */
  138893. set textureSamples(n: number);
  138894. get textureSamples(): number;
  138895. /**
  138896. * Ratio object used for SSAO ratio and blur ratio
  138897. */
  138898. private _ratio;
  138899. /**
  138900. * Dynamically generated sphere sampler.
  138901. */
  138902. private _sampleSphere;
  138903. /**
  138904. * Blur filter offsets
  138905. */
  138906. private _samplerOffsets;
  138907. private _expensiveBlur;
  138908. /**
  138909. * If bilateral blur should be used
  138910. */
  138911. set expensiveBlur(b: boolean);
  138912. get expensiveBlur(): boolean;
  138913. /**
  138914. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138915. */
  138916. radius: number;
  138917. /**
  138918. * The base color of the SSAO post-process
  138919. * The final result is "base + ssao" between [0, 1]
  138920. */
  138921. base: number;
  138922. /**
  138923. * Support test.
  138924. */
  138925. static get IsSupported(): boolean;
  138926. private _scene;
  138927. private _depthTexture;
  138928. private _normalTexture;
  138929. private _randomTexture;
  138930. private _originalColorPostProcess;
  138931. private _ssaoPostProcess;
  138932. private _blurHPostProcess;
  138933. private _blurVPostProcess;
  138934. private _ssaoCombinePostProcess;
  138935. /**
  138936. * Gets active scene
  138937. */
  138938. get scene(): Scene;
  138939. /**
  138940. * @constructor
  138941. * @param name The rendering pipeline name
  138942. * @param scene The scene linked to this pipeline
  138943. * @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 }
  138944. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138945. */
  138946. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138947. /**
  138948. * Get the class name
  138949. * @returns "SSAO2RenderingPipeline"
  138950. */
  138951. getClassName(): string;
  138952. /**
  138953. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138954. */
  138955. dispose(disableGeometryBufferRenderer?: boolean): void;
  138956. private _createBlurPostProcess;
  138957. /** @hidden */
  138958. _rebuild(): void;
  138959. private _bits;
  138960. private _radicalInverse_VdC;
  138961. private _hammersley;
  138962. private _hemisphereSample_uniform;
  138963. private _generateHemisphere;
  138964. private _createSSAOPostProcess;
  138965. private _createSSAOCombinePostProcess;
  138966. private _createRandomTexture;
  138967. /**
  138968. * Serialize the rendering pipeline (Used when exporting)
  138969. * @returns the serialized object
  138970. */
  138971. serialize(): any;
  138972. /**
  138973. * Parse the serialized pipeline
  138974. * @param source Source pipeline.
  138975. * @param scene The scene to load the pipeline to.
  138976. * @param rootUrl The URL of the serialized pipeline.
  138977. * @returns An instantiated pipeline from the serialized object.
  138978. */
  138979. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138980. }
  138981. }
  138982. declare module BABYLON {
  138983. /** @hidden */
  138984. export var ssaoPixelShader: {
  138985. name: string;
  138986. shader: string;
  138987. };
  138988. }
  138989. declare module BABYLON {
  138990. /**
  138991. * Render pipeline to produce ssao effect
  138992. */
  138993. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138994. /**
  138995. * @ignore
  138996. * The PassPostProcess id in the pipeline that contains the original scene color
  138997. */
  138998. SSAOOriginalSceneColorEffect: string;
  138999. /**
  139000. * @ignore
  139001. * The SSAO PostProcess id in the pipeline
  139002. */
  139003. SSAORenderEffect: string;
  139004. /**
  139005. * @ignore
  139006. * The horizontal blur PostProcess id in the pipeline
  139007. */
  139008. SSAOBlurHRenderEffect: string;
  139009. /**
  139010. * @ignore
  139011. * The vertical blur PostProcess id in the pipeline
  139012. */
  139013. SSAOBlurVRenderEffect: string;
  139014. /**
  139015. * @ignore
  139016. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139017. */
  139018. SSAOCombineRenderEffect: string;
  139019. /**
  139020. * The output strength of the SSAO post-process. Default value is 1.0.
  139021. */
  139022. totalStrength: number;
  139023. /**
  139024. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139025. */
  139026. radius: number;
  139027. /**
  139028. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139029. * Must not be equal to fallOff and superior to fallOff.
  139030. * Default value is 0.0075
  139031. */
  139032. area: number;
  139033. /**
  139034. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139035. * Must not be equal to area and inferior to area.
  139036. * Default value is 0.000001
  139037. */
  139038. fallOff: number;
  139039. /**
  139040. * The base color of the SSAO post-process
  139041. * The final result is "base + ssao" between [0, 1]
  139042. */
  139043. base: number;
  139044. private _scene;
  139045. private _depthTexture;
  139046. private _randomTexture;
  139047. private _originalColorPostProcess;
  139048. private _ssaoPostProcess;
  139049. private _blurHPostProcess;
  139050. private _blurVPostProcess;
  139051. private _ssaoCombinePostProcess;
  139052. private _firstUpdate;
  139053. /**
  139054. * Gets active scene
  139055. */
  139056. get scene(): Scene;
  139057. /**
  139058. * @constructor
  139059. * @param name - The rendering pipeline name
  139060. * @param scene - The scene linked to this pipeline
  139061. * @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 }
  139062. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139063. */
  139064. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139065. /**
  139066. * Get the class name
  139067. * @returns "SSAORenderingPipeline"
  139068. */
  139069. getClassName(): string;
  139070. /**
  139071. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139072. */
  139073. dispose(disableDepthRender?: boolean): void;
  139074. private _createBlurPostProcess;
  139075. /** @hidden */
  139076. _rebuild(): void;
  139077. private _createSSAOPostProcess;
  139078. private _createSSAOCombinePostProcess;
  139079. private _createRandomTexture;
  139080. }
  139081. }
  139082. declare module BABYLON {
  139083. /** @hidden */
  139084. export var screenSpaceReflectionPixelShader: {
  139085. name: string;
  139086. shader: string;
  139087. };
  139088. }
  139089. declare module BABYLON {
  139090. /**
  139091. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139092. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139093. */
  139094. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139095. /**
  139096. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139097. */
  139098. threshold: number;
  139099. /**
  139100. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139101. */
  139102. strength: number;
  139103. /**
  139104. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139105. */
  139106. reflectionSpecularFalloffExponent: number;
  139107. /**
  139108. * 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]
  139109. */
  139110. step: number;
  139111. /**
  139112. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139113. */
  139114. roughnessFactor: number;
  139115. private _geometryBufferRenderer;
  139116. private _enableSmoothReflections;
  139117. private _reflectionSamples;
  139118. private _smoothSteps;
  139119. /**
  139120. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139121. * @param name The name of the effect.
  139122. * @param scene The scene containing the objects to calculate reflections.
  139123. * @param options The required width/height ratio to downsize to before computing the render pass.
  139124. * @param camera The camera to apply the render pass to.
  139125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139126. * @param engine The engine which the post process will be applied. (default: current engine)
  139127. * @param reusable If the post process can be reused on the same frame. (default: false)
  139128. * @param textureType Type of textures used when performing the post process. (default: 0)
  139129. * @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)
  139130. */
  139131. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139132. /**
  139133. * Gets wether or not smoothing reflections is enabled.
  139134. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139135. */
  139136. get enableSmoothReflections(): boolean;
  139137. /**
  139138. * Sets wether or not smoothing reflections is enabled.
  139139. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139140. */
  139141. set enableSmoothReflections(enabled: boolean);
  139142. /**
  139143. * Gets the number of samples taken while computing reflections. More samples count is high,
  139144. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139145. */
  139146. get reflectionSamples(): number;
  139147. /**
  139148. * Sets the number of samples taken while computing reflections. More samples count is high,
  139149. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139150. */
  139151. set reflectionSamples(samples: number);
  139152. /**
  139153. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139154. * more the post-process will require GPU power and can generate a drop in FPS.
  139155. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139156. */
  139157. get smoothSteps(): number;
  139158. set smoothSteps(steps: number);
  139159. private _updateEffectDefines;
  139160. }
  139161. }
  139162. declare module BABYLON {
  139163. /** @hidden */
  139164. export var standardPixelShader: {
  139165. name: string;
  139166. shader: string;
  139167. };
  139168. }
  139169. declare module BABYLON {
  139170. /**
  139171. * Standard rendering pipeline
  139172. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139173. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139174. */
  139175. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139176. /**
  139177. * Public members
  139178. */
  139179. /**
  139180. * Post-process which contains the original scene color before the pipeline applies all the effects
  139181. */
  139182. originalPostProcess: Nullable<PostProcess>;
  139183. /**
  139184. * Post-process used to down scale an image x4
  139185. */
  139186. downSampleX4PostProcess: Nullable<PostProcess>;
  139187. /**
  139188. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139189. */
  139190. brightPassPostProcess: Nullable<PostProcess>;
  139191. /**
  139192. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139193. */
  139194. blurHPostProcesses: PostProcess[];
  139195. /**
  139196. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139197. */
  139198. blurVPostProcesses: PostProcess[];
  139199. /**
  139200. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139201. */
  139202. textureAdderPostProcess: Nullable<PostProcess>;
  139203. /**
  139204. * Post-process used to create volumetric lighting effect
  139205. */
  139206. volumetricLightPostProcess: Nullable<PostProcess>;
  139207. /**
  139208. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139209. */
  139210. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139211. /**
  139212. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139213. */
  139214. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139215. /**
  139216. * Post-process used to merge the volumetric light effect and the real scene color
  139217. */
  139218. volumetricLightMergePostProces: Nullable<PostProcess>;
  139219. /**
  139220. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139221. */
  139222. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139223. /**
  139224. * Base post-process used to calculate the average luminance of the final image for HDR
  139225. */
  139226. luminancePostProcess: Nullable<PostProcess>;
  139227. /**
  139228. * Post-processes used to create down sample post-processes in order to get
  139229. * the average luminance of the final image for HDR
  139230. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139231. */
  139232. luminanceDownSamplePostProcesses: PostProcess[];
  139233. /**
  139234. * Post-process used to create a HDR effect (light adaptation)
  139235. */
  139236. hdrPostProcess: Nullable<PostProcess>;
  139237. /**
  139238. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139239. */
  139240. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139241. /**
  139242. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139243. */
  139244. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139245. /**
  139246. * Post-process used to merge the final HDR post-process and the real scene color
  139247. */
  139248. hdrFinalPostProcess: Nullable<PostProcess>;
  139249. /**
  139250. * Post-process used to create a lens flare effect
  139251. */
  139252. lensFlarePostProcess: Nullable<PostProcess>;
  139253. /**
  139254. * Post-process that merges the result of the lens flare post-process and the real scene color
  139255. */
  139256. lensFlareComposePostProcess: Nullable<PostProcess>;
  139257. /**
  139258. * Post-process used to create a motion blur effect
  139259. */
  139260. motionBlurPostProcess: Nullable<PostProcess>;
  139261. /**
  139262. * Post-process used to create a depth of field effect
  139263. */
  139264. depthOfFieldPostProcess: Nullable<PostProcess>;
  139265. /**
  139266. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139267. */
  139268. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139269. /**
  139270. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139271. */
  139272. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139273. /**
  139274. * Represents the brightness threshold in order to configure the illuminated surfaces
  139275. */
  139276. brightThreshold: number;
  139277. /**
  139278. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139279. */
  139280. blurWidth: number;
  139281. /**
  139282. * Sets if the blur for highlighted surfaces must be only horizontal
  139283. */
  139284. horizontalBlur: boolean;
  139285. /**
  139286. * Gets the overall exposure used by the pipeline
  139287. */
  139288. get exposure(): number;
  139289. /**
  139290. * Sets the overall exposure used by the pipeline
  139291. */
  139292. set exposure(value: number);
  139293. /**
  139294. * Texture used typically to simulate "dirty" on camera lens
  139295. */
  139296. lensTexture: Nullable<Texture>;
  139297. /**
  139298. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139299. */
  139300. volumetricLightCoefficient: number;
  139301. /**
  139302. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139303. */
  139304. volumetricLightPower: number;
  139305. /**
  139306. * Used the set the blur intensity to smooth the volumetric lights
  139307. */
  139308. volumetricLightBlurScale: number;
  139309. /**
  139310. * Light (spot or directional) used to generate the volumetric lights rays
  139311. * The source light must have a shadow generate so the pipeline can get its
  139312. * depth map
  139313. */
  139314. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139315. /**
  139316. * For eye adaptation, represents the minimum luminance the eye can see
  139317. */
  139318. hdrMinimumLuminance: number;
  139319. /**
  139320. * For eye adaptation, represents the decrease luminance speed
  139321. */
  139322. hdrDecreaseRate: number;
  139323. /**
  139324. * For eye adaptation, represents the increase luminance speed
  139325. */
  139326. hdrIncreaseRate: number;
  139327. /**
  139328. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139329. */
  139330. get hdrAutoExposure(): boolean;
  139331. /**
  139332. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139333. */
  139334. set hdrAutoExposure(value: boolean);
  139335. /**
  139336. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139337. */
  139338. lensColorTexture: Nullable<Texture>;
  139339. /**
  139340. * The overall strengh for the lens flare effect
  139341. */
  139342. lensFlareStrength: number;
  139343. /**
  139344. * Dispersion coefficient for lens flare ghosts
  139345. */
  139346. lensFlareGhostDispersal: number;
  139347. /**
  139348. * Main lens flare halo width
  139349. */
  139350. lensFlareHaloWidth: number;
  139351. /**
  139352. * Based on the lens distortion effect, defines how much the lens flare result
  139353. * is distorted
  139354. */
  139355. lensFlareDistortionStrength: number;
  139356. /**
  139357. * Configures the blur intensity used for for lens flare (halo)
  139358. */
  139359. lensFlareBlurWidth: number;
  139360. /**
  139361. * Lens star texture must be used to simulate rays on the flares and is available
  139362. * in the documentation
  139363. */
  139364. lensStarTexture: Nullable<Texture>;
  139365. /**
  139366. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139367. * flare effect by taking account of the dirt texture
  139368. */
  139369. lensFlareDirtTexture: Nullable<Texture>;
  139370. /**
  139371. * Represents the focal length for the depth of field effect
  139372. */
  139373. depthOfFieldDistance: number;
  139374. /**
  139375. * Represents the blur intensity for the blurred part of the depth of field effect
  139376. */
  139377. depthOfFieldBlurWidth: number;
  139378. /**
  139379. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139380. */
  139381. get motionStrength(): number;
  139382. /**
  139383. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139384. */
  139385. set motionStrength(strength: number);
  139386. /**
  139387. * Gets wether or not the motion blur post-process is object based or screen based.
  139388. */
  139389. get objectBasedMotionBlur(): boolean;
  139390. /**
  139391. * Sets wether or not the motion blur post-process should be object based or screen based
  139392. */
  139393. set objectBasedMotionBlur(value: boolean);
  139394. /**
  139395. * List of animations for the pipeline (IAnimatable implementation)
  139396. */
  139397. animations: Animation[];
  139398. /**
  139399. * Private members
  139400. */
  139401. private _scene;
  139402. private _currentDepthOfFieldSource;
  139403. private _basePostProcess;
  139404. private _fixedExposure;
  139405. private _currentExposure;
  139406. private _hdrAutoExposure;
  139407. private _hdrCurrentLuminance;
  139408. private _motionStrength;
  139409. private _isObjectBasedMotionBlur;
  139410. private _floatTextureType;
  139411. private _camerasToBeAttached;
  139412. private _ratio;
  139413. private _bloomEnabled;
  139414. private _depthOfFieldEnabled;
  139415. private _vlsEnabled;
  139416. private _lensFlareEnabled;
  139417. private _hdrEnabled;
  139418. private _motionBlurEnabled;
  139419. private _fxaaEnabled;
  139420. private _screenSpaceReflectionsEnabled;
  139421. private _motionBlurSamples;
  139422. private _volumetricLightStepsCount;
  139423. private _samples;
  139424. /**
  139425. * @ignore
  139426. * Specifies if the bloom pipeline is enabled
  139427. */
  139428. get BloomEnabled(): boolean;
  139429. set BloomEnabled(enabled: boolean);
  139430. /**
  139431. * @ignore
  139432. * Specifies if the depth of field pipeline is enabed
  139433. */
  139434. get DepthOfFieldEnabled(): boolean;
  139435. set DepthOfFieldEnabled(enabled: boolean);
  139436. /**
  139437. * @ignore
  139438. * Specifies if the lens flare pipeline is enabed
  139439. */
  139440. get LensFlareEnabled(): boolean;
  139441. set LensFlareEnabled(enabled: boolean);
  139442. /**
  139443. * @ignore
  139444. * Specifies if the HDR pipeline is enabled
  139445. */
  139446. get HDREnabled(): boolean;
  139447. set HDREnabled(enabled: boolean);
  139448. /**
  139449. * @ignore
  139450. * Specifies if the volumetric lights scattering effect is enabled
  139451. */
  139452. get VLSEnabled(): boolean;
  139453. set VLSEnabled(enabled: boolean);
  139454. /**
  139455. * @ignore
  139456. * Specifies if the motion blur effect is enabled
  139457. */
  139458. get MotionBlurEnabled(): boolean;
  139459. set MotionBlurEnabled(enabled: boolean);
  139460. /**
  139461. * Specifies if anti-aliasing is enabled
  139462. */
  139463. get fxaaEnabled(): boolean;
  139464. set fxaaEnabled(enabled: boolean);
  139465. /**
  139466. * Specifies if screen space reflections are enabled.
  139467. */
  139468. get screenSpaceReflectionsEnabled(): boolean;
  139469. set screenSpaceReflectionsEnabled(enabled: boolean);
  139470. /**
  139471. * Specifies the number of steps used to calculate the volumetric lights
  139472. * Typically in interval [50, 200]
  139473. */
  139474. get volumetricLightStepsCount(): number;
  139475. set volumetricLightStepsCount(count: number);
  139476. /**
  139477. * Specifies the number of samples used for the motion blur effect
  139478. * Typically in interval [16, 64]
  139479. */
  139480. get motionBlurSamples(): number;
  139481. set motionBlurSamples(samples: number);
  139482. /**
  139483. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139484. */
  139485. get samples(): number;
  139486. set samples(sampleCount: number);
  139487. /**
  139488. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139489. * @constructor
  139490. * @param name The rendering pipeline name
  139491. * @param scene The scene linked to this pipeline
  139492. * @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)
  139493. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139494. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139495. */
  139496. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139497. private _buildPipeline;
  139498. private _createDownSampleX4PostProcess;
  139499. private _createBrightPassPostProcess;
  139500. private _createBlurPostProcesses;
  139501. private _createTextureAdderPostProcess;
  139502. private _createVolumetricLightPostProcess;
  139503. private _createLuminancePostProcesses;
  139504. private _createHdrPostProcess;
  139505. private _createLensFlarePostProcess;
  139506. private _createDepthOfFieldPostProcess;
  139507. private _createMotionBlurPostProcess;
  139508. private _getDepthTexture;
  139509. private _disposePostProcesses;
  139510. /**
  139511. * Dispose of the pipeline and stop all post processes
  139512. */
  139513. dispose(): void;
  139514. /**
  139515. * Serialize the rendering pipeline (Used when exporting)
  139516. * @returns the serialized object
  139517. */
  139518. serialize(): any;
  139519. /**
  139520. * Parse the serialized pipeline
  139521. * @param source Source pipeline.
  139522. * @param scene The scene to load the pipeline to.
  139523. * @param rootUrl The URL of the serialized pipeline.
  139524. * @returns An instantiated pipeline from the serialized object.
  139525. */
  139526. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139527. /**
  139528. * Luminance steps
  139529. */
  139530. static LuminanceSteps: number;
  139531. }
  139532. }
  139533. declare module BABYLON {
  139534. /** @hidden */
  139535. export var tonemapPixelShader: {
  139536. name: string;
  139537. shader: string;
  139538. };
  139539. }
  139540. declare module BABYLON {
  139541. /** Defines operator used for tonemapping */
  139542. export enum TonemappingOperator {
  139543. /** Hable */
  139544. Hable = 0,
  139545. /** Reinhard */
  139546. Reinhard = 1,
  139547. /** HejiDawson */
  139548. HejiDawson = 2,
  139549. /** Photographic */
  139550. Photographic = 3
  139551. }
  139552. /**
  139553. * Defines a post process to apply tone mapping
  139554. */
  139555. export class TonemapPostProcess extends PostProcess {
  139556. private _operator;
  139557. /** Defines the required exposure adjustement */
  139558. exposureAdjustment: number;
  139559. /**
  139560. * Creates a new TonemapPostProcess
  139561. * @param name defines the name of the postprocess
  139562. * @param _operator defines the operator to use
  139563. * @param exposureAdjustment defines the required exposure adjustement
  139564. * @param camera defines the camera to use (can be null)
  139565. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139566. * @param engine defines the hosting engine (can be ignore if camera is set)
  139567. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139568. */
  139569. constructor(name: string, _operator: TonemappingOperator,
  139570. /** Defines the required exposure adjustement */
  139571. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139572. }
  139573. }
  139574. declare module BABYLON {
  139575. /** @hidden */
  139576. export var volumetricLightScatteringPixelShader: {
  139577. name: string;
  139578. shader: string;
  139579. };
  139580. }
  139581. declare module BABYLON {
  139582. /** @hidden */
  139583. export var volumetricLightScatteringPassVertexShader: {
  139584. name: string;
  139585. shader: string;
  139586. };
  139587. }
  139588. declare module BABYLON {
  139589. /** @hidden */
  139590. export var volumetricLightScatteringPassPixelShader: {
  139591. name: string;
  139592. shader: string;
  139593. };
  139594. }
  139595. declare module BABYLON {
  139596. /**
  139597. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139598. */
  139599. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139600. private _volumetricLightScatteringPass;
  139601. private _volumetricLightScatteringRTT;
  139602. private _viewPort;
  139603. private _screenCoordinates;
  139604. private _cachedDefines;
  139605. /**
  139606. * If not undefined, the mesh position is computed from the attached node position
  139607. */
  139608. attachedNode: {
  139609. position: Vector3;
  139610. };
  139611. /**
  139612. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139613. */
  139614. customMeshPosition: Vector3;
  139615. /**
  139616. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139617. */
  139618. useCustomMeshPosition: boolean;
  139619. /**
  139620. * If the post-process should inverse the light scattering direction
  139621. */
  139622. invert: boolean;
  139623. /**
  139624. * The internal mesh used by the post-process
  139625. */
  139626. mesh: Mesh;
  139627. /**
  139628. * @hidden
  139629. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139630. */
  139631. get useDiffuseColor(): boolean;
  139632. set useDiffuseColor(useDiffuseColor: boolean);
  139633. /**
  139634. * Array containing the excluded meshes not rendered in the internal pass
  139635. */
  139636. excludedMeshes: AbstractMesh[];
  139637. /**
  139638. * Controls the overall intensity of the post-process
  139639. */
  139640. exposure: number;
  139641. /**
  139642. * Dissipates each sample's contribution in range [0, 1]
  139643. */
  139644. decay: number;
  139645. /**
  139646. * Controls the overall intensity of each sample
  139647. */
  139648. weight: number;
  139649. /**
  139650. * Controls the density of each sample
  139651. */
  139652. density: number;
  139653. /**
  139654. * @constructor
  139655. * @param name The post-process name
  139656. * @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)
  139657. * @param camera The camera that the post-process will be attached to
  139658. * @param mesh The mesh used to create the light scattering
  139659. * @param samples The post-process quality, default 100
  139660. * @param samplingModeThe post-process filtering mode
  139661. * @param engine The babylon engine
  139662. * @param reusable If the post-process is reusable
  139663. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139664. */
  139665. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139666. /**
  139667. * Returns the string "VolumetricLightScatteringPostProcess"
  139668. * @returns "VolumetricLightScatteringPostProcess"
  139669. */
  139670. getClassName(): string;
  139671. private _isReady;
  139672. /**
  139673. * Sets the new light position for light scattering effect
  139674. * @param position The new custom light position
  139675. */
  139676. setCustomMeshPosition(position: Vector3): void;
  139677. /**
  139678. * Returns the light position for light scattering effect
  139679. * @return Vector3 The custom light position
  139680. */
  139681. getCustomMeshPosition(): Vector3;
  139682. /**
  139683. * Disposes the internal assets and detaches the post-process from the camera
  139684. */
  139685. dispose(camera: Camera): void;
  139686. /**
  139687. * Returns the render target texture used by the post-process
  139688. * @return the render target texture used by the post-process
  139689. */
  139690. getPass(): RenderTargetTexture;
  139691. private _meshExcluded;
  139692. private _createPass;
  139693. private _updateMeshScreenCoordinates;
  139694. /**
  139695. * Creates a default mesh for the Volumeric Light Scattering post-process
  139696. * @param name The mesh name
  139697. * @param scene The scene where to create the mesh
  139698. * @return the default mesh
  139699. */
  139700. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139701. }
  139702. }
  139703. declare module BABYLON {
  139704. interface Scene {
  139705. /** @hidden (Backing field) */
  139706. _boundingBoxRenderer: BoundingBoxRenderer;
  139707. /** @hidden (Backing field) */
  139708. _forceShowBoundingBoxes: boolean;
  139709. /**
  139710. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139711. */
  139712. forceShowBoundingBoxes: boolean;
  139713. /**
  139714. * Gets the bounding box renderer associated with the scene
  139715. * @returns a BoundingBoxRenderer
  139716. */
  139717. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139718. }
  139719. interface AbstractMesh {
  139720. /** @hidden (Backing field) */
  139721. _showBoundingBox: boolean;
  139722. /**
  139723. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139724. */
  139725. showBoundingBox: boolean;
  139726. }
  139727. /**
  139728. * Component responsible of rendering the bounding box of the meshes in a scene.
  139729. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139730. */
  139731. export class BoundingBoxRenderer implements ISceneComponent {
  139732. /**
  139733. * The component name helpfull to identify the component in the list of scene components.
  139734. */
  139735. readonly name: string;
  139736. /**
  139737. * The scene the component belongs to.
  139738. */
  139739. scene: Scene;
  139740. /**
  139741. * Color of the bounding box lines placed in front of an object
  139742. */
  139743. frontColor: Color3;
  139744. /**
  139745. * Color of the bounding box lines placed behind an object
  139746. */
  139747. backColor: Color3;
  139748. /**
  139749. * Defines if the renderer should show the back lines or not
  139750. */
  139751. showBackLines: boolean;
  139752. /**
  139753. * @hidden
  139754. */
  139755. renderList: SmartArray<BoundingBox>;
  139756. private _colorShader;
  139757. private _vertexBuffers;
  139758. private _indexBuffer;
  139759. private _fillIndexBuffer;
  139760. private _fillIndexData;
  139761. /**
  139762. * Instantiates a new bounding box renderer in a scene.
  139763. * @param scene the scene the renderer renders in
  139764. */
  139765. constructor(scene: Scene);
  139766. /**
  139767. * Registers the component in a given scene
  139768. */
  139769. register(): void;
  139770. private _evaluateSubMesh;
  139771. private _activeMesh;
  139772. private _prepareRessources;
  139773. private _createIndexBuffer;
  139774. /**
  139775. * Rebuilds the elements related to this component in case of
  139776. * context lost for instance.
  139777. */
  139778. rebuild(): void;
  139779. /**
  139780. * @hidden
  139781. */
  139782. reset(): void;
  139783. /**
  139784. * Render the bounding boxes of a specific rendering group
  139785. * @param renderingGroupId defines the rendering group to render
  139786. */
  139787. render(renderingGroupId: number): void;
  139788. /**
  139789. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139790. * @param mesh Define the mesh to render the occlusion bounding box for
  139791. */
  139792. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139793. /**
  139794. * Dispose and release the resources attached to this renderer.
  139795. */
  139796. dispose(): void;
  139797. }
  139798. }
  139799. declare module BABYLON {
  139800. interface Scene {
  139801. /** @hidden (Backing field) */
  139802. _depthRenderer: {
  139803. [id: string]: DepthRenderer;
  139804. };
  139805. /**
  139806. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139807. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139808. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139809. * @returns the created depth renderer
  139810. */
  139811. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139812. /**
  139813. * Disables a depth renderer for a given camera
  139814. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139815. */
  139816. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139817. }
  139818. /**
  139819. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139820. * in several rendering techniques.
  139821. */
  139822. export class DepthRendererSceneComponent implements ISceneComponent {
  139823. /**
  139824. * The component name helpfull to identify the component in the list of scene components.
  139825. */
  139826. readonly name: string;
  139827. /**
  139828. * The scene the component belongs to.
  139829. */
  139830. scene: Scene;
  139831. /**
  139832. * Creates a new instance of the component for the given scene
  139833. * @param scene Defines the scene to register the component in
  139834. */
  139835. constructor(scene: Scene);
  139836. /**
  139837. * Registers the component in a given scene
  139838. */
  139839. register(): void;
  139840. /**
  139841. * Rebuilds the elements related to this component in case of
  139842. * context lost for instance.
  139843. */
  139844. rebuild(): void;
  139845. /**
  139846. * Disposes the component and the associated ressources
  139847. */
  139848. dispose(): void;
  139849. private _gatherRenderTargets;
  139850. private _gatherActiveCameraRenderTargets;
  139851. }
  139852. }
  139853. declare module BABYLON {
  139854. /** @hidden */
  139855. export var outlinePixelShader: {
  139856. name: string;
  139857. shader: string;
  139858. };
  139859. }
  139860. declare module BABYLON {
  139861. /** @hidden */
  139862. export var outlineVertexShader: {
  139863. name: string;
  139864. shader: string;
  139865. };
  139866. }
  139867. declare module BABYLON {
  139868. interface Scene {
  139869. /** @hidden */
  139870. _outlineRenderer: OutlineRenderer;
  139871. /**
  139872. * Gets the outline renderer associated with the scene
  139873. * @returns a OutlineRenderer
  139874. */
  139875. getOutlineRenderer(): OutlineRenderer;
  139876. }
  139877. interface AbstractMesh {
  139878. /** @hidden (Backing field) */
  139879. _renderOutline: boolean;
  139880. /**
  139881. * Gets or sets a boolean indicating if the outline must be rendered as well
  139882. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139883. */
  139884. renderOutline: boolean;
  139885. /** @hidden (Backing field) */
  139886. _renderOverlay: boolean;
  139887. /**
  139888. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139889. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139890. */
  139891. renderOverlay: boolean;
  139892. }
  139893. /**
  139894. * This class is responsible to draw bothe outline/overlay of meshes.
  139895. * It should not be used directly but through the available method on mesh.
  139896. */
  139897. export class OutlineRenderer implements ISceneComponent {
  139898. /**
  139899. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139900. */
  139901. private static _StencilReference;
  139902. /**
  139903. * The name of the component. Each component must have a unique name.
  139904. */
  139905. name: string;
  139906. /**
  139907. * The scene the component belongs to.
  139908. */
  139909. scene: Scene;
  139910. /**
  139911. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139912. */
  139913. zOffset: number;
  139914. private _engine;
  139915. private _effect;
  139916. private _cachedDefines;
  139917. private _savedDepthWrite;
  139918. /**
  139919. * Instantiates a new outline renderer. (There could be only one per scene).
  139920. * @param scene Defines the scene it belongs to
  139921. */
  139922. constructor(scene: Scene);
  139923. /**
  139924. * Register the component to one instance of a scene.
  139925. */
  139926. register(): void;
  139927. /**
  139928. * Rebuilds the elements related to this component in case of
  139929. * context lost for instance.
  139930. */
  139931. rebuild(): void;
  139932. /**
  139933. * Disposes the component and the associated ressources.
  139934. */
  139935. dispose(): void;
  139936. /**
  139937. * Renders the outline in the canvas.
  139938. * @param subMesh Defines the sumesh to render
  139939. * @param batch Defines the batch of meshes in case of instances
  139940. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139941. */
  139942. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139943. /**
  139944. * Returns whether or not the outline renderer is ready for a given submesh.
  139945. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139946. * @param subMesh Defines the submesh to check readyness for
  139947. * @param useInstances Defines wheter wee are trying to render instances or not
  139948. * @returns true if ready otherwise false
  139949. */
  139950. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139951. private _beforeRenderingMesh;
  139952. private _afterRenderingMesh;
  139953. }
  139954. }
  139955. declare module BABYLON {
  139956. /**
  139957. * Defines the basic options interface of a Sprite Frame Source Size.
  139958. */
  139959. export interface ISpriteJSONSpriteSourceSize {
  139960. /**
  139961. * number of the original width of the Frame
  139962. */
  139963. w: number;
  139964. /**
  139965. * number of the original height of the Frame
  139966. */
  139967. h: number;
  139968. }
  139969. /**
  139970. * Defines the basic options interface of a Sprite Frame Data.
  139971. */
  139972. export interface ISpriteJSONSpriteFrameData {
  139973. /**
  139974. * number of the x offset of the Frame
  139975. */
  139976. x: number;
  139977. /**
  139978. * number of the y offset of the Frame
  139979. */
  139980. y: number;
  139981. /**
  139982. * number of the width of the Frame
  139983. */
  139984. w: number;
  139985. /**
  139986. * number of the height of the Frame
  139987. */
  139988. h: number;
  139989. }
  139990. /**
  139991. * Defines the basic options interface of a JSON Sprite.
  139992. */
  139993. export interface ISpriteJSONSprite {
  139994. /**
  139995. * string name of the Frame
  139996. */
  139997. filename: string;
  139998. /**
  139999. * ISpriteJSONSpriteFrame basic object of the frame data
  140000. */
  140001. frame: ISpriteJSONSpriteFrameData;
  140002. /**
  140003. * boolean to flag is the frame was rotated.
  140004. */
  140005. rotated: boolean;
  140006. /**
  140007. * boolean to flag is the frame was trimmed.
  140008. */
  140009. trimmed: boolean;
  140010. /**
  140011. * ISpriteJSONSpriteFrame basic object of the source data
  140012. */
  140013. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140014. /**
  140015. * ISpriteJSONSpriteFrame basic object of the source data
  140016. */
  140017. sourceSize: ISpriteJSONSpriteSourceSize;
  140018. }
  140019. /**
  140020. * Defines the basic options interface of a JSON atlas.
  140021. */
  140022. export interface ISpriteJSONAtlas {
  140023. /**
  140024. * Array of objects that contain the frame data.
  140025. */
  140026. frames: Array<ISpriteJSONSprite>;
  140027. /**
  140028. * object basic object containing the sprite meta data.
  140029. */
  140030. meta?: object;
  140031. }
  140032. }
  140033. declare module BABYLON {
  140034. /** @hidden */
  140035. export var spriteMapPixelShader: {
  140036. name: string;
  140037. shader: string;
  140038. };
  140039. }
  140040. declare module BABYLON {
  140041. /** @hidden */
  140042. export var spriteMapVertexShader: {
  140043. name: string;
  140044. shader: string;
  140045. };
  140046. }
  140047. declare module BABYLON {
  140048. /**
  140049. * Defines the basic options interface of a SpriteMap
  140050. */
  140051. export interface ISpriteMapOptions {
  140052. /**
  140053. * Vector2 of the number of cells in the grid.
  140054. */
  140055. stageSize?: Vector2;
  140056. /**
  140057. * Vector2 of the size of the output plane in World Units.
  140058. */
  140059. outputSize?: Vector2;
  140060. /**
  140061. * Vector3 of the position of the output plane in World Units.
  140062. */
  140063. outputPosition?: Vector3;
  140064. /**
  140065. * Vector3 of the rotation of the output plane.
  140066. */
  140067. outputRotation?: Vector3;
  140068. /**
  140069. * number of layers that the system will reserve in resources.
  140070. */
  140071. layerCount?: number;
  140072. /**
  140073. * number of max animation frames a single cell will reserve in resources.
  140074. */
  140075. maxAnimationFrames?: number;
  140076. /**
  140077. * number cell index of the base tile when the system compiles.
  140078. */
  140079. baseTile?: number;
  140080. /**
  140081. * boolean flip the sprite after its been repositioned by the framing data.
  140082. */
  140083. flipU?: boolean;
  140084. /**
  140085. * Vector3 scalar of the global RGB values of the SpriteMap.
  140086. */
  140087. colorMultiply?: Vector3;
  140088. }
  140089. /**
  140090. * Defines the IDisposable interface in order to be cleanable from resources.
  140091. */
  140092. export interface ISpriteMap extends IDisposable {
  140093. /**
  140094. * String name of the SpriteMap.
  140095. */
  140096. name: string;
  140097. /**
  140098. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140099. */
  140100. atlasJSON: ISpriteJSONAtlas;
  140101. /**
  140102. * Texture of the SpriteMap.
  140103. */
  140104. spriteSheet: Texture;
  140105. /**
  140106. * The parameters to initialize the SpriteMap with.
  140107. */
  140108. options: ISpriteMapOptions;
  140109. }
  140110. /**
  140111. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140112. */
  140113. export class SpriteMap implements ISpriteMap {
  140114. /** The Name of the spriteMap */
  140115. name: string;
  140116. /** The JSON file with the frame and meta data */
  140117. atlasJSON: ISpriteJSONAtlas;
  140118. /** The systems Sprite Sheet Texture */
  140119. spriteSheet: Texture;
  140120. /** Arguments passed with the Constructor */
  140121. options: ISpriteMapOptions;
  140122. /** Public Sprite Storage array, parsed from atlasJSON */
  140123. sprites: Array<ISpriteJSONSprite>;
  140124. /** Returns the Number of Sprites in the System */
  140125. get spriteCount(): number;
  140126. /** Returns the Position of Output Plane*/
  140127. get position(): Vector3;
  140128. /** Returns the Position of Output Plane*/
  140129. set position(v: Vector3);
  140130. /** Returns the Rotation of Output Plane*/
  140131. get rotation(): Vector3;
  140132. /** Returns the Rotation of Output Plane*/
  140133. set rotation(v: Vector3);
  140134. /** Sets the AnimationMap*/
  140135. get animationMap(): RawTexture;
  140136. /** Sets the AnimationMap*/
  140137. set animationMap(v: RawTexture);
  140138. /** Scene that the SpriteMap was created in */
  140139. private _scene;
  140140. /** Texture Buffer of Float32 that holds tile frame data*/
  140141. private _frameMap;
  140142. /** Texture Buffers of Float32 that holds tileMap data*/
  140143. private _tileMaps;
  140144. /** Texture Buffer of Float32 that holds Animation Data*/
  140145. private _animationMap;
  140146. /** Custom ShaderMaterial Central to the System*/
  140147. private _material;
  140148. /** Custom ShaderMaterial Central to the System*/
  140149. private _output;
  140150. /** Systems Time Ticker*/
  140151. private _time;
  140152. /**
  140153. * Creates a new SpriteMap
  140154. * @param name defines the SpriteMaps Name
  140155. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140156. * @param spriteSheet is the Texture that the Sprites are on.
  140157. * @param options a basic deployment configuration
  140158. * @param scene The Scene that the map is deployed on
  140159. */
  140160. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140161. /**
  140162. * Returns tileID location
  140163. * @returns Vector2 the cell position ID
  140164. */
  140165. getTileID(): Vector2;
  140166. /**
  140167. * Gets the UV location of the mouse over the SpriteMap.
  140168. * @returns Vector2 the UV position of the mouse interaction
  140169. */
  140170. getMousePosition(): Vector2;
  140171. /**
  140172. * Creates the "frame" texture Buffer
  140173. * -------------------------------------
  140174. * Structure of frames
  140175. * "filename": "Falling-Water-2.png",
  140176. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140177. * "rotated": true,
  140178. * "trimmed": true,
  140179. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140180. * "sourceSize": {"w":32,"h":32}
  140181. * @returns RawTexture of the frameMap
  140182. */
  140183. private _createFrameBuffer;
  140184. /**
  140185. * Creates the tileMap texture Buffer
  140186. * @param buffer normally and array of numbers, or a false to generate from scratch
  140187. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140188. * @returns RawTexture of the tileMap
  140189. */
  140190. private _createTileBuffer;
  140191. /**
  140192. * Modifies the data of the tileMaps
  140193. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140194. * @param pos is the iVector2 Coordinates of the Tile
  140195. * @param tile The SpriteIndex of the new Tile
  140196. */
  140197. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140198. /**
  140199. * Creates the animationMap texture Buffer
  140200. * @param buffer normally and array of numbers, or a false to generate from scratch
  140201. * @returns RawTexture of the animationMap
  140202. */
  140203. private _createTileAnimationBuffer;
  140204. /**
  140205. * Modifies the data of the animationMap
  140206. * @param cellID is the Index of the Sprite
  140207. * @param _frame is the target Animation frame
  140208. * @param toCell is the Target Index of the next frame of the animation
  140209. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140210. * @param speed is a global scalar of the time variable on the map.
  140211. */
  140212. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140213. /**
  140214. * Exports the .tilemaps file
  140215. */
  140216. saveTileMaps(): void;
  140217. /**
  140218. * Imports the .tilemaps file
  140219. * @param url of the .tilemaps file
  140220. */
  140221. loadTileMaps(url: string): void;
  140222. /**
  140223. * Release associated resources
  140224. */
  140225. dispose(): void;
  140226. }
  140227. }
  140228. declare module BABYLON {
  140229. /**
  140230. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140231. * @see http://doc.babylonjs.com/babylon101/sprites
  140232. */
  140233. export class SpritePackedManager extends SpriteManager {
  140234. /** defines the packed manager's name */
  140235. name: string;
  140236. /**
  140237. * Creates a new sprite manager from a packed sprite sheet
  140238. * @param name defines the manager's name
  140239. * @param imgUrl defines the sprite sheet url
  140240. * @param capacity defines the maximum allowed number of sprites
  140241. * @param scene defines the hosting scene
  140242. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140243. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140244. * @param samplingMode defines the smapling mode to use with spritesheet
  140245. * @param fromPacked set to true; do not alter
  140246. */
  140247. constructor(
  140248. /** defines the packed manager's name */
  140249. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140250. }
  140251. }
  140252. declare module BABYLON {
  140253. /**
  140254. * Defines the list of states available for a task inside a AssetsManager
  140255. */
  140256. export enum AssetTaskState {
  140257. /**
  140258. * Initialization
  140259. */
  140260. INIT = 0,
  140261. /**
  140262. * Running
  140263. */
  140264. RUNNING = 1,
  140265. /**
  140266. * Done
  140267. */
  140268. DONE = 2,
  140269. /**
  140270. * Error
  140271. */
  140272. ERROR = 3
  140273. }
  140274. /**
  140275. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140276. */
  140277. export abstract class AbstractAssetTask {
  140278. /**
  140279. * Task name
  140280. */ name: string;
  140281. /**
  140282. * Callback called when the task is successful
  140283. */
  140284. onSuccess: (task: any) => void;
  140285. /**
  140286. * Callback called when the task is not successful
  140287. */
  140288. onError: (task: any, message?: string, exception?: any) => void;
  140289. /**
  140290. * Creates a new AssetsManager
  140291. * @param name defines the name of the task
  140292. */
  140293. constructor(
  140294. /**
  140295. * Task name
  140296. */ name: string);
  140297. private _isCompleted;
  140298. private _taskState;
  140299. private _errorObject;
  140300. /**
  140301. * Get if the task is completed
  140302. */
  140303. get isCompleted(): boolean;
  140304. /**
  140305. * Gets the current state of the task
  140306. */
  140307. get taskState(): AssetTaskState;
  140308. /**
  140309. * Gets the current error object (if task is in error)
  140310. */
  140311. get errorObject(): {
  140312. message?: string;
  140313. exception?: any;
  140314. };
  140315. /**
  140316. * Internal only
  140317. * @hidden
  140318. */
  140319. _setErrorObject(message?: string, exception?: any): void;
  140320. /**
  140321. * Execute the current task
  140322. * @param scene defines the scene where you want your assets to be loaded
  140323. * @param onSuccess is a callback called when the task is successfully executed
  140324. * @param onError is a callback called if an error occurs
  140325. */
  140326. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140327. /**
  140328. * Execute the current task
  140329. * @param scene defines the scene where you want your assets to be loaded
  140330. * @param onSuccess is a callback called when the task is successfully executed
  140331. * @param onError is a callback called if an error occurs
  140332. */
  140333. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140334. /**
  140335. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140336. * This can be used with failed tasks that have the reason for failure fixed.
  140337. */
  140338. reset(): void;
  140339. private onErrorCallback;
  140340. private onDoneCallback;
  140341. }
  140342. /**
  140343. * Define the interface used by progress events raised during assets loading
  140344. */
  140345. export interface IAssetsProgressEvent {
  140346. /**
  140347. * Defines the number of remaining tasks to process
  140348. */
  140349. remainingCount: number;
  140350. /**
  140351. * Defines the total number of tasks
  140352. */
  140353. totalCount: number;
  140354. /**
  140355. * Defines the task that was just processed
  140356. */
  140357. task: AbstractAssetTask;
  140358. }
  140359. /**
  140360. * Class used to share progress information about assets loading
  140361. */
  140362. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140363. /**
  140364. * Defines the number of remaining tasks to process
  140365. */
  140366. remainingCount: number;
  140367. /**
  140368. * Defines the total number of tasks
  140369. */
  140370. totalCount: number;
  140371. /**
  140372. * Defines the task that was just processed
  140373. */
  140374. task: AbstractAssetTask;
  140375. /**
  140376. * Creates a AssetsProgressEvent
  140377. * @param remainingCount defines the number of remaining tasks to process
  140378. * @param totalCount defines the total number of tasks
  140379. * @param task defines the task that was just processed
  140380. */
  140381. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140382. }
  140383. /**
  140384. * Define a task used by AssetsManager to load meshes
  140385. */
  140386. export class MeshAssetTask extends AbstractAssetTask {
  140387. /**
  140388. * Defines the name of the task
  140389. */
  140390. name: string;
  140391. /**
  140392. * Defines the list of mesh's names you want to load
  140393. */
  140394. meshesNames: any;
  140395. /**
  140396. * Defines the root url to use as a base to load your meshes and associated resources
  140397. */
  140398. rootUrl: string;
  140399. /**
  140400. * Defines the filename of the scene to load from
  140401. */
  140402. sceneFilename: string;
  140403. /**
  140404. * Gets the list of loaded meshes
  140405. */
  140406. loadedMeshes: Array<AbstractMesh>;
  140407. /**
  140408. * Gets the list of loaded particle systems
  140409. */
  140410. loadedParticleSystems: Array<IParticleSystem>;
  140411. /**
  140412. * Gets the list of loaded skeletons
  140413. */
  140414. loadedSkeletons: Array<Skeleton>;
  140415. /**
  140416. * Gets the list of loaded animation groups
  140417. */
  140418. loadedAnimationGroups: Array<AnimationGroup>;
  140419. /**
  140420. * Callback called when the task is successful
  140421. */
  140422. onSuccess: (task: MeshAssetTask) => void;
  140423. /**
  140424. * Callback called when the task is successful
  140425. */
  140426. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140427. /**
  140428. * Creates a new MeshAssetTask
  140429. * @param name defines the name of the task
  140430. * @param meshesNames defines the list of mesh's names you want to load
  140431. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140432. * @param sceneFilename defines the filename of the scene to load from
  140433. */
  140434. constructor(
  140435. /**
  140436. * Defines the name of the task
  140437. */
  140438. name: string,
  140439. /**
  140440. * Defines the list of mesh's names you want to load
  140441. */
  140442. meshesNames: any,
  140443. /**
  140444. * Defines the root url to use as a base to load your meshes and associated resources
  140445. */
  140446. rootUrl: string,
  140447. /**
  140448. * Defines the filename of the scene to load from
  140449. */
  140450. sceneFilename: string);
  140451. /**
  140452. * Execute the current task
  140453. * @param scene defines the scene where you want your assets to be loaded
  140454. * @param onSuccess is a callback called when the task is successfully executed
  140455. * @param onError is a callback called if an error occurs
  140456. */
  140457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140458. }
  140459. /**
  140460. * Define a task used by AssetsManager to load text content
  140461. */
  140462. export class TextFileAssetTask extends AbstractAssetTask {
  140463. /**
  140464. * Defines the name of the task
  140465. */
  140466. name: string;
  140467. /**
  140468. * Defines the location of the file to load
  140469. */
  140470. url: string;
  140471. /**
  140472. * Gets the loaded text string
  140473. */
  140474. text: string;
  140475. /**
  140476. * Callback called when the task is successful
  140477. */
  140478. onSuccess: (task: TextFileAssetTask) => void;
  140479. /**
  140480. * Callback called when the task is successful
  140481. */
  140482. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140483. /**
  140484. * Creates a new TextFileAssetTask object
  140485. * @param name defines the name of the task
  140486. * @param url defines the location of the file to load
  140487. */
  140488. constructor(
  140489. /**
  140490. * Defines the name of the task
  140491. */
  140492. name: string,
  140493. /**
  140494. * Defines the location of the file to load
  140495. */
  140496. url: string);
  140497. /**
  140498. * Execute the current task
  140499. * @param scene defines the scene where you want your assets to be loaded
  140500. * @param onSuccess is a callback called when the task is successfully executed
  140501. * @param onError is a callback called if an error occurs
  140502. */
  140503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140504. }
  140505. /**
  140506. * Define a task used by AssetsManager to load binary data
  140507. */
  140508. export class BinaryFileAssetTask extends AbstractAssetTask {
  140509. /**
  140510. * Defines the name of the task
  140511. */
  140512. name: string;
  140513. /**
  140514. * Defines the location of the file to load
  140515. */
  140516. url: string;
  140517. /**
  140518. * Gets the lodaded data (as an array buffer)
  140519. */
  140520. data: ArrayBuffer;
  140521. /**
  140522. * Callback called when the task is successful
  140523. */
  140524. onSuccess: (task: BinaryFileAssetTask) => void;
  140525. /**
  140526. * Callback called when the task is successful
  140527. */
  140528. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140529. /**
  140530. * Creates a new BinaryFileAssetTask object
  140531. * @param name defines the name of the new task
  140532. * @param url defines the location of the file to load
  140533. */
  140534. constructor(
  140535. /**
  140536. * Defines the name of the task
  140537. */
  140538. name: string,
  140539. /**
  140540. * Defines the location of the file to load
  140541. */
  140542. url: string);
  140543. /**
  140544. * Execute the current task
  140545. * @param scene defines the scene where you want your assets to be loaded
  140546. * @param onSuccess is a callback called when the task is successfully executed
  140547. * @param onError is a callback called if an error occurs
  140548. */
  140549. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140550. }
  140551. /**
  140552. * Define a task used by AssetsManager to load images
  140553. */
  140554. export class ImageAssetTask extends AbstractAssetTask {
  140555. /**
  140556. * Defines the name of the task
  140557. */
  140558. name: string;
  140559. /**
  140560. * Defines the location of the image to load
  140561. */
  140562. url: string;
  140563. /**
  140564. * Gets the loaded images
  140565. */
  140566. image: HTMLImageElement;
  140567. /**
  140568. * Callback called when the task is successful
  140569. */
  140570. onSuccess: (task: ImageAssetTask) => void;
  140571. /**
  140572. * Callback called when the task is successful
  140573. */
  140574. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140575. /**
  140576. * Creates a new ImageAssetTask
  140577. * @param name defines the name of the task
  140578. * @param url defines the location of the image to load
  140579. */
  140580. constructor(
  140581. /**
  140582. * Defines the name of the task
  140583. */
  140584. name: string,
  140585. /**
  140586. * Defines the location of the image to load
  140587. */
  140588. url: string);
  140589. /**
  140590. * Execute the current task
  140591. * @param scene defines the scene where you want your assets to be loaded
  140592. * @param onSuccess is a callback called when the task is successfully executed
  140593. * @param onError is a callback called if an error occurs
  140594. */
  140595. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140596. }
  140597. /**
  140598. * Defines the interface used by texture loading tasks
  140599. */
  140600. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140601. /**
  140602. * Gets the loaded texture
  140603. */
  140604. texture: TEX;
  140605. }
  140606. /**
  140607. * Define a task used by AssetsManager to load 2D textures
  140608. */
  140609. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140610. /**
  140611. * Defines the name of the task
  140612. */
  140613. name: string;
  140614. /**
  140615. * Defines the location of the file to load
  140616. */
  140617. url: string;
  140618. /**
  140619. * Defines if mipmap should not be generated (default is false)
  140620. */
  140621. noMipmap?: boolean | undefined;
  140622. /**
  140623. * Defines if texture must be inverted on Y axis (default is false)
  140624. */
  140625. invertY?: boolean | undefined;
  140626. /**
  140627. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140628. */
  140629. samplingMode: number;
  140630. /**
  140631. * Gets the loaded texture
  140632. */
  140633. texture: Texture;
  140634. /**
  140635. * Callback called when the task is successful
  140636. */
  140637. onSuccess: (task: TextureAssetTask) => void;
  140638. /**
  140639. * Callback called when the task is successful
  140640. */
  140641. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140642. /**
  140643. * Creates a new TextureAssetTask object
  140644. * @param name defines the name of the task
  140645. * @param url defines the location of the file to load
  140646. * @param noMipmap defines if mipmap should not be generated (default is false)
  140647. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140648. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140649. */
  140650. constructor(
  140651. /**
  140652. * Defines the name of the task
  140653. */
  140654. name: string,
  140655. /**
  140656. * Defines the location of the file to load
  140657. */
  140658. url: string,
  140659. /**
  140660. * Defines if mipmap should not be generated (default is false)
  140661. */
  140662. noMipmap?: boolean | undefined,
  140663. /**
  140664. * Defines if texture must be inverted on Y axis (default is false)
  140665. */
  140666. invertY?: boolean | undefined,
  140667. /**
  140668. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140669. */
  140670. samplingMode?: number);
  140671. /**
  140672. * Execute the current task
  140673. * @param scene defines the scene where you want your assets to be loaded
  140674. * @param onSuccess is a callback called when the task is successfully executed
  140675. * @param onError is a callback called if an error occurs
  140676. */
  140677. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140678. }
  140679. /**
  140680. * Define a task used by AssetsManager to load cube textures
  140681. */
  140682. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140683. /**
  140684. * Defines the name of the task
  140685. */
  140686. name: string;
  140687. /**
  140688. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140689. */
  140690. url: string;
  140691. /**
  140692. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140693. */
  140694. extensions?: string[] | undefined;
  140695. /**
  140696. * Defines if mipmaps should not be generated (default is false)
  140697. */
  140698. noMipmap?: boolean | undefined;
  140699. /**
  140700. * Defines the explicit list of files (undefined by default)
  140701. */
  140702. files?: string[] | undefined;
  140703. /**
  140704. * Gets the loaded texture
  140705. */
  140706. texture: CubeTexture;
  140707. /**
  140708. * Callback called when the task is successful
  140709. */
  140710. onSuccess: (task: CubeTextureAssetTask) => void;
  140711. /**
  140712. * Callback called when the task is successful
  140713. */
  140714. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140715. /**
  140716. * Creates a new CubeTextureAssetTask
  140717. * @param name defines the name of the task
  140718. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140719. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140720. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140721. * @param files defines the explicit list of files (undefined by default)
  140722. */
  140723. constructor(
  140724. /**
  140725. * Defines the name of the task
  140726. */
  140727. name: string,
  140728. /**
  140729. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140730. */
  140731. url: string,
  140732. /**
  140733. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140734. */
  140735. extensions?: string[] | undefined,
  140736. /**
  140737. * Defines if mipmaps should not be generated (default is false)
  140738. */
  140739. noMipmap?: boolean | undefined,
  140740. /**
  140741. * Defines the explicit list of files (undefined by default)
  140742. */
  140743. files?: string[] | undefined);
  140744. /**
  140745. * Execute the current task
  140746. * @param scene defines the scene where you want your assets to be loaded
  140747. * @param onSuccess is a callback called when the task is successfully executed
  140748. * @param onError is a callback called if an error occurs
  140749. */
  140750. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140751. }
  140752. /**
  140753. * Define a task used by AssetsManager to load HDR cube textures
  140754. */
  140755. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140756. /**
  140757. * Defines the name of the task
  140758. */
  140759. name: string;
  140760. /**
  140761. * Defines the location of the file to load
  140762. */
  140763. url: string;
  140764. /**
  140765. * Defines the desired size (the more it increases the longer the generation will be)
  140766. */
  140767. size: number;
  140768. /**
  140769. * Defines if mipmaps should not be generated (default is false)
  140770. */
  140771. noMipmap: boolean;
  140772. /**
  140773. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140774. */
  140775. generateHarmonics: boolean;
  140776. /**
  140777. * 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)
  140778. */
  140779. gammaSpace: boolean;
  140780. /**
  140781. * Internal Use Only
  140782. */
  140783. reserved: boolean;
  140784. /**
  140785. * Gets the loaded texture
  140786. */
  140787. texture: HDRCubeTexture;
  140788. /**
  140789. * Callback called when the task is successful
  140790. */
  140791. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140792. /**
  140793. * Callback called when the task is successful
  140794. */
  140795. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140796. /**
  140797. * Creates a new HDRCubeTextureAssetTask object
  140798. * @param name defines the name of the task
  140799. * @param url defines the location of the file to load
  140800. * @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.
  140801. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140802. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140803. * @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)
  140804. * @param reserved Internal use only
  140805. */
  140806. constructor(
  140807. /**
  140808. * Defines the name of the task
  140809. */
  140810. name: string,
  140811. /**
  140812. * Defines the location of the file to load
  140813. */
  140814. url: string,
  140815. /**
  140816. * Defines the desired size (the more it increases the longer the generation will be)
  140817. */
  140818. size: number,
  140819. /**
  140820. * Defines if mipmaps should not be generated (default is false)
  140821. */
  140822. noMipmap?: boolean,
  140823. /**
  140824. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140825. */
  140826. generateHarmonics?: boolean,
  140827. /**
  140828. * 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)
  140829. */
  140830. gammaSpace?: boolean,
  140831. /**
  140832. * Internal Use Only
  140833. */
  140834. reserved?: boolean);
  140835. /**
  140836. * Execute the current task
  140837. * @param scene defines the scene where you want your assets to be loaded
  140838. * @param onSuccess is a callback called when the task is successfully executed
  140839. * @param onError is a callback called if an error occurs
  140840. */
  140841. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140842. }
  140843. /**
  140844. * Define a task used by AssetsManager to load Equirectangular cube textures
  140845. */
  140846. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140847. /**
  140848. * Defines the name of the task
  140849. */
  140850. name: string;
  140851. /**
  140852. * Defines the location of the file to load
  140853. */
  140854. url: string;
  140855. /**
  140856. * Defines the desired size (the more it increases the longer the generation will be)
  140857. */
  140858. size: number;
  140859. /**
  140860. * Defines if mipmaps should not be generated (default is false)
  140861. */
  140862. noMipmap: boolean;
  140863. /**
  140864. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140865. * but the standard material would require them in Gamma space) (default is true)
  140866. */
  140867. gammaSpace: boolean;
  140868. /**
  140869. * Gets the loaded texture
  140870. */
  140871. texture: EquiRectangularCubeTexture;
  140872. /**
  140873. * Callback called when the task is successful
  140874. */
  140875. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140876. /**
  140877. * Callback called when the task is successful
  140878. */
  140879. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140880. /**
  140881. * Creates a new EquiRectangularCubeTextureAssetTask object
  140882. * @param name defines the name of the task
  140883. * @param url defines the location of the file to load
  140884. * @param size defines the desired size (the more it increases the longer the generation will be)
  140885. * If the size is omitted this implies you are using a preprocessed cubemap.
  140886. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140887. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140888. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140889. * (default is true)
  140890. */
  140891. constructor(
  140892. /**
  140893. * Defines the name of the task
  140894. */
  140895. name: string,
  140896. /**
  140897. * Defines the location of the file to load
  140898. */
  140899. url: string,
  140900. /**
  140901. * Defines the desired size (the more it increases the longer the generation will be)
  140902. */
  140903. size: number,
  140904. /**
  140905. * Defines if mipmaps should not be generated (default is false)
  140906. */
  140907. noMipmap?: boolean,
  140908. /**
  140909. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140910. * but the standard material would require them in Gamma space) (default is true)
  140911. */
  140912. gammaSpace?: boolean);
  140913. /**
  140914. * Execute the current task
  140915. * @param scene defines the scene where you want your assets to be loaded
  140916. * @param onSuccess is a callback called when the task is successfully executed
  140917. * @param onError is a callback called if an error occurs
  140918. */
  140919. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140920. }
  140921. /**
  140922. * This class can be used to easily import assets into a scene
  140923. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140924. */
  140925. export class AssetsManager {
  140926. private _scene;
  140927. private _isLoading;
  140928. protected _tasks: AbstractAssetTask[];
  140929. protected _waitingTasksCount: number;
  140930. protected _totalTasksCount: number;
  140931. /**
  140932. * Callback called when all tasks are processed
  140933. */
  140934. onFinish: (tasks: AbstractAssetTask[]) => void;
  140935. /**
  140936. * Callback called when a task is successful
  140937. */
  140938. onTaskSuccess: (task: AbstractAssetTask) => void;
  140939. /**
  140940. * Callback called when a task had an error
  140941. */
  140942. onTaskError: (task: AbstractAssetTask) => void;
  140943. /**
  140944. * Callback called when a task is done (whatever the result is)
  140945. */
  140946. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140947. /**
  140948. * Observable called when all tasks are processed
  140949. */
  140950. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140951. /**
  140952. * Observable called when a task had an error
  140953. */
  140954. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140955. /**
  140956. * Observable called when all tasks were executed
  140957. */
  140958. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140959. /**
  140960. * Observable called when a task is done (whatever the result is)
  140961. */
  140962. onProgressObservable: Observable<IAssetsProgressEvent>;
  140963. /**
  140964. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140965. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140966. */
  140967. useDefaultLoadingScreen: boolean;
  140968. /**
  140969. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140970. * when all assets have been downloaded.
  140971. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140972. */
  140973. autoHideLoadingUI: boolean;
  140974. /**
  140975. * Creates a new AssetsManager
  140976. * @param scene defines the scene to work on
  140977. */
  140978. constructor(scene: Scene);
  140979. /**
  140980. * Add a MeshAssetTask to the list of active tasks
  140981. * @param taskName defines the name of the new task
  140982. * @param meshesNames defines the name of meshes to load
  140983. * @param rootUrl defines the root url to use to locate files
  140984. * @param sceneFilename defines the filename of the scene file
  140985. * @returns a new MeshAssetTask object
  140986. */
  140987. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140988. /**
  140989. * Add a TextFileAssetTask to the list of active tasks
  140990. * @param taskName defines the name of the new task
  140991. * @param url defines the url of the file to load
  140992. * @returns a new TextFileAssetTask object
  140993. */
  140994. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140995. /**
  140996. * Add a BinaryFileAssetTask to the list of active tasks
  140997. * @param taskName defines the name of the new task
  140998. * @param url defines the url of the file to load
  140999. * @returns a new BinaryFileAssetTask object
  141000. */
  141001. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  141002. /**
  141003. * Add a ImageAssetTask to the list of active tasks
  141004. * @param taskName defines the name of the new task
  141005. * @param url defines the url of the file to load
  141006. * @returns a new ImageAssetTask object
  141007. */
  141008. addImageTask(taskName: string, url: string): ImageAssetTask;
  141009. /**
  141010. * Add a TextureAssetTask to the list of active tasks
  141011. * @param taskName defines the name of the new task
  141012. * @param url defines the url of the file to load
  141013. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141014. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141015. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141016. * @returns a new TextureAssetTask object
  141017. */
  141018. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141019. /**
  141020. * Add a CubeTextureAssetTask to the list of active tasks
  141021. * @param taskName defines the name of the new task
  141022. * @param url defines the url of the file to load
  141023. * @param extensions defines the extension to use to load the cube map (can be null)
  141024. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141025. * @param files defines the list of files to load (can be null)
  141026. * @returns a new CubeTextureAssetTask object
  141027. */
  141028. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141029. /**
  141030. *
  141031. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141032. * @param taskName defines the name of the new task
  141033. * @param url defines the url of the file to load
  141034. * @param size defines the size you want for the cubemap (can be null)
  141035. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141036. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141037. * @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)
  141038. * @param reserved Internal use only
  141039. * @returns a new HDRCubeTextureAssetTask object
  141040. */
  141041. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141042. /**
  141043. *
  141044. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141045. * @param taskName defines the name of the new task
  141046. * @param url defines the url of the file to load
  141047. * @param size defines the size you want for the cubemap (can be null)
  141048. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141049. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141050. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141051. * @returns a new EquiRectangularCubeTextureAssetTask object
  141052. */
  141053. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141054. /**
  141055. * Remove a task from the assets manager.
  141056. * @param task the task to remove
  141057. */
  141058. removeTask(task: AbstractAssetTask): void;
  141059. private _decreaseWaitingTasksCount;
  141060. private _runTask;
  141061. /**
  141062. * Reset the AssetsManager and remove all tasks
  141063. * @return the current instance of the AssetsManager
  141064. */
  141065. reset(): AssetsManager;
  141066. /**
  141067. * Start the loading process
  141068. * @return the current instance of the AssetsManager
  141069. */
  141070. load(): AssetsManager;
  141071. /**
  141072. * Start the loading process as an async operation
  141073. * @return a promise returning the list of failed tasks
  141074. */
  141075. loadAsync(): Promise<void>;
  141076. }
  141077. }
  141078. declare module BABYLON {
  141079. /**
  141080. * Wrapper class for promise with external resolve and reject.
  141081. */
  141082. export class Deferred<T> {
  141083. /**
  141084. * The promise associated with this deferred object.
  141085. */
  141086. readonly promise: Promise<T>;
  141087. private _resolve;
  141088. private _reject;
  141089. /**
  141090. * The resolve method of the promise associated with this deferred object.
  141091. */
  141092. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141093. /**
  141094. * The reject method of the promise associated with this deferred object.
  141095. */
  141096. get reject(): (reason?: any) => void;
  141097. /**
  141098. * Constructor for this deferred object.
  141099. */
  141100. constructor();
  141101. }
  141102. }
  141103. declare module BABYLON {
  141104. /**
  141105. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141106. */
  141107. export class MeshExploder {
  141108. private _centerMesh;
  141109. private _meshes;
  141110. private _meshesOrigins;
  141111. private _toCenterVectors;
  141112. private _scaledDirection;
  141113. private _newPosition;
  141114. private _centerPosition;
  141115. /**
  141116. * Explodes meshes from a center mesh.
  141117. * @param meshes The meshes to explode.
  141118. * @param centerMesh The mesh to be center of explosion.
  141119. */
  141120. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141121. private _setCenterMesh;
  141122. /**
  141123. * Get class name
  141124. * @returns "MeshExploder"
  141125. */
  141126. getClassName(): string;
  141127. /**
  141128. * "Exploded meshes"
  141129. * @returns Array of meshes with the centerMesh at index 0.
  141130. */
  141131. getMeshes(): Array<Mesh>;
  141132. /**
  141133. * Explodes meshes giving a specific direction
  141134. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141135. */
  141136. explode(direction?: number): void;
  141137. }
  141138. }
  141139. declare module BABYLON {
  141140. /**
  141141. * Class used to help managing file picking and drag'n'drop
  141142. */
  141143. export class FilesInput {
  141144. /**
  141145. * List of files ready to be loaded
  141146. */
  141147. static get FilesToLoad(): {
  141148. [key: string]: File;
  141149. };
  141150. /**
  141151. * Callback called when a file is processed
  141152. */
  141153. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141154. private _engine;
  141155. private _currentScene;
  141156. private _sceneLoadedCallback;
  141157. private _progressCallback;
  141158. private _additionalRenderLoopLogicCallback;
  141159. private _textureLoadingCallback;
  141160. private _startingProcessingFilesCallback;
  141161. private _onReloadCallback;
  141162. private _errorCallback;
  141163. private _elementToMonitor;
  141164. private _sceneFileToLoad;
  141165. private _filesToLoad;
  141166. /**
  141167. * Creates a new FilesInput
  141168. * @param engine defines the rendering engine
  141169. * @param scene defines the hosting scene
  141170. * @param sceneLoadedCallback callback called when scene is loaded
  141171. * @param progressCallback callback called to track progress
  141172. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141173. * @param textureLoadingCallback callback called when a texture is loading
  141174. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141175. * @param onReloadCallback callback called when a reload is requested
  141176. * @param errorCallback callback call if an error occurs
  141177. */
  141178. 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);
  141179. private _dragEnterHandler;
  141180. private _dragOverHandler;
  141181. private _dropHandler;
  141182. /**
  141183. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141184. * @param elementToMonitor defines the DOM element to track
  141185. */
  141186. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141187. /**
  141188. * Release all associated resources
  141189. */
  141190. dispose(): void;
  141191. private renderFunction;
  141192. private drag;
  141193. private drop;
  141194. private _traverseFolder;
  141195. private _processFiles;
  141196. /**
  141197. * Load files from a drop event
  141198. * @param event defines the drop event to use as source
  141199. */
  141200. loadFiles(event: any): void;
  141201. private _processReload;
  141202. /**
  141203. * Reload the current scene from the loaded files
  141204. */
  141205. reload(): void;
  141206. }
  141207. }
  141208. declare module BABYLON {
  141209. /**
  141210. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141211. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141212. */
  141213. export class SceneOptimization {
  141214. /**
  141215. * Defines the priority of this optimization (0 by default which means first in the list)
  141216. */
  141217. priority: number;
  141218. /**
  141219. * Gets a string describing the action executed by the current optimization
  141220. * @returns description string
  141221. */
  141222. getDescription(): string;
  141223. /**
  141224. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141225. * @param scene defines the current scene where to apply this optimization
  141226. * @param optimizer defines the current optimizer
  141227. * @returns true if everything that can be done was applied
  141228. */
  141229. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141230. /**
  141231. * Creates the SceneOptimization object
  141232. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141233. * @param desc defines the description associated with the optimization
  141234. */
  141235. constructor(
  141236. /**
  141237. * Defines the priority of this optimization (0 by default which means first in the list)
  141238. */
  141239. priority?: number);
  141240. }
  141241. /**
  141242. * Defines an optimization used to reduce the size of render target textures
  141243. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141244. */
  141245. export class TextureOptimization extends SceneOptimization {
  141246. /**
  141247. * Defines the priority of this optimization (0 by default which means first in the list)
  141248. */
  141249. priority: number;
  141250. /**
  141251. * 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
  141252. */
  141253. maximumSize: number;
  141254. /**
  141255. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141256. */
  141257. step: number;
  141258. /**
  141259. * Gets a string describing the action executed by the current optimization
  141260. * @returns description string
  141261. */
  141262. getDescription(): string;
  141263. /**
  141264. * Creates the TextureOptimization object
  141265. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141266. * @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
  141267. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141268. */
  141269. constructor(
  141270. /**
  141271. * Defines the priority of this optimization (0 by default which means first in the list)
  141272. */
  141273. priority?: number,
  141274. /**
  141275. * 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
  141276. */
  141277. maximumSize?: number,
  141278. /**
  141279. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141280. */
  141281. step?: number);
  141282. /**
  141283. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141284. * @param scene defines the current scene where to apply this optimization
  141285. * @param optimizer defines the current optimizer
  141286. * @returns true if everything that can be done was applied
  141287. */
  141288. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141289. }
  141290. /**
  141291. * Defines an optimization used to increase or decrease the rendering resolution
  141292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141293. */
  141294. export class HardwareScalingOptimization extends SceneOptimization {
  141295. /**
  141296. * Defines the priority of this optimization (0 by default which means first in the list)
  141297. */
  141298. priority: number;
  141299. /**
  141300. * Defines the maximum scale to use (2 by default)
  141301. */
  141302. maximumScale: number;
  141303. /**
  141304. * Defines the step to use between two passes (0.5 by default)
  141305. */
  141306. step: number;
  141307. private _currentScale;
  141308. private _directionOffset;
  141309. /**
  141310. * Gets a string describing the action executed by the current optimization
  141311. * @return description string
  141312. */
  141313. getDescription(): string;
  141314. /**
  141315. * Creates the HardwareScalingOptimization object
  141316. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141317. * @param maximumScale defines the maximum scale to use (2 by default)
  141318. * @param step defines the step to use between two passes (0.5 by default)
  141319. */
  141320. constructor(
  141321. /**
  141322. * Defines the priority of this optimization (0 by default which means first in the list)
  141323. */
  141324. priority?: number,
  141325. /**
  141326. * Defines the maximum scale to use (2 by default)
  141327. */
  141328. maximumScale?: number,
  141329. /**
  141330. * Defines the step to use between two passes (0.5 by default)
  141331. */
  141332. step?: number);
  141333. /**
  141334. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141335. * @param scene defines the current scene where to apply this optimization
  141336. * @param optimizer defines the current optimizer
  141337. * @returns true if everything that can be done was applied
  141338. */
  141339. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141340. }
  141341. /**
  141342. * Defines an optimization used to remove shadows
  141343. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141344. */
  141345. export class ShadowsOptimization extends SceneOptimization {
  141346. /**
  141347. * Gets a string describing the action executed by the current optimization
  141348. * @return description string
  141349. */
  141350. getDescription(): string;
  141351. /**
  141352. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141353. * @param scene defines the current scene where to apply this optimization
  141354. * @param optimizer defines the current optimizer
  141355. * @returns true if everything that can be done was applied
  141356. */
  141357. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141358. }
  141359. /**
  141360. * Defines an optimization used to turn post-processes off
  141361. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141362. */
  141363. export class PostProcessesOptimization extends SceneOptimization {
  141364. /**
  141365. * Gets a string describing the action executed by the current optimization
  141366. * @return description string
  141367. */
  141368. getDescription(): string;
  141369. /**
  141370. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141371. * @param scene defines the current scene where to apply this optimization
  141372. * @param optimizer defines the current optimizer
  141373. * @returns true if everything that can be done was applied
  141374. */
  141375. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141376. }
  141377. /**
  141378. * Defines an optimization used to turn lens flares off
  141379. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141380. */
  141381. export class LensFlaresOptimization extends SceneOptimization {
  141382. /**
  141383. * Gets a string describing the action executed by the current optimization
  141384. * @return description string
  141385. */
  141386. getDescription(): string;
  141387. /**
  141388. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141389. * @param scene defines the current scene where to apply this optimization
  141390. * @param optimizer defines the current optimizer
  141391. * @returns true if everything that can be done was applied
  141392. */
  141393. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141394. }
  141395. /**
  141396. * Defines an optimization based on user defined callback.
  141397. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141398. */
  141399. export class CustomOptimization extends SceneOptimization {
  141400. /**
  141401. * Callback called to apply the custom optimization.
  141402. */
  141403. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141404. /**
  141405. * Callback called to get custom description
  141406. */
  141407. onGetDescription: () => string;
  141408. /**
  141409. * Gets a string describing the action executed by the current optimization
  141410. * @returns description string
  141411. */
  141412. getDescription(): string;
  141413. /**
  141414. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141415. * @param scene defines the current scene where to apply this optimization
  141416. * @param optimizer defines the current optimizer
  141417. * @returns true if everything that can be done was applied
  141418. */
  141419. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141420. }
  141421. /**
  141422. * Defines an optimization used to turn particles off
  141423. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141424. */
  141425. export class ParticlesOptimization extends SceneOptimization {
  141426. /**
  141427. * Gets a string describing the action executed by the current optimization
  141428. * @return description string
  141429. */
  141430. getDescription(): string;
  141431. /**
  141432. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141433. * @param scene defines the current scene where to apply this optimization
  141434. * @param optimizer defines the current optimizer
  141435. * @returns true if everything that can be done was applied
  141436. */
  141437. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141438. }
  141439. /**
  141440. * Defines an optimization used to turn render targets off
  141441. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141442. */
  141443. export class RenderTargetsOptimization extends SceneOptimization {
  141444. /**
  141445. * Gets a string describing the action executed by the current optimization
  141446. * @return description string
  141447. */
  141448. getDescription(): string;
  141449. /**
  141450. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141451. * @param scene defines the current scene where to apply this optimization
  141452. * @param optimizer defines the current optimizer
  141453. * @returns true if everything that can be done was applied
  141454. */
  141455. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141456. }
  141457. /**
  141458. * Defines an optimization used to merge meshes with compatible materials
  141459. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141460. */
  141461. export class MergeMeshesOptimization extends SceneOptimization {
  141462. private static _UpdateSelectionTree;
  141463. /**
  141464. * Gets or sets a boolean which defines if optimization octree has to be updated
  141465. */
  141466. static get UpdateSelectionTree(): boolean;
  141467. /**
  141468. * Gets or sets a boolean which defines if optimization octree has to be updated
  141469. */
  141470. static set UpdateSelectionTree(value: boolean);
  141471. /**
  141472. * Gets a string describing the action executed by the current optimization
  141473. * @return description string
  141474. */
  141475. getDescription(): string;
  141476. private _canBeMerged;
  141477. /**
  141478. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141479. * @param scene defines the current scene where to apply this optimization
  141480. * @param optimizer defines the current optimizer
  141481. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141482. * @returns true if everything that can be done was applied
  141483. */
  141484. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141485. }
  141486. /**
  141487. * Defines a list of options used by SceneOptimizer
  141488. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141489. */
  141490. export class SceneOptimizerOptions {
  141491. /**
  141492. * Defines the target frame rate to reach (60 by default)
  141493. */
  141494. targetFrameRate: number;
  141495. /**
  141496. * Defines the interval between two checkes (2000ms by default)
  141497. */
  141498. trackerDuration: number;
  141499. /**
  141500. * Gets the list of optimizations to apply
  141501. */
  141502. optimizations: SceneOptimization[];
  141503. /**
  141504. * Creates a new list of options used by SceneOptimizer
  141505. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141506. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141507. */
  141508. constructor(
  141509. /**
  141510. * Defines the target frame rate to reach (60 by default)
  141511. */
  141512. targetFrameRate?: number,
  141513. /**
  141514. * Defines the interval between two checkes (2000ms by default)
  141515. */
  141516. trackerDuration?: number);
  141517. /**
  141518. * Add a new optimization
  141519. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141520. * @returns the current SceneOptimizerOptions
  141521. */
  141522. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141523. /**
  141524. * Add a new custom optimization
  141525. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141526. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141527. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141528. * @returns the current SceneOptimizerOptions
  141529. */
  141530. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141531. /**
  141532. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141533. * @param targetFrameRate defines the target frame rate (60 by default)
  141534. * @returns a SceneOptimizerOptions object
  141535. */
  141536. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141537. /**
  141538. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141539. * @param targetFrameRate defines the target frame rate (60 by default)
  141540. * @returns a SceneOptimizerOptions object
  141541. */
  141542. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141543. /**
  141544. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141545. * @param targetFrameRate defines the target frame rate (60 by default)
  141546. * @returns a SceneOptimizerOptions object
  141547. */
  141548. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141549. }
  141550. /**
  141551. * Class used to run optimizations in order to reach a target frame rate
  141552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141553. */
  141554. export class SceneOptimizer implements IDisposable {
  141555. private _isRunning;
  141556. private _options;
  141557. private _scene;
  141558. private _currentPriorityLevel;
  141559. private _targetFrameRate;
  141560. private _trackerDuration;
  141561. private _currentFrameRate;
  141562. private _sceneDisposeObserver;
  141563. private _improvementMode;
  141564. /**
  141565. * Defines an observable called when the optimizer reaches the target frame rate
  141566. */
  141567. onSuccessObservable: Observable<SceneOptimizer>;
  141568. /**
  141569. * Defines an observable called when the optimizer enables an optimization
  141570. */
  141571. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141572. /**
  141573. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141574. */
  141575. onFailureObservable: Observable<SceneOptimizer>;
  141576. /**
  141577. * Gets a boolean indicating if the optimizer is in improvement mode
  141578. */
  141579. get isInImprovementMode(): boolean;
  141580. /**
  141581. * Gets the current priority level (0 at start)
  141582. */
  141583. get currentPriorityLevel(): number;
  141584. /**
  141585. * Gets the current frame rate checked by the SceneOptimizer
  141586. */
  141587. get currentFrameRate(): number;
  141588. /**
  141589. * Gets or sets the current target frame rate (60 by default)
  141590. */
  141591. get targetFrameRate(): number;
  141592. /**
  141593. * Gets or sets the current target frame rate (60 by default)
  141594. */
  141595. set targetFrameRate(value: number);
  141596. /**
  141597. * Gets or sets the current interval between two checks (every 2000ms by default)
  141598. */
  141599. get trackerDuration(): number;
  141600. /**
  141601. * Gets or sets the current interval between two checks (every 2000ms by default)
  141602. */
  141603. set trackerDuration(value: number);
  141604. /**
  141605. * Gets the list of active optimizations
  141606. */
  141607. get optimizations(): SceneOptimization[];
  141608. /**
  141609. * Creates a new SceneOptimizer
  141610. * @param scene defines the scene to work on
  141611. * @param options defines the options to use with the SceneOptimizer
  141612. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141613. * @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)
  141614. */
  141615. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141616. /**
  141617. * Stops the current optimizer
  141618. */
  141619. stop(): void;
  141620. /**
  141621. * Reset the optimizer to initial step (current priority level = 0)
  141622. */
  141623. reset(): void;
  141624. /**
  141625. * Start the optimizer. By default it will try to reach a specific framerate
  141626. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141627. */
  141628. start(): void;
  141629. private _checkCurrentState;
  141630. /**
  141631. * Release all resources
  141632. */
  141633. dispose(): void;
  141634. /**
  141635. * Helper function to create a SceneOptimizer with one single line of code
  141636. * @param scene defines the scene to work on
  141637. * @param options defines the options to use with the SceneOptimizer
  141638. * @param onSuccess defines a callback to call on success
  141639. * @param onFailure defines a callback to call on failure
  141640. * @returns the new SceneOptimizer object
  141641. */
  141642. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141643. }
  141644. }
  141645. declare module BABYLON {
  141646. /**
  141647. * Class used to serialize a scene into a string
  141648. */
  141649. export class SceneSerializer {
  141650. /**
  141651. * Clear cache used by a previous serialization
  141652. */
  141653. static ClearCache(): void;
  141654. /**
  141655. * Serialize a scene into a JSON compatible object
  141656. * @param scene defines the scene to serialize
  141657. * @returns a JSON compatible object
  141658. */
  141659. static Serialize(scene: Scene): any;
  141660. /**
  141661. * Serialize a mesh into a JSON compatible object
  141662. * @param toSerialize defines the mesh to serialize
  141663. * @param withParents defines if parents must be serialized as well
  141664. * @param withChildren defines if children must be serialized as well
  141665. * @returns a JSON compatible object
  141666. */
  141667. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141668. }
  141669. }
  141670. declare module BABYLON {
  141671. /**
  141672. * Class used to host texture specific utilities
  141673. */
  141674. export class TextureTools {
  141675. /**
  141676. * Uses the GPU to create a copy texture rescaled at a given size
  141677. * @param texture Texture to copy from
  141678. * @param width defines the desired width
  141679. * @param height defines the desired height
  141680. * @param useBilinearMode defines if bilinear mode has to be used
  141681. * @return the generated texture
  141682. */
  141683. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141684. }
  141685. }
  141686. declare module BABYLON {
  141687. /**
  141688. * This represents the different options available for the video capture.
  141689. */
  141690. export interface VideoRecorderOptions {
  141691. /** Defines the mime type of the video. */
  141692. mimeType: string;
  141693. /** Defines the FPS the video should be recorded at. */
  141694. fps: number;
  141695. /** Defines the chunk size for the recording data. */
  141696. recordChunckSize: number;
  141697. /** The audio tracks to attach to the recording. */
  141698. audioTracks?: MediaStreamTrack[];
  141699. }
  141700. /**
  141701. * This can help with recording videos from BabylonJS.
  141702. * This is based on the available WebRTC functionalities of the browser.
  141703. *
  141704. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141705. */
  141706. export class VideoRecorder {
  141707. private static readonly _defaultOptions;
  141708. /**
  141709. * Returns whether or not the VideoRecorder is available in your browser.
  141710. * @param engine Defines the Babylon Engine.
  141711. * @returns true if supported otherwise false.
  141712. */
  141713. static IsSupported(engine: Engine): boolean;
  141714. private readonly _options;
  141715. private _canvas;
  141716. private _mediaRecorder;
  141717. private _recordedChunks;
  141718. private _fileName;
  141719. private _resolve;
  141720. private _reject;
  141721. /**
  141722. * True when a recording is already in progress.
  141723. */
  141724. get isRecording(): boolean;
  141725. /**
  141726. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141727. * @param engine Defines the BabylonJS Engine you wish to record.
  141728. * @param options Defines options that can be used to customize the capture.
  141729. */
  141730. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141731. /**
  141732. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141733. */
  141734. stopRecording(): void;
  141735. /**
  141736. * Starts recording the canvas for a max duration specified in parameters.
  141737. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141738. * If null no automatic download will start and you can rely on the promise to get the data back.
  141739. * @param maxDuration Defines the maximum recording time in seconds.
  141740. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141741. * @return A promise callback at the end of the recording with the video data in Blob.
  141742. */
  141743. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141744. /**
  141745. * Releases internal resources used during the recording.
  141746. */
  141747. dispose(): void;
  141748. private _handleDataAvailable;
  141749. private _handleError;
  141750. private _handleStop;
  141751. }
  141752. }
  141753. declare module BABYLON {
  141754. /**
  141755. * Class containing a set of static utilities functions for screenshots
  141756. */
  141757. export class ScreenshotTools {
  141758. /**
  141759. * Captures a screenshot of the current rendering
  141760. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141761. * @param engine defines the rendering engine
  141762. * @param camera defines the source camera
  141763. * @param size This parameter can be set to a single number or to an object with the
  141764. * following (optional) properties: precision, width, height. If a single number is passed,
  141765. * it will be used for both width and height. If an object is passed, the screenshot size
  141766. * will be derived from the parameters. The precision property is a multiplier allowing
  141767. * rendering at a higher or lower resolution
  141768. * @param successCallback defines the callback receives a single parameter which contains the
  141769. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141770. * src parameter of an <img> to display it
  141771. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141772. * Check your browser for supported MIME types
  141773. */
  141774. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141775. /**
  141776. * Captures a screenshot of the current rendering
  141777. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141778. * @param engine defines the rendering engine
  141779. * @param camera defines the source camera
  141780. * @param size This parameter can be set to a single number or to an object with the
  141781. * following (optional) properties: precision, width, height. If a single number is passed,
  141782. * it will be used for both width and height. If an object is passed, the screenshot size
  141783. * will be derived from the parameters. The precision property is a multiplier allowing
  141784. * rendering at a higher or lower resolution
  141785. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141786. * Check your browser for supported MIME types
  141787. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141788. * to the src parameter of an <img> to display it
  141789. */
  141790. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141791. /**
  141792. * Generates an image screenshot from the specified camera.
  141793. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141794. * @param engine The engine to use for rendering
  141795. * @param camera The camera to use for rendering
  141796. * @param size This parameter can be set to a single number or to an object with the
  141797. * following (optional) properties: precision, width, height. If a single number is passed,
  141798. * it will be used for both width and height. If an object is passed, the screenshot size
  141799. * will be derived from the parameters. The precision property is a multiplier allowing
  141800. * rendering at a higher or lower resolution
  141801. * @param successCallback The callback receives a single parameter which contains the
  141802. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141803. * src parameter of an <img> to display it
  141804. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141805. * Check your browser for supported MIME types
  141806. * @param samples Texture samples (default: 1)
  141807. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141808. * @param fileName A name for for the downloaded file.
  141809. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141810. */
  141811. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  141812. /**
  141813. * Generates an image screenshot from the specified camera.
  141814. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141815. * @param engine The engine to use for rendering
  141816. * @param camera The camera to use for rendering
  141817. * @param size This parameter can be set to a single number or to an object with the
  141818. * following (optional) properties: precision, width, height. If a single number is passed,
  141819. * it will be used for both width and height. If an object is passed, the screenshot size
  141820. * will be derived from the parameters. The precision property is a multiplier allowing
  141821. * rendering at a higher or lower resolution
  141822. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141823. * Check your browser for supported MIME types
  141824. * @param samples Texture samples (default: 1)
  141825. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141826. * @param fileName A name for for the downloaded file.
  141827. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141828. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141829. * to the src parameter of an <img> to display it
  141830. */
  141831. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  141832. /**
  141833. * Gets height and width for screenshot size
  141834. * @private
  141835. */
  141836. private static _getScreenshotSize;
  141837. }
  141838. }
  141839. declare module BABYLON {
  141840. /**
  141841. * Interface for a data buffer
  141842. */
  141843. export interface IDataBuffer {
  141844. /**
  141845. * Reads bytes from the data buffer.
  141846. * @param byteOffset The byte offset to read
  141847. * @param byteLength The byte length to read
  141848. * @returns A promise that resolves when the bytes are read
  141849. */
  141850. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141851. /**
  141852. * The byte length of the buffer.
  141853. */
  141854. readonly byteLength: number;
  141855. }
  141856. /**
  141857. * Utility class for reading from a data buffer
  141858. */
  141859. export class DataReader {
  141860. /**
  141861. * The data buffer associated with this data reader.
  141862. */
  141863. readonly buffer: IDataBuffer;
  141864. /**
  141865. * The current byte offset from the beginning of the data buffer.
  141866. */
  141867. byteOffset: number;
  141868. private _dataView;
  141869. private _dataByteOffset;
  141870. /**
  141871. * Constructor
  141872. * @param buffer The buffer to read
  141873. */
  141874. constructor(buffer: IDataBuffer);
  141875. /**
  141876. * Loads the given byte length.
  141877. * @param byteLength The byte length to load
  141878. * @returns A promise that resolves when the load is complete
  141879. */
  141880. loadAsync(byteLength: number): Promise<void>;
  141881. /**
  141882. * Read a unsigned 32-bit integer from the currently loaded data range.
  141883. * @returns The 32-bit integer read
  141884. */
  141885. readUint32(): number;
  141886. /**
  141887. * Read a byte array from the currently loaded data range.
  141888. * @param byteLength The byte length to read
  141889. * @returns The byte array read
  141890. */
  141891. readUint8Array(byteLength: number): Uint8Array;
  141892. /**
  141893. * Read a string from the currently loaded data range.
  141894. * @param byteLength The byte length to read
  141895. * @returns The string read
  141896. */
  141897. readString(byteLength: number): string;
  141898. /**
  141899. * Skips the given byte length the currently loaded data range.
  141900. * @param byteLength The byte length to skip
  141901. */
  141902. skipBytes(byteLength: number): void;
  141903. }
  141904. }
  141905. declare module BABYLON {
  141906. /**
  141907. * Options used for hit testing
  141908. */
  141909. export interface IWebXRHitTestOptions {
  141910. /**
  141911. * Only test when user interacted with the scene. Default - hit test every frame
  141912. */
  141913. testOnPointerDownOnly?: boolean;
  141914. /**
  141915. * The node to use to transform the local results to world coordinates
  141916. */
  141917. worldParentNode?: TransformNode;
  141918. }
  141919. /**
  141920. * Interface defining the babylon result of raycasting/hit-test
  141921. */
  141922. export interface IWebXRHitResult {
  141923. /**
  141924. * Transformation matrix that can be applied to a node that will put it in the hit point location
  141925. */
  141926. transformationMatrix: Matrix;
  141927. /**
  141928. * The native hit test result
  141929. */
  141930. xrHitResult: XRHitResult;
  141931. }
  141932. /**
  141933. * The currently-working hit-test module.
  141934. * Hit test (or Ray-casting) is used to interact with the real world.
  141935. * For further information read here - https://github.com/immersive-web/hit-test
  141936. */
  141937. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  141938. /**
  141939. * options to use when constructing this feature
  141940. */
  141941. readonly options: IWebXRHitTestOptions;
  141942. private _direction;
  141943. private _mat;
  141944. private _onSelectEnabled;
  141945. private _origin;
  141946. /**
  141947. * The module's name
  141948. */
  141949. static readonly Name: string;
  141950. /**
  141951. * The (Babylon) version of this module.
  141952. * This is an integer representing the implementation version.
  141953. * This number does not correspond to the WebXR specs version
  141954. */
  141955. static readonly Version: number;
  141956. /**
  141957. * Populated with the last native XR Hit Results
  141958. */
  141959. lastNativeXRHitResults: XRHitResult[];
  141960. /**
  141961. * Triggered when new babylon (transformed) hit test results are available
  141962. */
  141963. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  141964. /**
  141965. * Creates a new instance of the (legacy version) hit test feature
  141966. * @param _xrSessionManager an instance of WebXRSessionManager
  141967. * @param options options to use when constructing this feature
  141968. */
  141969. constructor(_xrSessionManager: WebXRSessionManager,
  141970. /**
  141971. * options to use when constructing this feature
  141972. */
  141973. options?: IWebXRHitTestOptions);
  141974. /**
  141975. * execute a hit test with an XR Ray
  141976. *
  141977. * @param xrSession a native xrSession that will execute this hit test
  141978. * @param xrRay the ray (position and direction) to use for ray-casting
  141979. * @param referenceSpace native XR reference space to use for the hit-test
  141980. * @param filter filter function that will filter the results
  141981. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141982. */
  141983. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  141984. /**
  141985. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  141986. * @param event the (select) event to use to select with
  141987. * @param referenceSpace the reference space to use for this hit test
  141988. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141989. */
  141990. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141991. /**
  141992. * attach this feature
  141993. * Will usually be called by the features manager
  141994. *
  141995. * @returns true if successful.
  141996. */
  141997. attach(): boolean;
  141998. /**
  141999. * detach this feature.
  142000. * Will usually be called by the features manager
  142001. *
  142002. * @returns true if successful.
  142003. */
  142004. detach(): boolean;
  142005. /**
  142006. * Dispose this feature and all of the resources attached
  142007. */
  142008. dispose(): void;
  142009. protected _onXRFrame(frame: XRFrame): void;
  142010. private _onHitTestResults;
  142011. private _onSelect;
  142012. }
  142013. }
  142014. declare module BABYLON {
  142015. /**
  142016. * Options used in the plane detector module
  142017. */
  142018. export interface IWebXRPlaneDetectorOptions {
  142019. /**
  142020. * The node to use to transform the local results to world coordinates
  142021. */
  142022. worldParentNode?: TransformNode;
  142023. }
  142024. /**
  142025. * A babylon interface for a WebXR plane.
  142026. * A Plane is actually a polygon, built from N points in space
  142027. *
  142028. * Supported in chrome 79, not supported in canary 81 ATM
  142029. */
  142030. export interface IWebXRPlane {
  142031. /**
  142032. * a babylon-assigned ID for this polygon
  142033. */
  142034. id: number;
  142035. /**
  142036. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142037. */
  142038. polygonDefinition: Array<Vector3>;
  142039. /**
  142040. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142041. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142042. */
  142043. transformationMatrix: Matrix;
  142044. /**
  142045. * the native xr-plane object
  142046. */
  142047. xrPlane: XRPlane;
  142048. }
  142049. /**
  142050. * The plane detector is used to detect planes in the real world when in AR
  142051. * For more information see https://github.com/immersive-web/real-world-geometry/
  142052. */
  142053. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142054. private _options;
  142055. private _detectedPlanes;
  142056. private _enabled;
  142057. private _lastFrameDetected;
  142058. /**
  142059. * The module's name
  142060. */
  142061. static readonly Name: string;
  142062. /**
  142063. * The (Babylon) version of this module.
  142064. * This is an integer representing the implementation version.
  142065. * This number does not correspond to the WebXR specs version
  142066. */
  142067. static readonly Version: number;
  142068. /**
  142069. * Observers registered here will be executed when a new plane was added to the session
  142070. */
  142071. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142072. /**
  142073. * Observers registered here will be executed when a plane is no longer detected in the session
  142074. */
  142075. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142076. /**
  142077. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142078. * This can execute N times every frame
  142079. */
  142080. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142081. /**
  142082. * construct a new Plane Detector
  142083. * @param _xrSessionManager an instance of xr Session manager
  142084. * @param _options configuration to use when constructing this feature
  142085. */
  142086. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142087. /**
  142088. * Dispose this feature and all of the resources attached
  142089. */
  142090. dispose(): void;
  142091. protected _onXRFrame(frame: XRFrame): void;
  142092. private _init;
  142093. private _updatePlaneWithXRPlane;
  142094. /**
  142095. * avoiding using Array.find for global support.
  142096. * @param xrPlane the plane to find in the array
  142097. */
  142098. private findIndexInPlaneArray;
  142099. }
  142100. }
  142101. declare module BABYLON {
  142102. /**
  142103. * Configuration options of the anchor system
  142104. */
  142105. export interface IWebXRAnchorSystemOptions {
  142106. /**
  142107. * Should a new anchor be added every time a select event is triggered
  142108. */
  142109. addAnchorOnSelect?: boolean;
  142110. /**
  142111. * should the anchor system use plane detection.
  142112. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142113. */
  142114. usePlaneDetection?: boolean;
  142115. /**
  142116. * a node that will be used to convert local to world coordinates
  142117. */
  142118. worldParentNode?: TransformNode;
  142119. }
  142120. /**
  142121. * A babylon container for an XR Anchor
  142122. */
  142123. export interface IWebXRAnchor {
  142124. /**
  142125. * A babylon-assigned ID for this anchor
  142126. */
  142127. id: number;
  142128. /**
  142129. * Transformation matrix to apply to an object attached to this anchor
  142130. */
  142131. transformationMatrix: Matrix;
  142132. /**
  142133. * The native anchor object
  142134. */
  142135. xrAnchor: XRAnchor;
  142136. }
  142137. /**
  142138. * An implementation of the anchor system of WebXR.
  142139. * Note that the current documented implementation is not available in any browser. Future implementations
  142140. * will use the frame to create an anchor and not the session or a detected plane
  142141. * For further information see https://github.com/immersive-web/anchors/
  142142. */
  142143. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142144. private _options;
  142145. private _enabled;
  142146. private _hitTestModule;
  142147. private _lastFrameDetected;
  142148. private _onSelect;
  142149. private _planeDetector;
  142150. private _trackedAnchors;
  142151. /**
  142152. * The module's name
  142153. */
  142154. static readonly Name: string;
  142155. /**
  142156. * The (Babylon) version of this module.
  142157. * This is an integer representing the implementation version.
  142158. * This number does not correspond to the WebXR specs version
  142159. */
  142160. static readonly Version: number;
  142161. /**
  142162. * Observers registered here will be executed when a new anchor was added to the session
  142163. */
  142164. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142165. /**
  142166. * Observers registered here will be executed when an anchor was removed from the session
  142167. */
  142168. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142169. /**
  142170. * Observers registered here will be executed when an existing anchor updates
  142171. * This can execute N times every frame
  142172. */
  142173. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142174. /**
  142175. * constructs a new anchor system
  142176. * @param _xrSessionManager an instance of WebXRSessionManager
  142177. * @param _options configuration object for this feature
  142178. */
  142179. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142180. /**
  142181. * Add anchor at a specific XR point.
  142182. *
  142183. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142184. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142185. * @returns a promise the fulfills when the anchor was created
  142186. */
  142187. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142188. /**
  142189. * attach this feature
  142190. * Will usually be called by the features manager
  142191. *
  142192. * @returns true if successful.
  142193. */
  142194. attach(): boolean;
  142195. /**
  142196. * detach this feature.
  142197. * Will usually be called by the features manager
  142198. *
  142199. * @returns true if successful.
  142200. */
  142201. detach(): boolean;
  142202. /**
  142203. * Dispose this feature and all of the resources attached
  142204. */
  142205. dispose(): void;
  142206. /**
  142207. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142208. * @param hitTestModule the hit-test module to use.
  142209. */
  142210. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142211. /**
  142212. * set the plane detector to use in order to create anchors from frames
  142213. * @param planeDetector the plane-detector module to use
  142214. * @param enable enable plane-anchors. default is true
  142215. */
  142216. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142217. protected _onXRFrame(frame: XRFrame): void;
  142218. /**
  142219. * avoiding using Array.find for global support.
  142220. * @param xrAnchor the plane to find in the array
  142221. */
  142222. private _findIndexInAnchorArray;
  142223. private _updateAnchorWithXRFrame;
  142224. }
  142225. }
  142226. declare module BABYLON {
  142227. /**
  142228. * Options interface for the background remover plugin
  142229. */
  142230. export interface IWebXRBackgroundRemoverOptions {
  142231. /**
  142232. * Further background meshes to disable when entering AR
  142233. */
  142234. backgroundMeshes?: AbstractMesh[];
  142235. /**
  142236. * flags to configure the removal of the environment helper.
  142237. * If not set, the entire background will be removed. If set, flags should be set as well.
  142238. */
  142239. environmentHelperRemovalFlags?: {
  142240. /**
  142241. * Should the skybox be removed (default false)
  142242. */
  142243. skyBox?: boolean;
  142244. /**
  142245. * Should the ground be removed (default false)
  142246. */
  142247. ground?: boolean;
  142248. };
  142249. /**
  142250. * don't disable the environment helper
  142251. */
  142252. ignoreEnvironmentHelper?: boolean;
  142253. }
  142254. /**
  142255. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142256. */
  142257. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142258. /**
  142259. * read-only options to be used in this module
  142260. */
  142261. readonly options: IWebXRBackgroundRemoverOptions;
  142262. /**
  142263. * The module's name
  142264. */
  142265. static readonly Name: string;
  142266. /**
  142267. * The (Babylon) version of this module.
  142268. * This is an integer representing the implementation version.
  142269. * This number does not correspond to the WebXR specs version
  142270. */
  142271. static readonly Version: number;
  142272. /**
  142273. * registered observers will be triggered when the background state changes
  142274. */
  142275. onBackgroundStateChangedObservable: Observable<boolean>;
  142276. /**
  142277. * constructs a new background remover module
  142278. * @param _xrSessionManager the session manager for this module
  142279. * @param options read-only options to be used in this module
  142280. */
  142281. constructor(_xrSessionManager: WebXRSessionManager,
  142282. /**
  142283. * read-only options to be used in this module
  142284. */
  142285. options?: IWebXRBackgroundRemoverOptions);
  142286. /**
  142287. * attach this feature
  142288. * Will usually be called by the features manager
  142289. *
  142290. * @returns true if successful.
  142291. */
  142292. attach(): boolean;
  142293. /**
  142294. * detach this feature.
  142295. * Will usually be called by the features manager
  142296. *
  142297. * @returns true if successful.
  142298. */
  142299. detach(): boolean;
  142300. /**
  142301. * Dispose this feature and all of the resources attached
  142302. */
  142303. dispose(): void;
  142304. protected _onXRFrame(_xrFrame: XRFrame): void;
  142305. private _setBackgroundState;
  142306. }
  142307. }
  142308. declare module BABYLON {
  142309. /**
  142310. * Options for the controller physics feature
  142311. */
  142312. export class IWebXRControllerPhysicsOptions {
  142313. /**
  142314. * Should the headset get its own impostor
  142315. */
  142316. enableHeadsetImpostor?: boolean;
  142317. /**
  142318. * Optional parameters for the headset impostor
  142319. */
  142320. headsetImpostorParams?: {
  142321. /**
  142322. * The type of impostor to create. Default is sphere
  142323. */
  142324. impostorType: number;
  142325. /**
  142326. * the size of the impostor. Defaults to 10cm
  142327. */
  142328. impostorSize?: number | {
  142329. width: number;
  142330. height: number;
  142331. depth: number;
  142332. };
  142333. /**
  142334. * Friction definitions
  142335. */
  142336. friction?: number;
  142337. /**
  142338. * Restitution
  142339. */
  142340. restitution?: number;
  142341. };
  142342. /**
  142343. * The physics properties of the future impostors
  142344. */
  142345. physicsProperties?: {
  142346. /**
  142347. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142348. * Note that this requires a physics engine that supports mesh impostors!
  142349. */
  142350. useControllerMesh?: boolean;
  142351. /**
  142352. * The type of impostor to create. Default is sphere
  142353. */
  142354. impostorType?: number;
  142355. /**
  142356. * the size of the impostor. Defaults to 10cm
  142357. */
  142358. impostorSize?: number | {
  142359. width: number;
  142360. height: number;
  142361. depth: number;
  142362. };
  142363. /**
  142364. * Friction definitions
  142365. */
  142366. friction?: number;
  142367. /**
  142368. * Restitution
  142369. */
  142370. restitution?: number;
  142371. };
  142372. /**
  142373. * the xr input to use with this pointer selection
  142374. */
  142375. xrInput: WebXRInput;
  142376. }
  142377. /**
  142378. * Add physics impostor to your webxr controllers,
  142379. * including naive calculation of their linear and angular velocity
  142380. */
  142381. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142382. private readonly _options;
  142383. private _attachController;
  142384. private _controllers;
  142385. private _debugMode;
  142386. private _delta;
  142387. private _headsetImpostor?;
  142388. private _headsetMesh?;
  142389. private _lastTimestamp;
  142390. private _tmpQuaternion;
  142391. private _tmpVector;
  142392. /**
  142393. * The module's name
  142394. */
  142395. static readonly Name: string;
  142396. /**
  142397. * The (Babylon) version of this module.
  142398. * This is an integer representing the implementation version.
  142399. * This number does not correspond to the webxr specs version
  142400. */
  142401. static readonly Version: number;
  142402. /**
  142403. * Construct a new Controller Physics Feature
  142404. * @param _xrSessionManager the corresponding xr session manager
  142405. * @param _options options to create this feature with
  142406. */
  142407. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142408. /**
  142409. * @hidden
  142410. * enable debugging - will show console outputs and the impostor mesh
  142411. */
  142412. _enablePhysicsDebug(): void;
  142413. /**
  142414. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142415. * @param xrController the controller to add
  142416. */
  142417. addController(xrController: WebXRInputSource): void;
  142418. /**
  142419. * attach this feature
  142420. * Will usually be called by the features manager
  142421. *
  142422. * @returns true if successful.
  142423. */
  142424. attach(): boolean;
  142425. /**
  142426. * detach this feature.
  142427. * Will usually be called by the features manager
  142428. *
  142429. * @returns true if successful.
  142430. */
  142431. detach(): boolean;
  142432. /**
  142433. * Get the headset impostor, if enabled
  142434. * @returns the impostor
  142435. */
  142436. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142437. /**
  142438. * Get the physics impostor of a specific controller.
  142439. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142440. * @param controller the controller or the controller id of which to get the impostor
  142441. * @returns the impostor or null
  142442. */
  142443. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142444. /**
  142445. * Update the physics properties provided in the constructor
  142446. * @param newProperties the new properties object
  142447. */
  142448. setPhysicsProperties(newProperties: {
  142449. impostorType?: number;
  142450. impostorSize?: number | {
  142451. width: number;
  142452. height: number;
  142453. depth: number;
  142454. };
  142455. friction?: number;
  142456. restitution?: number;
  142457. }): void;
  142458. protected _onXRFrame(_xrFrame: any): void;
  142459. private _detachController;
  142460. }
  142461. }
  142462. declare module BABYLON {
  142463. /**
  142464. * The motion controller class for all microsoft mixed reality controllers
  142465. */
  142466. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142467. protected readonly _mapping: {
  142468. defaultButton: {
  142469. "valueNodeName": string;
  142470. "unpressedNodeName": string;
  142471. "pressedNodeName": string;
  142472. };
  142473. defaultAxis: {
  142474. "valueNodeName": string;
  142475. "minNodeName": string;
  142476. "maxNodeName": string;
  142477. };
  142478. buttons: {
  142479. "xr-standard-trigger": {
  142480. "rootNodeName": string;
  142481. "componentProperty": string;
  142482. "states": string[];
  142483. };
  142484. "xr-standard-squeeze": {
  142485. "rootNodeName": string;
  142486. "componentProperty": string;
  142487. "states": string[];
  142488. };
  142489. "xr-standard-touchpad": {
  142490. "rootNodeName": string;
  142491. "labelAnchorNodeName": string;
  142492. "touchPointNodeName": string;
  142493. };
  142494. "xr-standard-thumbstick": {
  142495. "rootNodeName": string;
  142496. "componentProperty": string;
  142497. "states": string[];
  142498. };
  142499. };
  142500. axes: {
  142501. "xr-standard-touchpad": {
  142502. "x-axis": {
  142503. "rootNodeName": string;
  142504. };
  142505. "y-axis": {
  142506. "rootNodeName": string;
  142507. };
  142508. };
  142509. "xr-standard-thumbstick": {
  142510. "x-axis": {
  142511. "rootNodeName": string;
  142512. };
  142513. "y-axis": {
  142514. "rootNodeName": string;
  142515. };
  142516. };
  142517. };
  142518. };
  142519. /**
  142520. * The base url used to load the left and right controller models
  142521. */
  142522. static MODEL_BASE_URL: string;
  142523. /**
  142524. * The name of the left controller model file
  142525. */
  142526. static MODEL_LEFT_FILENAME: string;
  142527. /**
  142528. * The name of the right controller model file
  142529. */
  142530. static MODEL_RIGHT_FILENAME: string;
  142531. profileId: string;
  142532. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142533. protected _getFilenameAndPath(): {
  142534. filename: string;
  142535. path: string;
  142536. };
  142537. protected _getModelLoadingConstraints(): boolean;
  142538. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142539. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142540. protected _updateModel(): void;
  142541. }
  142542. }
  142543. declare module BABYLON {
  142544. /**
  142545. * The motion controller class for oculus touch (quest, rift).
  142546. * This class supports legacy mapping as well the standard xr mapping
  142547. */
  142548. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142549. private _forceLegacyControllers;
  142550. private _modelRootNode;
  142551. /**
  142552. * The base url used to load the left and right controller models
  142553. */
  142554. static MODEL_BASE_URL: string;
  142555. /**
  142556. * The name of the left controller model file
  142557. */
  142558. static MODEL_LEFT_FILENAME: string;
  142559. /**
  142560. * The name of the right controller model file
  142561. */
  142562. static MODEL_RIGHT_FILENAME: string;
  142563. /**
  142564. * Base Url for the Quest controller model.
  142565. */
  142566. static QUEST_MODEL_BASE_URL: string;
  142567. profileId: string;
  142568. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142569. protected _getFilenameAndPath(): {
  142570. filename: string;
  142571. path: string;
  142572. };
  142573. protected _getModelLoadingConstraints(): boolean;
  142574. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142575. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142576. protected _updateModel(): void;
  142577. /**
  142578. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142579. * between the touch and touch 2.
  142580. */
  142581. private _isQuest;
  142582. }
  142583. }
  142584. declare module BABYLON {
  142585. /**
  142586. * The motion controller class for the standard HTC-Vive controllers
  142587. */
  142588. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142589. private _modelRootNode;
  142590. /**
  142591. * The base url used to load the left and right controller models
  142592. */
  142593. static MODEL_BASE_URL: string;
  142594. /**
  142595. * File name for the controller model.
  142596. */
  142597. static MODEL_FILENAME: string;
  142598. profileId: string;
  142599. /**
  142600. * Create a new Vive motion controller object
  142601. * @param scene the scene to use to create this controller
  142602. * @param gamepadObject the corresponding gamepad object
  142603. * @param handness the handness of the controller
  142604. */
  142605. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142606. protected _getFilenameAndPath(): {
  142607. filename: string;
  142608. path: string;
  142609. };
  142610. protected _getModelLoadingConstraints(): boolean;
  142611. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142612. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142613. protected _updateModel(): void;
  142614. }
  142615. }
  142616. declare module BABYLON {
  142617. /**
  142618. * A cursor which tracks a point on a path
  142619. */
  142620. export class PathCursor {
  142621. private path;
  142622. /**
  142623. * Stores path cursor callbacks for when an onchange event is triggered
  142624. */
  142625. private _onchange;
  142626. /**
  142627. * The value of the path cursor
  142628. */
  142629. value: number;
  142630. /**
  142631. * The animation array of the path cursor
  142632. */
  142633. animations: Animation[];
  142634. /**
  142635. * Initializes the path cursor
  142636. * @param path The path to track
  142637. */
  142638. constructor(path: Path2);
  142639. /**
  142640. * Gets the cursor point on the path
  142641. * @returns A point on the path cursor at the cursor location
  142642. */
  142643. getPoint(): Vector3;
  142644. /**
  142645. * Moves the cursor ahead by the step amount
  142646. * @param step The amount to move the cursor forward
  142647. * @returns This path cursor
  142648. */
  142649. moveAhead(step?: number): PathCursor;
  142650. /**
  142651. * Moves the cursor behind by the step amount
  142652. * @param step The amount to move the cursor back
  142653. * @returns This path cursor
  142654. */
  142655. moveBack(step?: number): PathCursor;
  142656. /**
  142657. * Moves the cursor by the step amount
  142658. * If the step amount is greater than one, an exception is thrown
  142659. * @param step The amount to move the cursor
  142660. * @returns This path cursor
  142661. */
  142662. move(step: number): PathCursor;
  142663. /**
  142664. * Ensures that the value is limited between zero and one
  142665. * @returns This path cursor
  142666. */
  142667. private ensureLimits;
  142668. /**
  142669. * Runs onchange callbacks on change (used by the animation engine)
  142670. * @returns This path cursor
  142671. */
  142672. private raiseOnChange;
  142673. /**
  142674. * Executes a function on change
  142675. * @param f A path cursor onchange callback
  142676. * @returns This path cursor
  142677. */
  142678. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142679. }
  142680. }
  142681. declare module BABYLON {
  142682. /** @hidden */
  142683. export var blurPixelShader: {
  142684. name: string;
  142685. shader: string;
  142686. };
  142687. }
  142688. declare module BABYLON {
  142689. /** @hidden */
  142690. export var pointCloudVertexDeclaration: {
  142691. name: string;
  142692. shader: string;
  142693. };
  142694. }
  142695. // Mixins
  142696. interface Window {
  142697. mozIndexedDB: IDBFactory;
  142698. webkitIndexedDB: IDBFactory;
  142699. msIndexedDB: IDBFactory;
  142700. webkitURL: typeof URL;
  142701. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142702. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142703. WebGLRenderingContext: WebGLRenderingContext;
  142704. MSGesture: MSGesture;
  142705. CANNON: any;
  142706. AudioContext: AudioContext;
  142707. webkitAudioContext: AudioContext;
  142708. PointerEvent: any;
  142709. Math: Math;
  142710. Uint8Array: Uint8ArrayConstructor;
  142711. Float32Array: Float32ArrayConstructor;
  142712. mozURL: typeof URL;
  142713. msURL: typeof URL;
  142714. VRFrameData: any; // WebVR, from specs 1.1
  142715. DracoDecoderModule: any;
  142716. setImmediate(handler: (...args: any[]) => void): number;
  142717. }
  142718. interface HTMLCanvasElement {
  142719. requestPointerLock(): void;
  142720. msRequestPointerLock?(): void;
  142721. mozRequestPointerLock?(): void;
  142722. webkitRequestPointerLock?(): void;
  142723. /** Track wether a record is in progress */
  142724. isRecording: boolean;
  142725. /** Capture Stream method defined by some browsers */
  142726. captureStream(fps?: number): MediaStream;
  142727. }
  142728. interface CanvasRenderingContext2D {
  142729. msImageSmoothingEnabled: boolean;
  142730. }
  142731. interface MouseEvent {
  142732. mozMovementX: number;
  142733. mozMovementY: number;
  142734. webkitMovementX: number;
  142735. webkitMovementY: number;
  142736. msMovementX: number;
  142737. msMovementY: number;
  142738. }
  142739. interface Navigator {
  142740. mozGetVRDevices: (any: any) => any;
  142741. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142742. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142743. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142744. webkitGetGamepads(): Gamepad[];
  142745. msGetGamepads(): Gamepad[];
  142746. webkitGamepads(): Gamepad[];
  142747. }
  142748. interface HTMLVideoElement {
  142749. mozSrcObject: any;
  142750. }
  142751. interface Math {
  142752. fround(x: number): number;
  142753. imul(a: number, b: number): number;
  142754. }
  142755. interface WebGLRenderingContext {
  142756. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142757. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142758. vertexAttribDivisor(index: number, divisor: number): void;
  142759. createVertexArray(): any;
  142760. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142761. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142762. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142763. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142764. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142765. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142766. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142767. // Queries
  142768. createQuery(): WebGLQuery;
  142769. deleteQuery(query: WebGLQuery): void;
  142770. beginQuery(target: number, query: WebGLQuery): void;
  142771. endQuery(target: number): void;
  142772. getQueryParameter(query: WebGLQuery, pname: number): any;
  142773. getQuery(target: number, pname: number): any;
  142774. MAX_SAMPLES: number;
  142775. RGBA8: number;
  142776. READ_FRAMEBUFFER: number;
  142777. DRAW_FRAMEBUFFER: number;
  142778. UNIFORM_BUFFER: number;
  142779. HALF_FLOAT_OES: number;
  142780. RGBA16F: number;
  142781. RGBA32F: number;
  142782. R32F: number;
  142783. RG32F: number;
  142784. RGB32F: number;
  142785. R16F: number;
  142786. RG16F: number;
  142787. RGB16F: number;
  142788. RED: number;
  142789. RG: number;
  142790. R8: number;
  142791. RG8: number;
  142792. UNSIGNED_INT_24_8: number;
  142793. DEPTH24_STENCIL8: number;
  142794. MIN: number;
  142795. MAX: number;
  142796. /* Multiple Render Targets */
  142797. drawBuffers(buffers: number[]): void;
  142798. readBuffer(src: number): void;
  142799. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142800. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142801. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142802. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142803. // Occlusion Query
  142804. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142805. ANY_SAMPLES_PASSED: number;
  142806. QUERY_RESULT_AVAILABLE: number;
  142807. QUERY_RESULT: number;
  142808. }
  142809. interface WebGLProgram {
  142810. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142811. }
  142812. interface EXT_disjoint_timer_query {
  142813. QUERY_COUNTER_BITS_EXT: number;
  142814. TIME_ELAPSED_EXT: number;
  142815. TIMESTAMP_EXT: number;
  142816. GPU_DISJOINT_EXT: number;
  142817. QUERY_RESULT_EXT: number;
  142818. QUERY_RESULT_AVAILABLE_EXT: number;
  142819. queryCounterEXT(query: WebGLQuery, target: number): void;
  142820. createQueryEXT(): WebGLQuery;
  142821. beginQueryEXT(target: number, query: WebGLQuery): void;
  142822. endQueryEXT(target: number): void;
  142823. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142824. deleteQueryEXT(query: WebGLQuery): void;
  142825. }
  142826. interface WebGLUniformLocation {
  142827. _currentState: any;
  142828. }
  142829. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142830. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142831. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142832. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142833. interface WebGLRenderingContext {
  142834. readonly RASTERIZER_DISCARD: number;
  142835. readonly DEPTH_COMPONENT24: number;
  142836. readonly TEXTURE_3D: number;
  142837. readonly TEXTURE_2D_ARRAY: number;
  142838. readonly TEXTURE_COMPARE_FUNC: number;
  142839. readonly TEXTURE_COMPARE_MODE: number;
  142840. readonly COMPARE_REF_TO_TEXTURE: number;
  142841. readonly TEXTURE_WRAP_R: number;
  142842. readonly HALF_FLOAT: number;
  142843. readonly RGB8: number;
  142844. readonly RED_INTEGER: number;
  142845. readonly RG_INTEGER: number;
  142846. readonly RGB_INTEGER: number;
  142847. readonly RGBA_INTEGER: number;
  142848. readonly R8_SNORM: number;
  142849. readonly RG8_SNORM: number;
  142850. readonly RGB8_SNORM: number;
  142851. readonly RGBA8_SNORM: number;
  142852. readonly R8I: number;
  142853. readonly RG8I: number;
  142854. readonly RGB8I: number;
  142855. readonly RGBA8I: number;
  142856. readonly R8UI: number;
  142857. readonly RG8UI: number;
  142858. readonly RGB8UI: number;
  142859. readonly RGBA8UI: number;
  142860. readonly R16I: number;
  142861. readonly RG16I: number;
  142862. readonly RGB16I: number;
  142863. readonly RGBA16I: number;
  142864. readonly R16UI: number;
  142865. readonly RG16UI: number;
  142866. readonly RGB16UI: number;
  142867. readonly RGBA16UI: number;
  142868. readonly R32I: number;
  142869. readonly RG32I: number;
  142870. readonly RGB32I: number;
  142871. readonly RGBA32I: number;
  142872. readonly R32UI: number;
  142873. readonly RG32UI: number;
  142874. readonly RGB32UI: number;
  142875. readonly RGBA32UI: number;
  142876. readonly RGB10_A2UI: number;
  142877. readonly R11F_G11F_B10F: number;
  142878. readonly RGB9_E5: number;
  142879. readonly RGB10_A2: number;
  142880. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142881. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142882. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142883. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142884. readonly DEPTH_COMPONENT32F: number;
  142885. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142886. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142887. 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;
  142888. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142889. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142890. readonly TRANSFORM_FEEDBACK: number;
  142891. readonly INTERLEAVED_ATTRIBS: number;
  142892. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142893. createTransformFeedback(): WebGLTransformFeedback;
  142894. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142895. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142896. beginTransformFeedback(primitiveMode: number): void;
  142897. endTransformFeedback(): void;
  142898. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142899. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142900. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142901. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142902. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142903. }
  142904. interface ImageBitmap {
  142905. readonly width: number;
  142906. readonly height: number;
  142907. close(): void;
  142908. }
  142909. interface WebGLQuery extends WebGLObject {
  142910. }
  142911. declare var WebGLQuery: {
  142912. prototype: WebGLQuery;
  142913. new(): WebGLQuery;
  142914. };
  142915. interface WebGLSampler extends WebGLObject {
  142916. }
  142917. declare var WebGLSampler: {
  142918. prototype: WebGLSampler;
  142919. new(): WebGLSampler;
  142920. };
  142921. interface WebGLSync extends WebGLObject {
  142922. }
  142923. declare var WebGLSync: {
  142924. prototype: WebGLSync;
  142925. new(): WebGLSync;
  142926. };
  142927. interface WebGLTransformFeedback extends WebGLObject {
  142928. }
  142929. declare var WebGLTransformFeedback: {
  142930. prototype: WebGLTransformFeedback;
  142931. new(): WebGLTransformFeedback;
  142932. };
  142933. interface WebGLVertexArrayObject extends WebGLObject {
  142934. }
  142935. declare var WebGLVertexArrayObject: {
  142936. prototype: WebGLVertexArrayObject;
  142937. new(): WebGLVertexArrayObject;
  142938. };
  142939. // Type definitions for WebVR API
  142940. // Project: https://w3c.github.io/webvr/
  142941. // Definitions by: six a <https://github.com/lostfictions>
  142942. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142943. interface VRDisplay extends EventTarget {
  142944. /**
  142945. * Dictionary of capabilities describing the VRDisplay.
  142946. */
  142947. readonly capabilities: VRDisplayCapabilities;
  142948. /**
  142949. * z-depth defining the far plane of the eye view frustum
  142950. * enables mapping of values in the render target depth
  142951. * attachment to scene coordinates. Initially set to 10000.0.
  142952. */
  142953. depthFar: number;
  142954. /**
  142955. * z-depth defining the near plane of the eye view frustum
  142956. * enables mapping of values in the render target depth
  142957. * attachment to scene coordinates. Initially set to 0.01.
  142958. */
  142959. depthNear: number;
  142960. /**
  142961. * An identifier for this distinct VRDisplay. Used as an
  142962. * association point in the Gamepad API.
  142963. */
  142964. readonly displayId: number;
  142965. /**
  142966. * A display name, a user-readable name identifying it.
  142967. */
  142968. readonly displayName: string;
  142969. readonly isConnected: boolean;
  142970. readonly isPresenting: boolean;
  142971. /**
  142972. * If this VRDisplay supports room-scale experiences, the optional
  142973. * stage attribute contains details on the room-scale parameters.
  142974. */
  142975. readonly stageParameters: VRStageParameters | null;
  142976. /**
  142977. * Passing the value returned by `requestAnimationFrame` to
  142978. * `cancelAnimationFrame` will unregister the callback.
  142979. * @param handle Define the hanle of the request to cancel
  142980. */
  142981. cancelAnimationFrame(handle: number): void;
  142982. /**
  142983. * Stops presenting to the VRDisplay.
  142984. * @returns a promise to know when it stopped
  142985. */
  142986. exitPresent(): Promise<void>;
  142987. /**
  142988. * Return the current VREyeParameters for the given eye.
  142989. * @param whichEye Define the eye we want the parameter for
  142990. * @returns the eye parameters
  142991. */
  142992. getEyeParameters(whichEye: string): VREyeParameters;
  142993. /**
  142994. * Populates the passed VRFrameData with the information required to render
  142995. * the current frame.
  142996. * @param frameData Define the data structure to populate
  142997. * @returns true if ok otherwise false
  142998. */
  142999. getFrameData(frameData: VRFrameData): boolean;
  143000. /**
  143001. * Get the layers currently being presented.
  143002. * @returns the list of VR layers
  143003. */
  143004. getLayers(): VRLayer[];
  143005. /**
  143006. * Return a VRPose containing the future predicted pose of the VRDisplay
  143007. * when the current frame will be presented. The value returned will not
  143008. * change until JavaScript has returned control to the browser.
  143009. *
  143010. * The VRPose will contain the position, orientation, velocity,
  143011. * and acceleration of each of these properties.
  143012. * @returns the pose object
  143013. */
  143014. getPose(): VRPose;
  143015. /**
  143016. * Return the current instantaneous pose of the VRDisplay, with no
  143017. * prediction applied.
  143018. * @returns the current instantaneous pose
  143019. */
  143020. getImmediatePose(): VRPose;
  143021. /**
  143022. * The callback passed to `requestAnimationFrame` will be called
  143023. * any time a new frame should be rendered. When the VRDisplay is
  143024. * presenting the callback will be called at the native refresh
  143025. * rate of the HMD. When not presenting this function acts
  143026. * identically to how window.requestAnimationFrame acts. Content should
  143027. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143028. * asynchronously from other displays and at differing refresh rates.
  143029. * @param callback Define the eaction to run next frame
  143030. * @returns the request handle it
  143031. */
  143032. requestAnimationFrame(callback: FrameRequestCallback): number;
  143033. /**
  143034. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143035. * Repeat calls while already presenting will update the VRLayers being displayed.
  143036. * @param layers Define the list of layer to present
  143037. * @returns a promise to know when the request has been fulfilled
  143038. */
  143039. requestPresent(layers: VRLayer[]): Promise<void>;
  143040. /**
  143041. * Reset the pose for this display, treating its current position and
  143042. * orientation as the "origin/zero" values. VRPose.position,
  143043. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143044. * updated when calling resetPose(). This should be called in only
  143045. * sitting-space experiences.
  143046. */
  143047. resetPose(): void;
  143048. /**
  143049. * The VRLayer provided to the VRDisplay will be captured and presented
  143050. * in the HMD. Calling this function has the same effect on the source
  143051. * canvas as any other operation that uses its source image, and canvases
  143052. * created without preserveDrawingBuffer set to true will be cleared.
  143053. * @param pose Define the pose to submit
  143054. */
  143055. submitFrame(pose?: VRPose): void;
  143056. }
  143057. declare var VRDisplay: {
  143058. prototype: VRDisplay;
  143059. new(): VRDisplay;
  143060. };
  143061. interface VRLayer {
  143062. leftBounds?: number[] | Float32Array | null;
  143063. rightBounds?: number[] | Float32Array | null;
  143064. source?: HTMLCanvasElement | null;
  143065. }
  143066. interface VRDisplayCapabilities {
  143067. readonly canPresent: boolean;
  143068. readonly hasExternalDisplay: boolean;
  143069. readonly hasOrientation: boolean;
  143070. readonly hasPosition: boolean;
  143071. readonly maxLayers: number;
  143072. }
  143073. interface VREyeParameters {
  143074. /** @deprecated */
  143075. readonly fieldOfView: VRFieldOfView;
  143076. readonly offset: Float32Array;
  143077. readonly renderHeight: number;
  143078. readonly renderWidth: number;
  143079. }
  143080. interface VRFieldOfView {
  143081. readonly downDegrees: number;
  143082. readonly leftDegrees: number;
  143083. readonly rightDegrees: number;
  143084. readonly upDegrees: number;
  143085. }
  143086. interface VRFrameData {
  143087. readonly leftProjectionMatrix: Float32Array;
  143088. readonly leftViewMatrix: Float32Array;
  143089. readonly pose: VRPose;
  143090. readonly rightProjectionMatrix: Float32Array;
  143091. readonly rightViewMatrix: Float32Array;
  143092. readonly timestamp: number;
  143093. }
  143094. interface VRPose {
  143095. readonly angularAcceleration: Float32Array | null;
  143096. readonly angularVelocity: Float32Array | null;
  143097. readonly linearAcceleration: Float32Array | null;
  143098. readonly linearVelocity: Float32Array | null;
  143099. readonly orientation: Float32Array | null;
  143100. readonly position: Float32Array | null;
  143101. readonly timestamp: number;
  143102. }
  143103. interface VRStageParameters {
  143104. sittingToStandingTransform?: Float32Array;
  143105. sizeX?: number;
  143106. sizeY?: number;
  143107. }
  143108. interface Navigator {
  143109. getVRDisplays(): Promise<VRDisplay[]>;
  143110. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143111. }
  143112. interface Window {
  143113. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143114. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143115. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143116. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143117. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143118. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143119. }
  143120. interface Gamepad {
  143121. readonly displayId: number;
  143122. }
  143123. type XRSessionMode =
  143124. | "inline"
  143125. | "immersive-vr"
  143126. | "immersive-ar";
  143127. type XRReferenceSpaceType =
  143128. | "viewer"
  143129. | "local"
  143130. | "local-floor"
  143131. | "bounded-floor"
  143132. | "unbounded";
  143133. type XREnvironmentBlendMode =
  143134. | "opaque"
  143135. | "additive"
  143136. | "alpha-blend";
  143137. type XRVisibilityState =
  143138. | "visible"
  143139. | "visible-blurred"
  143140. | "hidden";
  143141. type XRHandedness =
  143142. | "none"
  143143. | "left"
  143144. | "right";
  143145. type XRTargetRayMode =
  143146. | "gaze"
  143147. | "tracked-pointer"
  143148. | "screen";
  143149. type XREye =
  143150. | "none"
  143151. | "left"
  143152. | "right";
  143153. interface XRSpace extends EventTarget {
  143154. }
  143155. interface XRRenderState {
  143156. depthNear?: number;
  143157. depthFar?: number;
  143158. inlineVerticalFieldOfView?: number;
  143159. baseLayer?: XRWebGLLayer;
  143160. }
  143161. interface XRInputSource {
  143162. handedness: XRHandedness;
  143163. targetRayMode: XRTargetRayMode;
  143164. targetRaySpace: XRSpace;
  143165. gripSpace: XRSpace | undefined;
  143166. gamepad: Gamepad | undefined;
  143167. profiles: Array<string>;
  143168. }
  143169. interface XRSessionInit {
  143170. optionalFeatures?: XRReferenceSpaceType[];
  143171. requiredFeatures?: XRReferenceSpaceType[];
  143172. }
  143173. interface XRSession extends XRAnchorCreator {
  143174. addEventListener: Function;
  143175. removeEventListener: Function;
  143176. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143177. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143178. requestAnimationFrame: Function;
  143179. end(): Promise<void>;
  143180. renderState: XRRenderState;
  143181. inputSources: Array<XRInputSource>;
  143182. // AR hit test
  143183. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143184. updateWorldTrackingState(options: {
  143185. planeDetectionState?: { enabled: boolean; }
  143186. }): void;
  143187. }
  143188. interface XRReferenceSpace extends XRSpace {
  143189. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143190. onreset: any;
  143191. }
  143192. type XRPlaneSet = Set<XRPlane>;
  143193. type XRAnchorSet = Set<XRAnchor>;
  143194. interface XRFrame {
  143195. session: XRSession;
  143196. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143197. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143198. // Anchors
  143199. trackedAnchors?: XRAnchorSet;
  143200. // Planes
  143201. worldInformation: {
  143202. detectedPlanes?: XRPlaneSet;
  143203. };
  143204. }
  143205. interface XRViewerPose extends XRPose {
  143206. views: Array<XRView>;
  143207. }
  143208. interface XRPose {
  143209. transform: XRRigidTransform;
  143210. emulatedPosition: boolean;
  143211. }
  143212. interface XRWebGLLayerOptions {
  143213. antialias?: boolean;
  143214. depth?: boolean;
  143215. stencil?: boolean;
  143216. alpha?: boolean;
  143217. multiview?: boolean;
  143218. framebufferScaleFactor?: number;
  143219. }
  143220. declare var XRWebGLLayer: {
  143221. prototype: XRWebGLLayer;
  143222. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143223. };
  143224. interface XRWebGLLayer {
  143225. framebuffer: WebGLFramebuffer;
  143226. framebufferWidth: number;
  143227. framebufferHeight: number;
  143228. getViewport: Function;
  143229. }
  143230. declare class XRRigidTransform {
  143231. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143232. position: DOMPointReadOnly;
  143233. orientation: DOMPointReadOnly;
  143234. matrix: Float32Array;
  143235. inverse: XRRigidTransform;
  143236. }
  143237. interface XRView {
  143238. eye: XREye;
  143239. projectionMatrix: Float32Array;
  143240. transform: XRRigidTransform;
  143241. }
  143242. interface XRInputSourceChangeEvent {
  143243. session: XRSession;
  143244. removed: Array<XRInputSource>;
  143245. added: Array<XRInputSource>;
  143246. }
  143247. interface XRInputSourceEvent extends Event {
  143248. readonly frame: XRFrame;
  143249. readonly inputSource: XRInputSource;
  143250. }
  143251. // Experimental(er) features
  143252. declare class XRRay {
  143253. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143254. origin: DOMPointReadOnly;
  143255. direction: DOMPointReadOnly;
  143256. matrix: Float32Array;
  143257. }
  143258. interface XRHitResult {
  143259. hitMatrix: Float32Array;
  143260. }
  143261. interface XRAnchor {
  143262. // remove?
  143263. id?: string;
  143264. anchorSpace: XRSpace;
  143265. lastChangedTime: number;
  143266. detach(): void;
  143267. }
  143268. interface XRPlane extends XRAnchorCreator {
  143269. orientation: "Horizontal" | "Vertical";
  143270. planeSpace: XRSpace;
  143271. polygon: Array<DOMPointReadOnly>;
  143272. lastChangedTime: number;
  143273. }
  143274. interface XRAnchorCreator {
  143275. // AR Anchors
  143276. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143277. }